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)
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
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)
gem update --system
This command work for me
After run try this gem list bundler
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
I observed that sometime default gems are not present in the INSTALLATION DIRECTORY path provided in the output of gem environment command.
I observed this problem in Alpine OS where Ruby v2.7.0 is installed.
In such cases you can use gem list -d <GEM_NAME> -v <VERSION> command to get the location where default gem is installed.
/ # gem list -d rexml -v 3.2.3
*** LOCAL GEMS ***
rexml (3.2.3)
Author: Kouhei Sutou
Homepage: https://github.com/ruby/rexml
License: BSD-2-Clause
Installed at (default): /usr/lib/ruby/gems/2.7.0
An XML toolkit for Ruby
To remove default version you can use /usr/lib/ruby/gems/2.7.0 shown in above output. Delete command will be:
rm -rf <INSTALLED_AT_PATH>/specifications/default/<GEM_NAME>-<VERSION>.gemspec
For example:
rm -rf /usr/lib/ruby/gems/2.7.0/specifications/default/rexml-3.2.3.gemspec
With some bundler versions: you just get:
gem list bundler
# bundler (2.1.4, default: 1.17.3)
you install new version of bundler, set it to default and you get multiple default bundler versions
gem install --default bundler -v2.3.8
# bundler (default: 2.3.8, 2.1.4, default: 1.17.3)
and than you can reinstall old default version without --default parameter so it would be reinstalled as non-default and than you can uninstall it.
gem install bundler -v1.17.3
# bundler (default: 2.3.8, 2.1.4, 1.17.3)
and uninstall old default one
gem uninstall bundler -v1.17.3
# bundler (default: 2.3.8, 2.1.4)
Came late to the party but perhaps my findings may help somebody:
After Ruby 2.6 bundler became a default gem this means that for each ruby version there's a default bundler, and the bundler gem comes with an executable bundle command.
You can't remove this gem and the only way to update the default gems is to update the RubyGems system using gem update --system [<version>]
I Had a lot of problems removing files in install paths to force the default gem, I wouldn't recommend but YMMV. In order to have a ruby 2.6.x with a 2.x default and working bundler, I had to start from a clean ruby installation and update the Rubygems to the point it had the bundler version that the project required.
As #theist points out, after Ruby 2.6 bundler became a default gem. So depending on your version of Ruby, you will have a different version of bundler included. You can see the list here.
But what has not been explained in the answers so far is that you can control which version of bundler is used by editing your Gemfile.lock and specifying the version you want to use on the very last line of the file, where it says:
BUNDLED WITH
2.2.33
This feels completely backwards since Gemfile.lock is supposed to be generated automatically by bundler, but that is the state of things at this point.
So, let's explain it all with an example. Let's say I am using Ruby 3.0.3. This version of Ruby comes with bundler 2.2.32. But my hosting company, Heroku, is using bundler 2.2.33. Since I want my dev environment to use the same bundler version as my production environment, I want to use 2.2.33.
So the first thing to do is gem install bundler -v "2.2.33". Then change the very bottom line of Gemfile.lock to say that it was bundled with 2.2.33 like:
BUNDLED WITH
2.2.33
Now when you run bundle install it will use bundler 2.2.33.
You can find the default one at /usr/local/bin/, so if you delete that one and have ruby installed with homebrew for instance, it will dafault to the one that homebrew has.
After deleting it you should see something like:
open . /usr/local/bin/
bundler -v
Bundler version 2.3.25
which bundler
/opt/homebrew/opt/ruby/bin/bundler
If and only if you are using ruby with homebrew, make sure you have it exported to your path: export PATH=/opt/homebrew/opt/ruby/bin:$PATH
TLDR: uninstall ruby & then reinstall it.
Details:
For others using rbenv who have exhausted other ideas, the following worked for me:
exit your project directory (e.g. cd /tmp)
uninstall ruby (e.g. rbenv uninstall 2.6.6)
reinstall ruby (e.g. rbenv install 2.6.6)
return to your project directory (cd -)
install the RubyGems you desire (e.g. gem install bundler:2.1.4)
In your project directory you will see something like this:
-bash> gem list | grep bundle
bundler (2.1.4, default: 1.17.2)
Outside your project directory (e.g. cd /tmp) you will see something like this:
-bash> gem list | grep bundle
bundler (default: 1.17.2)
Related
$ gem list bundler
*** LOCAL GEMS ***
bundler (default: 1.17.3)
capistrano-bundler (2.0.1)
$ ruby --version
ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-darwin19]
$ bundle _1.17.3_ -v
Bundler version 2.1.4
Why does Bundler claim to be 2.1.4, when I don't have that installed?
Is this a way of trying to force me to upgrade by making my Gemfile think I used a newer version, and then making me install that to continue?
Or is there some configuration that I'm overlooking?
UPDATE
gem list bundle -d returns
*** LOCAL GEMS ***
bundler (1.17.3)
Authors: André Arko, Samuel Giddins, Colby Swandale, Hiroshi
Shibata, David Rodríguez, Grey Baker, Stephanie Morillo, Chris
Morris, James Wen, Tim Moore, André Medeiros, Jessica Lynn Suttles,
Terence Lee, Carl Lerche, Yehuda Katz
Homepage: http://bundler.io
License: MIT
Installed at (default): /Users/brandon/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0
The best way to manage your application's dependencies
capistrano-bundler (2.0.1)
Authors: Tom Clements, Lee Hambley, Kir Shatrov
Homepage: https://github.com/capistrano/bundler
License: MIT
Installed at: /Users/brandon/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0
Bundler support for Capistrano 3.x
which bundle returns
/Users/brandon/.rbenv/shims/bundle
Running eval "$(rbenv init -)" does not change anything.
Updating above 2.1.4 doesn't fix the problem either. No matter what I install, I'm told I'm using 2.1.4:
$ gem install --default bundler:2.2.24
Successfully installed bundler-2.2.24 as a default gem
WARNING: Unable to pull data from 'https://gems.github.com/': bad response Not Found 404 (https://gems.github.com/specs.4.8.gz)
1 gem installed
$ bundler --version
Bundler version 2.1.4
You probably have couple versions installed,
try
gem list bundle -d
to see where those are installed
which bundle
to see where 2.1.4 resides
If you are working in a shared environment,
may be the root user would have the bundler which is showing bundle -v as 2.1.4
to find it, you can try digging it in your environment
by env command which will give your environment variables list:
$ env
$ echo $PATH
and your bundler list which you are seeing on gem list bundler would be from your local user space
you can refer these too, which would probably hit the solution
How to `bundle install` when your Gemfile requires an older version of bundler?
How to bundle install gemfile with specific version of bundler
I'm having trouble creating a new Rails app. I'm using a fresh WSL2 + Ubuntu 18.04 install.
Long story short, I followed the Rails installation procedure from https://gorails.com/setup/windows/10 but when installing bundle using gem install bundler, I end up with 2 bundler versions (2.1.2 and 2.1.4).
If I stick with 2.1.2 webpacker throws an error, so I definitely need to install the newest version. The problem is, when I install 2.1.4 the default version remains 2.1.2, so then I go to cd /.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/specifications/default and remove bundler-2.1.2.gemspec, and then I do a gem install bundler --default to get only v2.1.4 as default:
gem list bundler
*** LOCAL GEMS ***
bundler (default: 2.1.4)
But here is the problem; if I run bundler -v I get:
bundler -v
Bundler version 2.1.2
But the real problem is that, when running rails new, it clearly tries to use 2.1.2 which inevitably fails.
How can I solve this?
Thank you
Try gem uninstall bundler --version 2.1.2.
From the app directory run these commands:
gem install bundler
bundle update --bundler
bundle install
This rebuilds the Gemfile.lock with the correct Bundler version.
EDIT: You can create the directory first with rails new my_rails_app, then do cd .. ; rails new my_rails_app after running the above commands.
bundler (2.0.1, default: 1.17.2)
How could I change the default to 2.0.1
Following https://bundler.io/guides/bundler_2_upgrade.html#upgrading-applications-from-bundler-1-to-bundler-2, here's what worked for me:
gem install --default bundler
gem update --system
bundle update --bundler
What helped me is to delete the current default manually from the folder
lib\ruby\gems\2.6.0\specifications\default\
and then install fresh bundler as usually
gem install bundler
or as default
gem install --default bundler
I had this same concern when trying to setup Bundler gem 2.2.11 as the default gem on my machine.
Here's how I achieved it:
First, I listed and uninstalled all other versions of the Bundler gem because I did not need them:
gem list bundler
gem uninstall bundler
If you encounter an error like this
Gem bundler-2.1.4 cannot be uninstalled because it is a default gem
Simply run the command below to get your ruby installation directory:
gem environment | grep "INSTALLATION DIRECTORY"
This should display an output like this. In my case my ruby version was 2.7.2:
- INSTALLATION DIRECTORY: /home/mycomputer/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0
Next, navigate to the specifications/default directory of the INSTALLATION PATH:
cd /home/mycomputer/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/specifications/default
Remove/delete the bundler.gemspec file that you have there. In my case it was bundler-2.1.4.gemspec, so I ran the command:
rm bundler-2.1.4.gemspec
Next, I installed the Bundler gem 2.2.11 and made it the default gem:
gem install --default bundler -v 2.2.11
Next, I listed my Bundler versions:
gem list bundler
Finally, I updated my gems to use the newly installed Bundler:
gem update --system
That's all.
I hope this helps
You need to remove .spec file to remove the gem.
Steps:
gem env – try to search in provided list under GEM PATHS, in specifications/default
remove there bundler-VERSION.gemspec
install bundler, if you don't have specific: gem install bundler:VERSION --default
gem install --default bundler:<version>
You need to know where the default specs are, so use gem environment to find out.
the steps I used were:
gem environment
# note INSTALLATION DIRECTORY
cd <installation_dir>
cd specifications/default
rm bundler-2.1.4.gemspec
gem install --default bundler -v 2.2.11
Remove all default bundler versions.
Commands:
$ gem environment
$ cd INSTALLATION DIRECTORY
$ cd specifications
$ cd default
$ rm bundler version
$ gem install bundler
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?
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)
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
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.
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
When I run the following command, it gives me the available installed versions of bundler:
command :
gem list | grep "bundle"
output:
bundler (1.11.2, 1.10.6, 1.10.4, 1.3.6, 1.3.0, 1.3.0.pre)
The current version of bundler I obtained was 1.11.2 using the following command:
bundler --version
I want to use version 1.3.6
How do I swap the current version of bundler with the available ones?
Normally during development Bundler is used from it's executable on your system, so I don't believe you can specify a specific version in your Gemfile, for example. (You might try it, though). However, you can install the version you like and force the shell/rubygems to use that version:
$ gem install bundler -v 1.3.6
...
1 gem installed
$ bundle _1.3.6_ -v
Bundler version 1.3.6
To get my machine to use 1.3.6 by default I had to uninstall 1.11.2.
Update: I tried specifying gem 'bundler', '~> 1.3' in one of my projects and it worked, although the CLI for bundler still used the system default version.
Sept 2019
If you want to upgrade bundler 1 to 2, then you should do the following:
1- The first step in upgrading to Bundler 2 is installing the Bundler 2 gem by running:
gem install bundler
2- When Bundler 2 installed, Bundler will automatically switch between version 1 and version 2 based on your application’s Gemfile.lock based on the BUNDLED WITH ((version)) in your Gemfile.lock
Note:
Before the next step, you should commit your Gemfile & Gemfile.lock, so that you can revert to bundler version 1 if needed
3- To upgrade from bundler 1 to 2, run:
bundle update --bundler
The answer is based on the official bundler update guide
To change your bundler default version, use bundle config default <the desired version>.