Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use Bundler 2.0 on MRI 2.6.0? #3346

Closed
eregon opened this issue Jan 16, 2019 · 11 comments
Closed

How to use Bundler 2.0 on MRI 2.6.0? #3346

eregon opened this issue Jan 16, 2019 · 11 comments

Comments

@eregon
Copy link
Contributor

eregon commented Jan 16, 2019

I can install the gem with gem install bundler, but it's not used:

$ gem list

*** LOCAL GEMS ***

bigdecimal (default: 1.4.1)
bundler (2.0.1, default: 1.17.3)
...

$ bundle --version
Bundler version 1.17.3

$ bundle _2.0.1_ --version
Traceback (most recent call last):
	2: from /home/eregon/.gem/ruby/2.6.0/bin/bundle:23:in `<main>'
	1: from /home/eregon/.rubies/ruby-2.6.0/lib/ruby/site_ruby/2.6.0/rubygems.rb:302:in `activate_bin_path'
/home/eregon/.rubies/ruby-2.6.0/lib/ruby/site_ruby/2.6.0/rubygems.rb:283:in `find_spec_for_exe': Could not find 'bundler' (1.16.1) required by your /home/eregon/code/mspec/Gemfile.lock. (Gem::GemNotFoundException)
To update to the latest version installed on your system, run `bundle update --bundler`.
To install the missing version, run `gem install bundler:1.16.1`

And running that (or bundle _2.0.1_ update --bundler) doesn't change the Gemfile.lock.

I also tried to update RubyGems with gem update --system, but that doesn't help either.

@deivid-rodriguez
Copy link
Member

We definitely need to better communicate this, but it sounds like your lock file is locked to bundler 1.16.1 (BUNDLED WITH 1.16.1). You have 2 options: either upgrade your lock file to the bundler version you are using (bundle update --bundler), or use the bundler version you're locked to (gem install bundler:1.16.1).

@deivid-rodriguez
Copy link
Member

The fact that bundle update --bundler does not update your lock file seems like a bug, also reported here. I'm planning to investigate this in the future.

@eregon
Copy link
Contributor Author

eregon commented Jan 16, 2019

It's quite confusing imho, I would expect bundler to be "a gem" and so when I install version 2.0.1, the latest version is used like for other gems.
Compatibility would then be achieved by having code in Bundler 2.0 that cares about that, rather than relying on a bundler 1.x gem being installed, and having RubyGems or Bundler magically choose a different version based on the Gemfile.lock in the current directory.
This also means releases of 1.x would be less needed, but right now 1.x has to be maintained because 2.x cannot run 1.x Gemfile.lock, right?

@eregon
Copy link
Contributor Author

eregon commented Jan 16, 2019

This blog post explains the behavior, but I still find it surprising. Running bundle --version in a directory without a Gemfile.lock, I can indeed see Bundler version 2.0.1.

@colby-swandale What's the plan to drop 1.8.7 support, but still support existing Gemfile.lock files which will keep existing for a while?
Should Bundler 2 support these existing Gemfile.lock files, and not support Ruby 1.8.7? That would make sense to me, and then Bundler 1.x could be truly deprecated.

@hsbt hsbt self-assigned this Jan 21, 2019
@alexshapalov
Copy link

I have the same issue and I changed my ruby version from 2.6.1 to 2.5.3. Only this helped. before that, I tried everything.

@eregon
Copy link
Contributor Author

eregon commented Apr 13, 2019

@colby-swandale @deivid-rodriguez @hsbt I'd like to have your opinion on this issue, regarding my latest comment. What's the plan to drop 1.8.7 in Bundler 2.x but still support 1.x Gemfiles? Is it hard to support 1.x Gemfiles with Bundler 2? I would expect it's not, and that would allow to really deprecate Bundler 1.x.

@hsbt
Copy link
Member

hsbt commented Apr 13, 2019

@SashkaSh Try to use Ruby 2.6.2. I fixed some of the issues related to this.

@eregon I'm not sure what your concerns. But Bundler 2 still support 1.x Gemiles and drop to support Ruby 1.8 and 1.9 now.

@deivid-rodriguez
Copy link
Member

@eregon I think this is precisely what we are addressing in rubygems/bundler#6996 and #2696. I'm working on both right now.

@eregon
Copy link
Contributor Author

eregon commented Apr 14, 2019

@hsbt

@eregon I'm not sure what your concerns. But Bundler 2 still support 1.x Gemiles and drop to support Ruby 1.8 and 1.9 now.

AFAIK, RubyGems magically switches to use Bundler 1 in that case. I find that behavior very confusing.

Bundler 2 does not work at all if there is a Gemfile.lock with BUNDLED WITH 1.16.4:

$ chruby 2.6.2
$ gem install bundler
$ bundle version
Bundler version 1.17.2 (2018-12-19 commit 3fc4de72b)
$ bundle _2.0.1_ version
Traceback (most recent call last):
	2: from /home/eregon/.rubies/ruby-2.6.2/bin/bundle:23:in `<main>'
	1: from /home/eregon/.rubies/ruby-2.6.2/lib/ruby/2.6.0/rubygems.rb:302:in `activate_bin_path'
/home/eregon/.rubies/ruby-2.6.2/lib/ruby/2.6.0/rubygems.rb:283:in `find_spec_for_exe': Could not find 'bundler' (1.16.4) required by your /home/eregon/tmp/Gemfile.lock. (Gem::GemNotFoundException)
To update to the latest version installed on your system, run `bundle update --bundler`.
To install the missing version, run `gem install bundler:1.16.4`

@hsbt
Copy link
Member

hsbt commented Apr 15, 2019

@eregon It's intentional behavior. You need to run bundle update --bundler for using Bundler 2 includes 2.0 and 2.1.

ghost referenced this issue Jan 13, 2020
3073: Remove the bundler version selector r=bronzdoc a=deivid-rodriguez

# Description:

I do like the idea of bundler being able to lock its own version, but this implementation is not the right way to do it in my opinion.

I aim to reimplement this inside bundler in the near future, but it needs to be done in a more user friendly way that properly informs the user about what's going on, and never raises when not necessary.

But for now I think we should remove this code from rubygems because this is causing more problems than benefits and it's being counterproductive.

Closes #2671.
Closes #3044.
Closes rubygems/bundler#6913.
Closes rubygems/bundler#7031.
Closes rubygems/bundler#7489.
Closes rubygems/bundler#7517.
Closes rubygems/bundler#7538.
Closes rubygems/bundler#7564.

# Tasks:

- [x] Describe the problem / feature
- [ ] Write tests
- [x] Write code to solve the problem
- [ ] Get code review from coworkers / friends

I will abide by the [code of conduct](https://github.com/rubygems/rubygems/blob/master/CODE_OF_CONDUCT.md).


Co-authored-by: David Rodríguez <deivid.rodriguez@riseup.net>
@hsbt hsbt transferred this issue from rubygems/bundler Mar 14, 2020
@deivid-rodriguez
Copy link
Member

This is related to the ongoing discussion about the version switcher, so I'll close this ticket in favor of those.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants