Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

bundle path confusing behavior #6619

Closed
pegasd opened this issue Jul 6, 2018 · 15 comments · Fixed by #6628
Closed

bundle path confusing behavior #6619

pegasd opened this issue Jul 6, 2018 · 15 comments · Fixed by #6628

Comments

@pegasd
Copy link

pegasd commented Jul 6, 2018

Environment:

macOS High Sierra
bundler 1.16.2
Ruby 2.4.4 (through RVM)

Steps to reproduce:

  • Simple Gemfile for testing:
 % cat Gemfile
source 'https://rubygems.org'
gem 'rake'
  • No local or global bundle configuration files (to begin with)
 % bundle config
Settings are listed in order of priority. The top value will be used.

Behavior 1

Attempt to set path using global config

 % bundle config path ~/.bundle
 % bundle config
Settings are listed in order of priority. The top value will be used.
path
Set for the current user (/Users/pegas/.bundle/config): "/Users/pegas/.bundle"

Expected location of installed gems: ~/.bundle
Actual location of installed gems: ~/.rvm/gems (this is the "system" gem location)

 % bundle show rake
/Users/pegas/.rvm/gems/ruby-2.4.4/gems/rake-12.3.1

Behavior 2

Attempt to disable system path

 % bundle config path.system false
 % bundle config
Settings are listed in order of priority. The top value will be used.
path
Set for the current user (/Users/pegas/.bundle/config): "/Users/pegas/.bundle"

path.system
Set for the current user (/Users/pegas/.bundle/config): false

Expected location of installed gems: ~/.bundle
Actual location of installed gems: ~/.bundle (non Ruby-version dependent)

 % bundle show rake
/Users/pegas/.bundle/gems/rake-12.3.1

Behavior 3

Attempt to set path locally

 % bundle config --local path ~/.bundle
 % bundle config
Settings are listed in order of priority. The top value will be used.
path
Set for your local app (/Users/pegas/test/.bundle/config): "/Users/pegas/.bundle"

Expected location of installed gems: ~/.bundle
Actual location of installed gems: ~/.bundle (Ruby-version dependent)

 % bundle show rake
/Users/pegas/.bundle/ruby/2.4.0/gems/rake-12.3.1

Questions, thoughts

  • What is the proper workflow for this use case? The only logical gem location (from my POV) results from storing local .bundle/config files all over my apps (behavior 3), which does not seem very user-friendly. How do I make a global configuration that behaves like this?
  • Why is behavior 1 not doing the same as behavior 3?
  • If behavior 2 works (almost well), why are path and path.system considered mutually exclusive?
 % bundle config path ~/.bundle/gems
You are replacing the current global value of path, which is currently "/Users/pegas/.bundle"
Setting `path.system` to nil, since path and path.system are mutually exclusive
@segiddins
Copy link
Member

Does his happen for gems that are not default gems ? (Rake is a default gem, installed with ruby)

@pegasd
Copy link
Author

pegasd commented Jul 6, 2018

@segiddins Yes, this happens for all gems - rake was simply an easy example.
I can also reproduce this on an Ubuntu box with the exact same results.

@pegasd
Copy link
Author

pegasd commented Jul 8, 2018

@segiddins Also note the version of rake. Ruby 2.4.4 comes bundled with 12.0.0, whereas in all of the examples the installed version is 12.3.1.

@segiddins
Copy link
Member

I'm unable to reproduce this:

$ bundle config path ~/.tmp-bundle
$ bundle install
$ bundle info rake
  * rake (12.3.1)
	Summary: Rake is a Make-like program implemented in Ruby
	Homepage: https://github.com/ruby/rake
	Path: /Users/segiddins/.tmp-bundle/gems/rake-12.3.1

@pegasd
Copy link
Author

pegasd commented Jul 11, 2018

@segiddins could you please share your full bundle config and environment info?

@pegasd
Copy link
Author

pegasd commented Jul 11, 2018

@segiddins Also, can you please check if the current location of rake gem will be used after you do

$ bundle config --local path ~/.tmp-bundle
$ bundle up

?

@segiddins
Copy link
Member

