How to specify version of bundler for bundle install - ruby-on-rails

When I try to bundle the gemfile of a new project I get :
Bundler could not find compatible versions for gem "bundler":
In Gemfile:
bundler-audit was resolved to 0.6.0, which depends on
bundler (~> 1.2)
rails (~> 5.2) was resolved to 5.2.1, which depends on
bundler (>= 1.3.0)
Current Bundler version:
bundler (2.0.2)
This Gemfile requires a different version of Bundler.
Perhaps you need to update Bundler by running `gem install bundler`?
Could not find gem 'bundler (~> 1.2)', which is required by gem 'rails (~>
5.2)', in any of the sources.
As a result I run gem install bundler '~> 1.2'.
Now when I run gem list bundler, I have those 2 versions 2.0.2, 1.17.3
I know want to bundle my gemfile with version 1.17.3
However when I run bundle _1.17.3_ install, I get :
Could not find command "_1.17.3_".
What am I doing wrong here ? How can I fix that ? Is there a way to specify directly in my rails project with which version of bundler it should download & resolve dependencies ?

Try gem install bundler -v 1.17.3 and then bundle _1.17.3_ install

Related

Ruby rails error: Bundler could not find compatible versions for gem "bundler":

Bundler could not find compatible versions for gem "bundler":
The error is below
Bundler could not find compatible versions for gem "bundler":
In Gemfile:
bundler (~> 2.2)
rails (= 6.1.4.6) was resolved to 6.1.4.6, which depends on
bundler (>= 2.2.0)
Current Bundler version:
bundler (2.1.4)
This Gemfile requires a different version of Bundler.
Perhaps you need to update Bundler by running `gem install bundler`?
Could not find gem 'bundler (~> 2.2)', which is required by gem 'rails (= 6.1.4.6)', in any of the relevant sources:
the local ruby installation
Your solution is actually in the error message that you are getting. Run
gem install bundler
to install the latest version of bundler (that should satisfy the constraints
You can also specify a particular version of any gem by specifying the version flag. For example.
gem install bundler -v 2.2.0
gem install bundler --version 2.2.19 --default

Bundler : Is there a way to set the version?

When trying to run 'bundle install', I have this message :
Bundler could not find compatible versions for gem "bundler":
In Gemfile:
rails (= 5.0.2) was resolved to 5.0.2, which depends on
bundler (>= 1.3.0, < 2.0)
Current Bundler version:
bundler (2.1.2)
This Gemfile requires a different version of Bundler.
Perhaps you need to update Bundler by running `gem install bundler`?
Could not find gem 'bundler (>= 1.3.0, < 2.0)', which is required by gem 'rails (= 5.0.2)', in any of the sources.
Bundler could not find compatible versions for gem "pg":
In Gemfile:
pg (= 0.18.3)
jsonb_accessor (~> 1.0.0) was resolved to 1.0.0, which depends on
pg (>= 0.18.1)
Then, I think I need to change my bundler version why is 2.1.2, I would like to change to 1.17.3.
gem list command says :
bundler (default 1.17.3)
but bundle -v command says :
Bundler version 2.1.2
I am using ruby 2.5.1 with RVM.
Do you have any idea how to do so ?
I read that I can use bundle config set but it does nothing.
Bundler installs a binary that gets invoked before your Gemfile is read, so you'll need to remove the version you are using and install the version you want.
You can do this with RVM with the following:
rvm #global do gem uninstall bundler -a -x -I || true
gem install bundler -v '= 1.17.3'
If you hop between projects, you may have to do this a lot, or you can do this:
gem install bundler -v '= 1.17.3'
And instead of using bundle install, use:
bundle _1.17.3_ install
to specify the version of the bundler gem gets used.
I would recommend you look into upgrading Rails, not only to get on a supported version (that has security updates), but it will also allow you to upgrade bundler again.
You need to delete manually the directory on your problematic ruby version: for example if there is a bundler problem with the 2.5.1 ruby version, go to this path:
/Users/YOUR_USER/.rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/
and delete the bundler directory.
If bundler is in the default specification you also need to remove the bundler associated file on this path:
/Users/YOUR_USER/.rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/specifications/default
Then you can re-install a specific version of bundler using #Unixmonkey answer

How to fix bundle version incompatibility?

https://github.com/jhu-ep-coursera/fullstack-course3-module3-movies
I use this repo , I run rake db:seed Project want sqlite update and I add gem 'sqlite3', '~> 1.3.13' in Gemfile .
Project gives an error
(base) ➜ fullstack-course3-module3-movies git:(master) ✗ bundle
The dependency tzinfo-data (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mingw32, x86-mswin32, x64-mingw32, java. To add those platforms to the bundle, run `bundle lock --add-platform x86-mingw32 x86-mswin32 x64-mingw32 java`.
Fetching gem metadata from https://rubygems.org/...........
Fetching gem metadata from https://rubygems.org/.
Resolving dependencies...
Bundler could not find compatible versions for gem "bundler":
In Gemfile:
rails (= 4.2.4) was resolved to 4.2.4, which depends on
bundler (< 2.0, >= 1.3.0)
Current Bundler version:
bundler (2.0.1)
This Gemfile requires a different version of Bundler.
Perhaps you need to update Bundler by running `gem install bundler`?
Could not find gem 'bundler (< 2.0, >= 1.3.0)', which is required by gem 'rails (= 4.2.4)', in any of the sources.
You got Bundler 2.0.1 installed on your computer, but apparently your Gemfile requires bundler (< 2.0, >= 1.3.0).
You can install the required bundler version like this:
gem install bundler --version=1.x.y

Can't downgrade bundler

I try to install a project I cloned. When I do 'bundle install' I have the following message:
$ bundle install
Bundler could not find compatible versions for gem "bundler":
In Gemfile:
rails (= 3.0.0) ruby depends on
bundler (~> 1.0.0) ruby
Current Bundler version:
bundler (1.6.2)
This Gemfile requires a different version of Bundler.
Perhaps you need to update Bundler by running `gem install bundler`?
So i did the following:
gem uninstall bundler
gem install bundler --version '1.0.0'
Successfully installed bundler-1.0.0
1 gem installed
I do 'bundle install', and I keep having the same message:
$ bundle install
Bundler could not find compatible versions for gem "bundler":
In Gemfile:
rails (= 3.0.0) ruby depends on
bundler (~> 1.0.0) ruby
Current Bundler version:
bundler (1.6.2)
This Gemfile requires a different version of Bundler.
Perhaps you need to update Bundler by running `gem install bundler`?
It seems that I cannot downgrade bundler to the '1.0.0' version, any idea?
If you do not need multiple versions of Bundler, you can uninstall the newer version:
$ gem uninstall bundler -v 1.6.2
You can also choose from a list of bundler versions if you have more than one:
$ gem uninstall bundler
You'll need to hit the global instance (alter installed ruby version as needed) --
$ gem uninstall -i /Users/<user>/.rvm/gems/ruby-2.3.8#global bundler

Problems with bundle (Rails)

I'm running Ruby 1.9.3 and Rails 4.0.0, and I'm just starting to learn how to use Ruby on Rails. Whenever I type the command to create a project:
rails new blog
I get this error when the bundle tries to execute the "bundle install" command:
Bundler could not find compatible versions for gem "bundler":
In Gemfile:
rails (= 4.0.0) ruby depends on
bundler (< 2.0, >= 1.3.0) ruby
Current Bundler version:
bundler (1.2.3)
This Gemfile requires a different version of Bundler.
Perhaps you need to update Bundler by running `gem install bundler`?
But with the command:
gem list bundle
returns:
bundler (1.3.5, 1.2.3)
And the command:
bundle -v
returns:
Bundler version 1.3.5
I don't know why that's happening, I appreciate any help, thanks.
Try removing the version in your Gemfile. Just keep
gem 'bundler'
Now run
bundle update
Try check Gemfile.lock for used bundler version.
You also can try to uninstall old version:
gem uninstall bundler --version 1.2.3
You can also specify the version of bundler you want to use
bundle _1.3.5_ install

Resources