How to solve bundler LoadError - ruby-on-rails

I am using rvm and running Ruby 2.6.1 and using rails 5.2.2. When I try bundler -v
I get the error:
Traceback (most recent call last):
3: from /home/amairu/.rvm/gems/ruby-2.6.1#rails522/bin/ruby_executable_hooks:24:in `<main>'
2: from /home/amairu/.rvm/gems/ruby-2.6.1#rails522/bin/ruby_executable_hooks:24:in `eval'
1: from /home/amairu/.rvm/gems/ruby-2.6.1#rails522/bin/bundler:23:in `<main>'
/home/amairu/.rvm/gems/ruby-2.6.1#rails522/bin/bundler:23:in `load': cannot load such file -- /home/amairu/.rvm/rubies/ruby-2.6.1/lib/ruby/gems/2.6.0/gems/bundler-1.17.3/exe/bundler (LoadError)
gem list bundler returns:
*** LOCAL GEMS ***
bundler (2.0.2, default: 1.17.3, 1.17.2)
bundler-unload (1.0.2)
rubygems-bundler (1.4.5)
It seems that it is trying to look for the file named "bundler" in /home/amairu/.rvm/rubies/ruby-2.6.1/lib/ruby/gems/2.6.0/gems/bundler-1.17.3/exe/ folder but there is no such file. The required file is in a different folder:
ls /home/amairu/.rvm/rubies/ruby-2.6.1/lib/ruby/gems/2.6.0/gems/bundler-1.17.2/exe/
> bundler
How can I set it such that the bundler -v command looks into the bundler-1.17.2/exe instead of the bundler-1.17.3/exe? In other words I need to set the default bundler version as 1.17.2 instead of 1.17.3
I have run:
gem uninstall bundler
gem install bundler
bundle install
Which install successfully but still I get an error with bundler -v.
A similar post suggest reinstalling Rails gem install rails -v 5.2.2 but this did not fix my issue.

You can try by uninstalling the bundler with version
gem uninstall bundler -v 2.0.2
gem uninstall bundler -v 1.17.3
gem uninstall bundler -v 1.17.2
and then check the gem list that bundler has been uninstalled
gem list bundler
If its get uninstalled then you can install bundler with version again
gem install bundler -v 1.17.2
Or if its not uninstalled then might be bundler gem is in your default gemset so you can use the default gemset and then try uninstalling and then install 1.17.2 again
rvm gemset use default
gem uninstall bundler -v 2.0.2
gem uninstall bundler -v 1.17.3
gem uninstall bundler -v 1.17.2
gem install bundler -v 1.17.2

I know this is quite old, but just to help anyone that is facing the same problem:
/home/amairu/.rvm/gems/ruby-2.6.1#rails522/bin/bundler:23:in `load': cannot load such file -- /home/amairu/.rvm/rubies/ruby-2.6.1/lib/ruby/gems/2.6.0/gems/bundler-1.17.3/exe/bundler (LoadError)
You have to reinstall the exact version that ruby is complying. In the error message above, it was looking for bundler version 1.17.3.
So you should only reinstall this exact version.
gem install bundler -v 1.17.3

Related

Bundler shows version I did not install

I installed bundler with the command
gem install bundler --default -v 1.17.3
When I hit gem list, I get
bundler (default: 1.17.3)
But if I do bundler -v or bundler --version, I get
Bundler version 2.2.14
Which I did not install, so perhaps it was there before, or I have no idea.
The problem is I can't do bundle install because it gives me issues with the version, saying bundler > 2.0 isn't compatible with some of my gems.
Any help is appreciated.

Bundler can't install signet