$ bundle config --local path ~/.tmp-bundle
$ bundle up
$ bundle info rake
  * rake (12.3.1)
	Summary: Rake is a Make-like program implemented in Ruby
	Homepage: https://github.com/ruby/rake
	Path: /Users/segiddins/.tmp-bundle/ruby/2.5.0/gems/rake-12.3.1

@segiddins
Copy link
Member

Environment

Bundler       1.16.2
  Platforms   ruby, x86_64-darwin-16
Ruby          2.5.0p0 (2017-12-25 revision 61468) [x86_64-darwin16]
  Full Path   /Users/segiddins/.rubies/2.5.0/bin/ruby
  Config Dir  /Users/segiddins/.rubies/2.5.0/etc
RubyGems      2.7.7
  Gem Home    /Users/segiddins/.gem/ruby/2.5.0
  Gem Path    /Users/segiddins/.gem/ruby/2.5.0:/Users/segiddins/.rubies/2.5.0/lib/ruby/gems/2.5.0
  User Path   /Users/segiddins/.gem/ruby/2.5.0
  Bin Dir     /Users/segiddins/.gem/ruby/2.5.0/bin
Tools
  Git         2.17.0
  RVM         not installed
  rbenv       not installed
  chruby      0.3.9

Bundler Build Metadata

Built At          2018-07-17
Git SHA
Released Version  false

Bundler settings

gem.test
  Set for the current user (/Users/segiddins/.bundle/config): "rspec"
gem.coc
  Set for the current user (/Users/segiddins/.bundle/config): true
plugins
  Set for the current user (/Users/segiddins/.bundle/config): false
allow_offline_install
  Set for the current user (/Users/segiddins/.bundle/config): true
global_gem_cache
  Set for the current user (/Users/segiddins/.bundle/config): true
major_deprecations
  Set for the current user (/Users/segiddins/.bundle/config): true
gem.mit
  Set for the current user (/Users/segiddins/.bundle/config): true
gem.rubocop
  Set for the current user (/Users/segiddins/.bundle/config): "true"
path
  Set for your local app (/Users/segiddins/Desktop/GemfileTest/.bundle/config): "/Users/segiddins/.tmp-bundle"
  Set for the current user (/Users/segiddins/.bundle/config): "/Users/segiddins/.tmp-bundle"

Gemfile

Gemfile

source 'https://rubygems.org'
gem 'rake'

Gemfile.lock

GEM
  remote: https://rubygems.org/
  specs:
    rake (12.3.1)

PLATFORMS
  ruby

DEPENDENCIES
  rake

BUNDLED WITH
   1.16.2

@pegasd
Copy link
Author

pegasd commented Jul 17, 2018

So the installation path differs for you as well. Local and global setting result in different gem installations (just like I described in 1 and 3).

@segiddins
Copy link
Member

Yes, that's "intended" that local & global settings for bundle path are interpreted differently

@indirect
Copy link
Member

did we finally fix that under a 2.0 feature flag? it's definitely on my list of "ugh god we should finally fix that in 2.0"

@segiddins
Copy link
Member

@indirect I don't think so, mostly since I'm not even sure which way 'fixing' it would be :P

@indirect
Copy link
Member

@segiddins we have definitely concluded in the past that fixing it means making all install paths include the ABI version. It's too weird to set a global path and then break all your gems every time you switch rubies.

bundlerbot added a commit that referenced this issue Jul 17, 2018
…ope, r=indirect

[Settings] Append the ruby scope on Bundler 2 with a global path setting

### What was the end-user problem that led to this PR?

The problem was `bundle config path` behaving differently depending on whether the config is local or global was... confusing.

Closes #6619 (comment).

### What was your diagnosis of the problem?

My diagnosis was setting the `path` setting should be consistent, regardless of the level of configuration it is set at.

### What is your fix for the problem, implemented in this PR?

My fix appends the "ruby scope" to the path when set globally on Bundler 2.

### Why did you choose this fix out of the possible options?

I chose this fix because it means users won't have to re-install gems when switching rubies with a global `BUNDLE_PATH` set.
@pegasd
Copy link
Author

