Skip to content

Conversation

@felipec
Copy link

@felipec felipec commented Oct 22, 2020

Many (most) people don't install gems in the default directory, but in
the user's directory (--user-install), this can be configured by
distributions using /etc/gemrc.

However, that doesn't work for bundler, which has no global
configuration.

Many bugs have been opened about this mismatch, but there's no easy
clean solution, except this.

The environment variable GEM_USER_INSTALL overrides the installation
directory (home) so it is the same as the user's home directory, so
there's effectively only one directory (and --[no-]user-install has no
effect).

Distributions can set this variable on, and then finally 'gem install'
and 'bundle install' would use the same location without user
intervention.

Fixes issue #4027.

Signed-off-by: Felipe Contreras felipe.contreras@gmail.com

Many (most) people don't install gems in the default directory, but in
the user's directory (--user-install), this can be configured by
distributions using /etc/gemrc.

However, that doesn't work for bundler, which has no global
configuration.

Many bugs have been opened about this mismatch, but there's no easy
clean solution, except this.

The environment variable GEM_USER_INSTALL overrides the installation
directory (home) so it is the same as the user's home directory, so
there's effectively only one directory (and --[no-]user-install has no
effect).

Distributions can set this variable on, and then finally 'gem install'
and 'bundle install' would use the same location without user
intervention.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
@welcome
Copy link

welcome bot commented Oct 22, 2020

Thanks for opening a pull request and helping make RubyGems and Bundler better! Someone from the RubyGems team will take a look at your pull request shortly and leave any feedback. Please make sure that your pull request has tests for any changes or added functionality.

We use GitHub Actions to test and make sure your change works functionally and uses acceptable conventions, you can review the current progress of GitHub Actions in the PR status window below.

If you have any questions or concerns that you wish to ask, feel free to leave a comment in this PR or join our #rubygems or #bundler channel on Slack.

For more information about contributing to the RubyGems project feel free to review our CONTRIBUTING guide

@deivid-rodriguez
Copy link
Contributor

Thanks for your contribution @felipec. However, I don't like this solution. If you're willing to set an environment variable, why not setting GEM_HOME or GEM_PATH directly?

@felipec
Copy link
Author

felipec commented Oct 22, 2020

@deivid-rodriguez If I set GEM_USER_INSTALL, the gems will be installed to ~/.gem/ruby/2.7.0, if I set GEM_HOME to that, that will work until there's an update to the ruby version, or I change the engine, then my gems will be all mixed up.

There's a reason gems are installed to ~/.gem/$engine/$version by default.

@deivid-rodriguez
Copy link
Contributor

Right, sorry, BUNDLE_PATH would be the right way. If you set BUNDLE_PATH=~/.gem, I think it should be the same as --user-install in the rubygems side.

@felipec
Copy link
Author

felipec commented Oct 22, 2020

@deivid-rodriguez Yes, but I don't want to set two configurations. bundler should by default install to the same location as gem, with one configuration.

@deivid-rodriguez
Copy link
Contributor

Sure, you want a clean solution and I give you a workaround. I'd like to think a bit more about what the cleanest solution is.

@deivid-rodriguez
Copy link
Contributor

The environment variable approach has the advantage of being opt-in for the majority of users (those developing using version managers, like rbenv, rvm, chruby and so on), but with the possibility of being provided by default to OS ruby packages users (if OS packagers set it by default on their integrations).

This is something I didn't consider initially and I admit feels nice.

Pinging OS packagers @terceiro and @voxik since I'd also like to hear their opinions about this. I believe many OS package users don't use bundler at all, but still.

@felipec
Copy link
Author

felipec commented Oct 22, 2020

I believe many OS package users don't use bundler at all, but still.

They may not normally use bundler, but occasionally the may download the source code of a project that uses bundler.

@ruby ruby locked and limited conversation to collaborators Oct 23, 2020
@deivid-rodriguez
Copy link
Contributor

Let's have a fresh discussion about this at #4031.

@felipec felipec deleted the fc-install-fix branch May 21, 2021 04:24
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants