Not able to update Bundler version - ruby

I have a gemfile.lock which requires Bundle 2.2.19 . My system has Bundle 1.11.2. Now I ran the following commands:
gem update --system
sudo gem install bundler
Has the following output:
Successfully installed bundler-2.2.31.gem
But after that, I do:
Bundler --version
I still get
Bundler version 1.11.2
And if I try to do
bundle install
I get
You must use Bundler 2 or greater with this lock file
I also tried running
bundler update --bundler
But that does not work either. I also tried uninstalling and reinstalling but while uninstalling, it only uninstalls the 2.2.31 version. Also tried something like
bundle _2.2.31_ install
But it says could not find command. Any suggestions are welcome.

Related

Bundler 2.2.0 and Ruby 2.7.5 on Docker crashing

I installed Ruby 2.7.5, and within the Dockerfile, specified bundler (version 2.2.0) to be installed:
RUN gem install bundler -v 2.2.0 --no-document
the output of this is:
INFO[0093] RUN gem install bundler -v 2.2.0 --no-document
INFO[0093] cmd: /bin/sh
INFO[0093] args: [-c gem install bundler -v 2.2.0 --no-document]
INFO[0093] Running: [/bin/sh -c gem install bundler -v 2.2.0 --no-document]
Successfully installed bundler-2.2.0
All seemed to be fine in that install, and bundle works as gems specified in Gemfile are installed. However, when I try to open the console, I see this:
/usr/lib/ruby/2.7.0/rubygems.rb:277:in `find_spec_for_exe': Could not find 'bundler' (2.2.0) required by your /app/Gemfile.lock. (Gem::GemNotFoundException)
To update to the latest version installed on your system, run `bundle update --bundler`.
To install the missing version, run `gem install bundler:2.2.0`
However, it is installed. as you can see from above. Also, when I output the version within the Dockerfile, I see:
Bundler version 2.2.0
It seemed to install fine, however, still see the error above, and it crashes immediately.
Is there something obvious I am doing wrong?
Building a Docker Image with an Updated Bundler Version
You're missing a couple of steps in your Dockerfile build for bundled gems. After you update Bundler, you also need to update your Gemfile.lock and possibly re-run bundle install. There are a lot of options involved, but here's my personal recommendation for your Dockerfile based on your post:
# Note: Don't lock your Bundler version unless you
# have a VERY good reason to do so. Update will
# install or update, as needed.
RUN gem update bundler --no-document \
&& gem clean bundler \
&& bundle update --bundler \
&& bundle install
The key here is that if you don't use bundle update --bundler then the Gemfile.lock will not contain the version of Bundler that you're expecting to call. Recent versions of Bundler will downgrade themselves to the version in the Gemfile.lock if necessary, so this is really the key to the whole thing.
In addition, if you continue to have problems after applying the recipe above, you may need to figure out where Bundler is actually being installed inside your container image. While Bundler (currently) doesn't run from inside your bundle, the required version still needs to be in GEM_HOME, GEM_ROOT, or GEM_PATH in order to be found when you invoke it.
As a final consideration, if you're building your gems locally or modifying your Gemfile.lock and then using an ADD or COPY command to place the Gemfile.lock or any vendored gems into your container image, you need to perform these activities outside of Docker rather than inside the Dockerfile. Based on your original post it doesn't look like you're doing that now, but it's another option to consider as you work on resolving this.

How can Bundler be inactive if it's appearing in my gem list?

Im trying to install this Rails project (https://github.com/mjohnson324/MockDoc/blob/master/docs/setup.md)
when running 'bundle install' I get the following error:
Traceback (most recent call last):
2: from /usr/bin/bundle:23:in `<main>'
1: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems.rb:302:in `activate_bin_path'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems.rb:283:in `find_spec_for_exe': Could not find 'bundler' (2.0.2) required by your /Users/michaelkoch/projects/MockDoc-master/Gemfile.lock. (Gem::GemNotFoundException)
To update to the latest version installed on your system, run `bundle update --bundler`.
To install the missing version, run `gem install bundler:2.0.2`
So I run 'gem install bundler:2.0.2' and the install seems to work. Here's the output:
Successfully installed bundler-2.0.2
Parsing documentation for bundler-2.0.2
Done installing documentation for bundler after 2 seconds
1 gem installed
If I run gem list I see the following line: bundler (2.1.4, 2.0.2)
If I run bundle install command again, I get the same orginal error, as if bundler is not installed.
I'm using rbenv to manage versions, as indicated by the Github project.
I kindly as for your help.
I encountered a similar issue on my MacBook M1 system while trying to use 2.1.4 for my project. I tried deleting the gemfile.lock and reinstalling by running gem install bundler:2.1.4 and then bundle install as suggested by #Giuseppe Schembri but that didn't solve my issue.
I navigated to the root directory, and tried to check the global version by running
bundler version
and got-
Bundler version 2.3.22 ([date] commit [commit_id])
I again navigated to my project directory, and ran bundler version again, and got -
Bundler version 2.1.4 ([date] commit [commit_id])
News flash: bundler 2.1.4 is installed for my project.
Then why does the error persist?
Aparently, I had a post-checkout file in my .git > hook which was trying to execute bundler exec pod install and failing.
Later I realized, it couldn't find the path for the bundler. so I get the path by running
type bundler
which returned
bundler is /Users/myUserName/.rbenv/shims/bundler
Then rather than bundler exec pod install, I used /Users/myUserName/.rbenv/shims/bundler exec pod install.
In the newer versions of OS on M1, this can happen.