I've just removed rbenv as i wanted to install a newer Ruby version (2.6) than the ones available for rbenv, then installed Ruby 2.6, that went fine, now while trying to reinstall all the gems for my app I ran into the following problem:
$ bundle install
Installing signet 0.14.0
Gem::InstallError: signet requires Ruby version >= 2.4.0.
An error occurred while installing signet (0.14.0), and Bundler cannot continue.
Make sure that `gem install signet -v '0.14.0' --source 'https://rubygems.org/'` succeeds before bundling.
In Gemfile:
google_drive was resolved to 2.1.12, which depends on
google-api-client was resolved to 0.21.2, which depends on
googleauth was resolved to 0.6.7, which depends on
signet
But ruby has clearly been upgraded:
$ ruby -v
ruby 2.6.6p146 (2020-03-31 revision 67876) [x86_64-linux-gnu]
and if I try to install signet manually it works fine:
gem install signet -v '0.14.0' --source 'https://rubygems.org/'
Successfully installed signet-0.14.0
Parsing documentation for signet-0.14.0
Done installing documentation for signet after 0 seconds
1 gem installed
But then if i run bundle install again I still get the same problem. I've also tried bundle install --path vendor/cache and bundle install --system to no avail.
Note that the gems seem to install in the right place:
gem which signet
/var/lib/gems/2.6.0/gems/signet-0.14.0/lib/signet.rb
if I compare it to another one installed by bundler:
gem which multi_json
/var/lib/gems/2.6.0/gems/multi_json-1.14.1/lib/multi_json.rb
This is on Ubuntu 16.04.4 LTS and bundler 1.16.3
How do I fix this?
So I've finally figured it out, installing a newer version of bundler (but < 2.0 as Rails 4.2 requires it) did the trick, although i also had to uninstall the ruby 2.2-dev package and install the 2.6-dev package to be able to compile native gems like nokogiri, then running the whole thing specifying the bundler version.
For those interested, these were the commands:
apt-get remove ruby-dev
apt install ruby2.6-dev
gem install bundler -v 1.17.3
bundle _1.17.3_ install

Can not downgrade bundler

I am getting this error while trying to push my app to heroku:
Warning: the running version of Bundler (1.17.2) is older than the version that created the lockfile (1.17.3). We suggest you upgrade to the latest version of Bundler by runninggem install bundler. I have the following versions of bundler:
gem list | grep bundler
bundler (2.0.2, default: 1.17.3, 1.17.2)
I have tried various suggestions from different similar posts but I am not able to set the bundler version to 1.17.2 which is required by Heroku. I tried:
gem uninstall bundler
gem install bundler -v 1.17.2
1 gem installed
Then removed the lock file and rerunning the bundle update but the version 1.17.3 still comes as the default.
I tried gem uninstall bundler:1.17.3 which returned:
Successfully uninstalled bundler-1.17.3
Then: gem install bundler -v 1.17.2which returned:
Successfully installed bundler-1.17.2
1 gem installed
Now bundler -v returns a LoadError:
Traceback (most recent call last):
3: from /home/amairu/.rvm/gems/ruby-2.6.1#rails522/bin/ruby_executable_hooks:24:in `<main>'
2: from /home/amairu/.rvm/gems/ruby-2.6.1#rails522/bin/ruby_executable_hooks:24:in `eval'
1: from /home/amairu/.rvm/gems/ruby-2.6.1#rails522/bin/bundler:23:in `<main>'
/home/amairu/.rvm/gems/ruby-2.6.1#rails522/bin/bundler:23:in `load': cannot load such file -- /home/amairu/.rvm/rubies/ruby-2.6.1/lib/ruby/gems/2.6.0/gems/bundler-1.17.3/exe/bundler (LoadError)
I am using rvm and I also tried to uninstall in the global gem set:
rvm use 2.6.1#global
gem uninstall bundler:1.17.3 which does not return any output or message.
How can I set the bundler to 1.17.2?
set your bundler version as a default version like below if you want to use 2.0.2
bundle _2.0.2_ -v
I had troubles with bundlers recently (Bundler v2.0.2 was installed, v1.17.3 set as default) but with a different error (Can't find gem bundler (>= 0.a) with executable bundle (Gem::GemNotFoundException)).
Running gem update --system did a trick for me.
Install the correct bundler for your application with the following command:
gem install bundler -v "$(grep -A 1 "BUNDLED WITH" Gemfile.lock | tail -n 1)"

Gem install the wrong version of bundler

I had a problem with Bundler (bundle cannot load such file bundler-1.17.1/exe/bundle), so I removed Bundler then manually removed all bundler directory:
gem uninstall bundler -x
gem cleanup bundler
Then removed with rm -rf from:
~/.gem/ruby/2.5.1/gems/bundler-1.17.1
~/.rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/bundler-1.17.1
and ~/.bundle
Now, I would like to reinstall bundler with the default version, 1.17.1.
So I tried gem install bundler
gem install bundler
Fetching: bundler-1.17.1.gem (100%)
Successfully installed bundler-1.17.1
Parsing documentation for bundler-1.17.1
Installing ri documentation for bundler-1.17.1
Done installing documentation for bundler after 3 seconds
1 gem installed
If I try to execute a bundle command, I get this error:
bundle
Traceback (most recent call last):
1: from /Users/robin/.gem/ruby/2.5.1/bin/bundle:23:in `<main>'
/Users/robin/.gem/ruby/2.5.1/bin/bundle:23:in `load': cannot load such file -- /Users/robin/.rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/bundler-1.17.1/exe/bundle (LoadError)
I can see bundler-1.17.1 in ~/.gem/ruby/2.5.1/gems/bundler-1.17.1 but not in .rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/bundler-1.17.1. So I have to manually copy the folder:
cp -R ~/.gem/ruby/2.5.1/gems/bundler-1.17.1 ~/.rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/bundler-1.17.1
But now, if I try a bundle command, it works but I have this message in first line:
Warning: the running version of Bundler (1.16.2) is older than the version that created the lockfile (1.16.6). We suggest you upgrade to the latest version of Bundler by running 'gem install bundler'.
I tried to install bundler by gem install bundler -v 1.17.1 but I still have the problem.
gem list output:
gem list bundler
*** LOCAL GEMS ***
bundler (default: 1.17.1)
capistrano-bundler (1.4.0, 1.3.0)
my config:
macOS 10.13.6
ruby -v
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin17]
chruby
ruby-2.5.0
* ruby-2.5.1
rails -v
Rails 5.2.1
gem -v
2.7.7
EDIT:
I forgot to specify than gem pristine bundler doesn't work with bundler:
gem pristine bundler
Restoring gems to pristine condition...
Skipped bundler-1.17.1, it is a default gem
And if I try to uninstall bundler twice, I get this message:
gem uninstall bundler -x
ERROR: While executing gem ... (Gem::InstallError)
gem "bundler" cannot be uninstalled because it is a default gem
So i don't know if bundler is really uninstalled the first time.