pegasd commented Jul 27, 2018

Pardon my ignorance, but is there an approximate release date set for 2.0?

@segiddins
Copy link
Member

@pegasd not yet

bundlerbot added a commit that referenced this issue Jul 31, 2018
…ope, r=colby-swandale

[Settings] Append the ruby scope on Bundler 2 with a global path setting

### What was the end-user problem that led to this PR?

The problem was `bundle config path` behaving differently depending on whether the config is local or global was... confusing.

Closes #6619 (comment).

### What was your diagnosis of the problem?

My diagnosis was setting the `path` setting should be consistent, regardless of the level of configuration it is set at.

### What is your fix for the problem, implemented in this PR?

My fix appends the "ruby scope" to the path when set globally on Bundler 2.

### Why did you choose this fix out of the possible options?

I chose this fix because it means users won't have to re-install gems when switching rubies with a global `BUNDLE_PATH` set.
colby-swandale pushed a commit that referenced this issue Sep 21, 2018
…ope, r=colby-swandale

[Settings] Append the ruby scope on Bundler 2 with a global path setting

### What was the end-user problem that led to this PR?

The problem was `bundle config path` behaving differently depending on whether the config is local or global was... confusing.

Closes #6619 (comment).

### What was your diagnosis of the problem?

My diagnosis was setting the `path` setting should be consistent, regardless of the level of configuration it is set at.

### What is your fix for the problem, implemented in this PR?

My fix appends the "ruby scope" to the path when set globally on Bundler 2.

### Why did you choose this fix out of the possible options?

I chose this fix because it means users won't have to re-install gems when switching rubies with a global `BUNDLE_PATH` set.

(cherry picked from commit 0fc64a6)
colby-swandale pushed a commit that referenced this issue Sep 22, 2018
…ope, r=colby-swandale

[Settings] Append the ruby scope on Bundler 2 with a global path setting

### What was the end-user problem that led to this PR?

The problem was `bundle config path` behaving differently depending on whether the config is local or global was... confusing.

Closes #6619 (comment).

### What was your diagnosis of the problem?

My diagnosis was setting the `path` setting should be consistent, regardless of the level of configuration it is set at.

### What is your fix for the problem, implemented in this PR?

My fix appends the "ruby scope" to the path when set globally on Bundler 2.

### Why did you choose this fix out of the possible options?

I chose this fix because it means users won't have to re-install gems when switching rubies with a global `BUNDLE_PATH` set.

(cherry picked from commit 0fc64a6)
colby-swandale pushed a commit that referenced this issue Oct 5, 2018
…ope, r=colby-swandale

[Settings] Append the ruby scope on Bundler 2 with a global path setting

### What was the end-user problem that led to this PR?

The problem was `bundle config path` behaving differently depending on whether the config is local or global was... confusing.

Closes #6619 (comment).

### What was your diagnosis of the problem?

My diagnosis was setting the `path` setting should be consistent, regardless of the level of configuration it is set at.

### What is your fix for the problem, implemented in this PR?

My fix appends the "ruby scope" to the path when set globally on Bundler 2.

### Why did you choose this fix out of the possible options?

I chose this fix because it means users won't have to re-install gems when switching rubies with a global `BUNDLE_PATH` set.

(cherry picked from commit 0fc64a6)
hsbt pushed a commit to rubygems/bundler-graph that referenced this issue Oct 19, 2021
…ope, r=colby-swandale

[Settings] Append the ruby scope on Bundler 2 with a global path setting

### What was the end-user problem that led to this PR?

The problem was `bundle config path` behaving differently depending on whether the config is local or global was... confusing.

Closes rubygems/bundler#6619 (comment).

### What was your diagnosis of the problem?

My diagnosis was setting the `path` setting should be consistent, regardless of the level of configuration it is set at.

### What is your fix for the problem, implemented in this PR?

My fix appends the "ruby scope" to the path when set globally on Bundler 2.

### Why did you choose this fix out of the possible options?

I chose this fix because it means users won't have to re-install gems when switching rubies with a global `BUNDLE_PATH` set.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants