Whenever I run bundle update or bundle install on Windows 8.1 I can't update/install gems from github. I can install other gems like uglifier, but it doesn't work for github gems specifically. For example, putting this in the Gemfile
group :development, :test do
gem 'rspec-rails', '2.13.1'
gem 'spork-rails', github: 'sporkrb/spork-rails'
end
results in the error:
Retrying source fetch due to error (2/3): You need to install git to be able to use gems from git repositories.
The problem is I definitely have git installed. I was running this from Git Bash and working in a project that I was cloning, pulling, and working with off of Git. So why does the bundle update/install keep insisting that I don't have git installed? How do I fix it and make bundle install work?
Are you running a pre-release version of Bundler? This commit might be related to your problem; it looks like earlier versions of Bundler scan your %PATH% for "git", but not "git.exe".
The easiest solution would be to backport bundler to 1.3.5:
gem uninstall bundler
gem install bundler
Don't forget to select radio "Use git from Windows Command Prompt" while installing the Git. Thats the key!
By default "Use git from Git Bash only" is set.
For me it was also the path, with space and accent, I guess that was the accent the issue. installed the bundler 1.6-pre, uninstalled git, reinstalled it in C:\Git, changed the path of git in my IDE (RubyMine) and finally installed every gems using bundle install.
Thanks a lot!
While on Windows, if you're still getting that error after installing git too, make sure to close the 'CMD' instance and open it again, the system paths vars have been set, but not instantiated in the active 'CMD' window.
Related
I want to get a Gem's version without running bundle install.
Which is to say I want figure out what version bundle is planning to install without actually installing the gem.
Say read it from the Gemfile.lock(and Gemfile) combined.
Is there a way I can resolve what version bundler plans to install?
I need this because I want to cache the expensive installs while running docker build.
Gems like rails(nokogiri) take a while to install and I would like to do gem install rails -v ... in a previous step before running bundle install.
For this purpose i need to get the rails version before hand
If you add a new gem to your gemfile, but don't do bundle install, it doesn't install yet. Instead, you can run bundle lock, which generates a new lock file. This includes the gem version of the new gem that would be installed.
By running bundle show new_gem, it shows it isn't actually installed.
To be sure maybe get a backup of the original Gemfile.lock before running the command though.
By default if no version is specified in the Gemfile, running bundle install will attempt to install the latest version of the gem which is compatible with the rest of the gems and ruby version in your project. This will create a Gemfile.lock file if one doesn't already exist. If a Gemfile.lock file is already committed to git repo, it should then install the versions specified in Gemfile.lock. The point of bundler is to handle dependencies to insure your stack works correctly.
To see the version of a gem bundler is currently using you can run
bundle show rails
You will probably want to specify the ruby version in the Gemfile for example
ruby '~> 2.5' #
You can specify exact version of a gem in the Gemfile like this which you should be able to rely on to be the version bundler will install so long as it's compatible with the rest of the stack. bundle install will throw errors if there are incompatible gem versions.
gem 'rails', '4.2.11' # this will always install only this version.
You may also use pessimistic operator (~>) to set for only minor updates
gem 'influxdb', '~> 0.6.1' # could go to 0.6.2 but never 0.7.0
You can also set minimum versions like this although it's probably not what you need for your question.
gem 'pg_query', '>= 0.9.0'
If you have a Gemfile.lock already in your repo you can see which version would be installed by running for example:
gem show rails
Which would show you the version and weather it or not it is currently installed.
For more info see bundle --help
Where does bundle install fit into the add-commit-push workflow? In other words, when is it necessary.
You will need to launch bundle install every time that you update your Gemfile.
Before you run it, make sure you have bundler gem installed:
$ gem install bundler
You can integrate this command and several others adding some git hooks. For example, I use overcommit gem to make sure that some actions are performed before commit, merge and push.
You would want to ensure that you have run bundle install before adding files to a git commit.
You should be in the habit of running bundle install every time your Gemfile is changed.
Please note: Git and Bundler are independent. The only reason you want to have run bundle install before adding to git is to ensure that your Gemfile.lock is updated to contain the latest information.
I am developing with bundler under Windows and am wondering how to create the Gemfile.lock for my production environment.
What seems missing are the gems for other platforms. Running bundle install on
group :production do
gem 'mysql2'
end
on Windows creates a Gemfile.lock
mysql2 (0.3.18-x86-mingw32)
When deploying to a Linux environment this is obviously not correct, I would need the Gemfile.lock to also contain the correct result for Linux. I can run bundle install on Linux and learn that indeed
mysql2 (0.3.18)
is the correct gem for Linux. I then manually update the Gemfile.lock in the repository to contain both:
mysql2 (0.3.18)
mysql2 (0.3.18-x86-mingw32)
This works clean under both platforms, but it seems a kludge.
How can I tell bundle to resolve the Gemfile.lock for another platform other than the local one? I guess I need something like bundle install --all-platforms. What am I missing?
It would appear this is a known shortcoming in bundler and the workaround seems to be to run bundle pack on every platform you need to use.
Running the following commands will fix your issue.
bundle lock --add-platform x86_64-linux
bundle install
git add . ; git commit -m fix
Reference
https://www.moncefbelyamani.com/understanding-the-gemfile-lock-file/#platforms
https://bundler.io/man/gemfile.5.html#PLATFORMS
https://github.com/rubygems/rubygems/issues/4269#issuecomment-758564690
In my Rails app, I have installed the gem sdoc from Github by specifying gem 'sdoc', github: 'voloko/sdoc' in my Gemfile. All was well until I recently updated Bundler to v1.6.0.rc.
Now I get the following error message when Bundler tries to load the gem:
There was a LoadError while loading sdoc.gemspec:
cannot infer basepath from
/Users/manuel/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/bundler/gems/sdoc-1a0e80c2d629/sdoc.gemspec:2:in `require_relative'
Does it try to require a relative path? That's been removed in Ruby 1.9.
I've already fixed the issue and submitted a pull request, but I cannot get rid of the "broken" gem!
This is what I tried:
removing the gem from the Gemfile or setting it to a different version
removing Gemfile.lock
deleting the gem folder /Users/manuel/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/bundler/gems/sdoc-1a0e80c2d629
gem uninstall sdoc (It doesn't even appear in gem list)
Nothing helped, every time I do bundle install or bundle update afterwards, I get the same error.
Any hints?
First-off: Clarifying a few things
From the Bundler documentation:
Because Rubygems lacks the ability to handle gems from git, any gems installed from a git repository will not show up in gem list. They will, however, be available after running Bundler.setup
Also, after deleting the gem inside the . . . /bundler/gems/ directory, you also should run rbenv rehash. This should get rid of the gem for you.
Answer:
Go to the root directory of your project (where the Gemfile resides) and run bundle clean. You have to pass either --path or --force switches. This should remove gems installed via git (usually if you have those gems installed and listed by gem list).
If you have issues. Delete the directories manually as you already tried and run rbenv rehash.
If I were you I would downgrade Bundler (ie. uninstall the RC release and install the latest stable).
Authlogic has a couple unfortunate deprecation warnings that are fixed in a fork.
How do I use this forked version? I tried adding the following to my Gemfile:
gem 'authlogic', :git => 'git://github.com/railsware/authlogic.git'
And it didn't work quite that well. I started getting:
git://github.com/railsware/authlogic.git (at master) is not checked out. Please run bundle install
And
The git source git://github.com/railsware/authlogic.git is not yet checked out. Please run bundle install before trying to start your application
Assistance will be rewarded with virtual cookies.
Have you tried running bundle install after removing Gemfile.lock?
rm Gemfile.lock
bundle install
Your Gemfile configuration should work, I was able to use the same for and my bundle install command executes as does my bundle list command.
My other suggestion would be removing you ~/.bundler and .bundle directories and checking that you have properly configured git.
You need to run bundle install from the terminal after updating your Gemfile.