Installing Rails with RVM, while checking rail -v: bundler-1.1.5 conflicts with bundler (~> 1.0.0)

I'm having a dearly hard time getting my rails environment up. Here is the issue.
$ gem install rails --version 3.0.1
Successfully installed rails-3.0.1
1 gem installed
Installing ri documentation for rails-3.0.1...
Installing RDoc documentation for rails-3.0.1...
$ rails -v
/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:1637:in `raise_if_conflicts': **Unable to activate rails-3.0.1, because bundler-1.1.5 conflicts with bundler (~> 1.0.0) (Gem::LoadError)**
from /.rvm/rubies/ruby-1.9.2- p320/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:746:in `activate'
from /.rvm/rubies/ruby-1.9.2-p320/lib/ruby/site_ruby/1.9.1/rubygems.rb:1232:in `gem'
from /.rvm/gems/ruby-1.9.2-p320#rails3tutorial/bin/rails:18:in `<main>'
from /.rvm/gems/ruby-1.9.2-p320#rails3tutorial/bin/ruby_noexec_wrapper:14:in `eval'
from /.rvm/gems/ruby-1.9.2-p320#rails3tutorial/bin/ruby_noexec_wrapper:14:in `<main>'
Here in lies the issue. I've reinstalled ruby. I've installed 1.8.7, 1.9.2, 1.9.3 and still no luck across the board.
i've run
$ gem update bundler
But bundle is 'up to date', so still no luck
I've really poked at this all day now, and with no luck I open my palms to you all.
the issue is that in #global gemset you have higher version of bundler then the one required.
you can either specify the version on command line:
bundle _1.0.27_ exec rails -v
or use Gemfile:
printf 'source :rubygems\ngem "rails", "3.0.1"\n'
rails -v
this assumed you have the gem rubygems-bundler - but it comes by default with RVM so you should have it.
and last - remove bundler from #global:
rvm #global do gem uninstall bundler
but there is one caveat - while reinstalling ruby gem bundler will be installed again.

Resources