How can I remove default version of bundler?

混江龙づ霸主 提交于 2020-08-04 02:28:33

问题


I tried to change default bundle version but it getting updated with 2 default version. How can I modify to single default?

$ gem list bundler

*** LOCAL GEMS ***

bundler (2.0.1, default: 1.16.6, default: 1.16.2)

If I do gem uninstall not removing defaults,

$ gem uninstall bundler
Successfully uninstalled bundler-2.0.1


$ gem list bundle

*** LOCAL GEMS ***

bundler (default: 1.16.6, default: 1.16.2)

How can I set (like the below) default as single version?

bundler (2.0.1, default: 1.16.6)

回答1:


I had the same problem but with a newer version

$ gem list bundler

*** LOCAL GEMS ***

bundler (default: 2.1.4, default: 2.1.2)

But after following indications on this post Two default versions of rake installed - how to delete one allowed me to deleted one.


You have to delete the .gemspec file corresponding to the default gem you want to delete.

So first, locate where those files are.

# I'm running RVM to manage my Ruby versions

~/.rvm/rubies/ruby-2.7.0/lib/ruby/gems/2.7.0/specifications/default/

-rw-r--r--   1 myuser  staff  10731 Dec 26 17:22 bundler-2.1.2.gemspec
-rw-r--r--   1 myuser  staff  15134 Jan  7 17:30 bundler-2.1.4.gemspec

Delete the one you don't need.

$ rm ~/.rvm/rubies/ruby-2.7.0/lib/ruby/gems/2.7.0/specifications/default/bundler-2.1.2.gemspec

Then install (or reinstall) the gem you want to set as default.

$ gem install bundler:2.1.4 --default

Successfully installed bundler-2.1.4 as a default gem

Finally you'll have installed only the version you wanted.

$ gem list bundler

*** LOCAL GEMS ***

bundler (default: 2.1.4)



回答2:


gem update --system

This command work for me

After run try this gem list bundler




回答3:


For those who use rbenv, let say by accidentally you have two default versions

$ gem list | grep bundler
bundler (default: 2.1.4, default: 1.17.2)

Check your gem installation path

$ gem environment
RubyGems Environment:
.
.
- INSTALLATION DIRECTORY: /home/yohanes/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0
.

Go to the specifications/default directory and look for bundlers gemspec

$ cd /home/yohanes/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/specifications/default
$ ls -lah
total 200K
drwxr-xr-x 2 yohanes yohanes 4,0K Jun  1 10:05 .
drwxr-xr-x 3 yohanes yohanes  20K Jun  1 10:05 ..
.
.
-rw-r--r-- 1 yohanes yohanes  16K Jun  1 10:05 bundler-1.17.2.gemspec
-rw-r--r-- 1 yohanes yohanes  15K Jun  1 09:31 bundler-2.1.4.gemspec
.
.

Remove the version that you need to remove

$ rm bundler-2.1.4.gemspec

Check again

$ gem list | grep bundler
bundler (default: 1.17.2)
$ gem list bundler

*** LOCAL GEMS ***

bundler (default: 1.17.2)

but, if you check bundle version, you still get the deleted version as default

$ bundler -v
Bundler version 2.1.4

So we have to overrides it by reinstalling the required bundler version again

$ gem install bundler --version '1.17.2'
Successfully installed bundler-1.17.2
Parsing documentation for bundler-1.17.2
Done installing documentation for bundler after 1 seconds
1 gem installed

Then, if you check again it will show you the desired version

$ bundle -v
Bundler version 1.17.2



回答4:


The rbenv path to the offending default .gemspec should be like below.

/Users/yourusername/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/specifications/default/bundler-2.1.2.gemspec


来源:https://stackoverflow.com/questions/57306611/how-can-i-remove-default-version-of-bundler

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!