Bundle install fails, Gem install succeeds

When trying to bundle install on a Gemfile that contained only the GitHub Pages gem and nothing else, on Ubuntu 18.04, I got error messages telling me to try installing eventmachine using gem install. That always succeeds, but bundle install still fails. How can I get bundler to see that the gem is installed?
I fixed this after many hours of struggle, by noticing that on the GitHub Pages repo there's a note that says
Important: Make sure you have Bundler > v1.14 by running gem update bundler in your terminal before following the next steps.
I have no idea why this mattered but I removed my ruby packages from Ubuntu and reinstalled them, then installed bundler with rubygems, which gave me a newer version:
sudo apt-get remove ruby
sudo apt-get install ruby ruby-dev
sudo gem install bundler
bundler --version
If anyone knows why I needed that version of bundler, or how I should have diagnosed this faster, I'd be interested to hear it. I'm not new to programming but I'm new to Ruby.
From my understanding it might be the gem you are trying to install requires a specific feature provided by bundler. If you check the change log of bundler there is some changes related to install github based gems on how to correctly read the user git settings. So I think that might be where the problem is from.

Travis reports odd message of corrupted Gemfile.lock

Im using bundler to install stuff and since I have added Gemfile.lock, travis started to complain with:
Your Gemfile.lock is corrupt. The following gem is missing from the DEPENDENCIES
section: 'echoe'
Of course, everything works locally. It also works using DeployBot. I even installed docker ubuntu and tried, still ok. My Gemfile.lock is not corrupt. Same versions of ruby and bundler is used.
What is going on?
Update
This is something related to bundler version. Im using 1.11.0, but got reports that it worked with eg. 1.8.3. ??
We've seen a very similar issue today on Buildkite due to the recent release of a new bundler version
https://rubygems.org/gems/bundler/versions/1.11.0
We got the build working by stipulating the version of bundler to install.
gem install -v 1.10.6 bundler --no-rdoc --no-ri
and forcing the use of that
bundle _1.10.6_ install
Firstly, remove the gem lock file:
rm -f Gemfile.lock
Then install the dependencies:
bundle install
You can update the dependencies to ensure that you won't get an error:
bundle update

dev_appserver.rb cannot start after rubygems update on Ubuntu 10.04

I had rubygems 1.3.5 (or 1.3.6?) installed and then made a sudo gem update after a long while again. Some gems complained they needed a newer gems version. Because sudo gem update --system is deactivated on Ubuntu I followed these steps: How can I get RubyGems 1.3.6 on Ubuntu 10.4
But now I cannot start the dev_appserver.rb anymore, it says:
=> Bundling gems
ERROR: While executing gem ... (RuntimeError)
Unknown command bundle
I also tried to do sudo gem update and sudo gem update --system again a few times but everything is up-to-date now. Here is a list of my gems: http://pastebin.com/cFaTCyF5
It's a bit of a hack around but I can't really tell what's going on properly from what you sent but I know a few people have been having problems after running gem update --system lately. Find out what version you've just installed with
gem list
Look for the update, should look something like this: rubygems-update-1.5.0
Then try rolling back your rubygems version
sudo gem uninstall rubygems-update -v 1.5.0
sudo gem install rubygems-update -v 1.4.2 <-- try a different version
gem install --system 1.3.7 worked in my case

Resources