3

I had bundler 1.16 installed and rails was complaining that my bundle had previously been created with a higher version of bundler So I installed bundler 2.0.1 with the --default switch but that still left a default 1.16.6 as well I'm trying to uninstall 1.16.6 but I get error can't uninstall a default gem How can I remove it's default flag then? Also if I'm using rails 5.0.7 which ruby version should I use?

stuckonrails
  • 73
  • 1
  • 7
  • Might also be this thing I bumped into the other day: https://stackoverflow.com/questions/54123850/mismatched-bundler-version-bundler-2-ruby-2-6 – Dave Slutzkin Jan 13 '19 at 03:15

4 Answers4

3

I am not sure if this is the right way to do this, but, in my case, its how i got the issue fixed. So, just in-case this helps.

Initially:

gem list bundler

*** LOCAL GEMS ***

bundler (default: 2.0.2, default: 1.17.3, default: 1.16.6)
bundler-unload (1.0.2)
rubygems-bundler (1.4.5)

After failing multiple uninstalls, I ran this,

gem update --system

Then,

bundle version
Bundler version 1.17.3 (2019-08-16 commit d7089abb6)

(which is the version i required in my application)

gem list bundler

*** LOCAL GEMS ***

bundler (default: 1.17.3)
bundler-unload (1.0.2)
rubygems-bundler (1.4.5)
MonR
  • 111
  • 1
  • 4
0

If you really, really want to remove the default bundler, you can clobber it like I just did using something like this but adjusted for your ruby's versions and paths:

rm /usr/local/rbenv/versions/2.6.2/lib/ruby/2.6.0/bundler.rb
rm -r /usr/local/rbenv/versions/2.6.2/lib/ruby/2.6.0/bundler/
rm /usr/local/rbenv/versions/2.6.2/bin/bundle{,r}
rm /usr/local/rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/specifications/default/bundler-1.17.3.gemspec

Or, living dangerously:

rm -rf "$(ruby -e 'print RbConfig::CONFIG["rubylibdir"]')"/bundler{.rb,/} \
  "$(ruby -e 'print RbConfig::CONFIG["bindir"]')"/bundle{,r} \
  "$(ruby -e 'print Gem.dir')"/specifications/default/bundler-*.gemspec
sj26
  • 6,725
  • 2
  • 27
  • 24
0

I ran into the same problem. None of the suggested answers worked for me. Then I tried to install bundler again -- issue solved.

gem install bundler

hope it works for you too.

Arvind
  • 171
  • 1
  • 4
-2

Try

gem list -d

command to see the gems then use

gem uninstall bundler -v 1.16.6

or

gem uninstall bundler -v 1.16.6 --default

olucube.com
  • 330
  • 2
  • 11