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

rubygems does not select correct bundler version when BUNDLE_GEMFILE is set via .bundle/config #2991

Open
jtokoph opened this issue Nov 19, 2019 · 0 comments

Comments

@jtokoph
Copy link

@jtokoph jtokoph commented Nov 19, 2019

I'm having a problem.

My current problem is: the gem command does not factor in the BUNDLE_GEMFILE option being set in .bundle/config. It only checks for the environment variable of the same name.

When running the bundle command in an environment that has both v1 and v2 of bundler installed, rubygems will always use bundler v2 when the following conditions are true:

  1. The Gemfile is in a subdirectory or has an alternate name
  2. and the alternate location is specified in .bundle/config with BUNDLE_GEMFILE
  3. and bundle update is run from the project root directory

The bundle command should choose a version of bundler based on the BUNDLED WITH lines in the lockfile.

Note: This is working correctly if one of the following is true:

  • bundle update is run from the subdirectory that includes the Gemfile
  • or bundle update is run with BUNDLE_GEMFILE env var set to the alternate location

I think I've narrowed it down to this block of code here:
https://github.com/rubygems/rubygems/blame/ed6641c2f36268a89c6db150fca5768e225cf804/lib/rubygems/bundler_version_finder.rb#L83

I think it should look for a .bundle/config file with the BUNDLE_GEMFILE option, but am unsure of the best way to implement here.

Expected result

Running bundle in a project that was previously bundled with 1.x would not update BUNDLED_WITH to a different version

Observed result

BUNDLED WITH is updated to 2.x

Example repo to reproduce

A repository that demonstrates this behavior is located here: https://github.com/jtokoph/bundler2bug

The readme has steps to reproduce.

This issue is related to:

  • Network problems
  • Installing a library
  • Publishing a library
  • The command line gem
  • Other

Here are my current environment details:

$ gem env version
RubyGems Environment:
  - RUBYGEMS VERSION: 3.0.3
  - RUBY VERSION: 2.6.5 (2019-10-01 patchlevel 114) [x86_64-linux]
  - INSTALLATION DIRECTORY: /usr/local/bundle
  - USER INSTALLATION DIRECTORY: /root/.gem/ruby/2.6.0
  - RUBY EXECUTABLE: /usr/local/bin/ruby
  - GIT EXECUTABLE: /usr/bin/git
  - EXECUTABLE DIRECTORY: /usr/local/bundle/bin
  - SPEC CACHE DIRECTORY: /root/.gem/specs
  - SYSTEM CONFIGURATION DIRECTORY: /usr/local/etc
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-linux
  - GEM PATHS:
     - /usr/local/bundle
     - /root/.gem/ruby/2.6.0
     - /usr/local/lib/ruby/gems/2.6.0
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
     - "install" => "--no-document"
     - "update" => "--no-document"
  - REMOTE SOURCES:
     - https://rubygems.org/
  - SHELL PATH:
     - /usr/local/bundle/bin
     - /usr/local/sbin
     - /usr/local/bin
     - /usr/sbin
     - /usr/bin
     - /sbin
     - /bin

I will abide by the code of conduct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
2 participants
You can’t perform that action at this time.