-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Make --user-install as default
#2847
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
Conversation
|
❓ I'm wondering what has changed your opinion @hsbt. I think you were against this in the initial discussion (#1394 (comment)). |
|
@simi Yes, But I prefer this idea after thinking with XDG compliance: ruby/ruby#2174 |
|
I am 100% in favor of this change. Are there any known complications with it? |
|
Re complications, maybe edge cases where one has more than one platform of the same Ruby major/minor version installed. For instance, I normally work with MinGW builds, and have quite a few gems installed via |
|
While working on some CI issues, this came to mind. Re Windows, I don't think AppVeyor or Actions have the user bin folder in ENV['PATH']. Don't know about Ubuntu and macOS on Travis and Actions. I suspect Actions does not. It could be added, but otherwise... |
|
I'm not sure this is a good idea, it can be less reliable and cause confusing errors if multiple Ruby versions are installed. If This change is also almost guaranteed to break many usages of Ruby which don't add |
Since --user-install was enabled by default in gem[1], we need to set --no-user-install to make "gem install" refer GEM_HOME. Closes-Bug: #1866176 [1] ruby/rubygems#2847 Change-Id: Id640ec2cb1012e99826cb990fb4995945183521d
* Update puppet-openstack-integration from branch 'master'
- Merge "Set --no-user-install in gem install"
- Set --no-user-install in gem install
Since --user-install was enabled by default in gem[1], we need to set
--no-user-install to make "gem install" refer GEM_HOME.
Closes-Bug: #1866176
[1] ruby/rubygems#2847
Change-Id: Id640ec2cb1012e99826cb990fb4995945183521d
Since --user-install was enabled by default in gem[1], we need to set --no-user-install to make "gem install" refer GEM_HOME. Closes-Bug: #1866176 [1] ruby/rubygems#2847 Change-Id: Id640ec2cb1012e99826cb990fb4995945183521d (cherry picked from commit 3b266e9)
Since --user-install was enabled by default in gem[1], we need to set --no-user-install to make "gem install" refer GEM_HOME. Closes-Bug: #1866176 [1] ruby/rubygems#2847 Change-Id: Id640ec2cb1012e99826cb990fb4995945183521d (cherry picked from commit 3b266e9)
Since --user-install was enabled by default in gem[1], we need to set --no-user-install to make "gem install" refer GEM_HOME. Closes-Bug: #1866176 [1] ruby/rubygems#2847 Change-Id: Id640ec2cb1012e99826cb990fb4995945183521d (cherry picked from commit 3b266e9) (cherry picked from commit f9050dc)
Since --user-install was enabled by default in gem[1], we need to set --no-user-install to make "gem install" refer GEM_HOME. Closes-Bug: #1866176 [1] ruby/rubygems#2847 Change-Id: Id640ec2cb1012e99826cb990fb4995945183521d (cherry picked from commit 3b266e9)
|
eregon - you need to remember the other trade-off too, in particular on HaikuOS with the I completely disagree with your claim of "difficult segfaults" being a showstopper to this I am not at all having a problem with more customization-possibilities, but at the same |
|
Based on the feedback from other folks above, I took a look into how Python, and Haiku, handles things.
@eregon Python handles this by printing a message like the following:
Do you consider something like that a reasonable compromise? @rubyFeedback pip, the package manager for Python, does not default to Details for @rubyFeedbackSpecifically, I think Haiku may want to use the OS-specific See |
|
@rubyFeedback Fedora's |
I think that warning would be useful to have. I still think there is nothing safer than installing gems under the Ruby prefix, if it's writable. FWIW, chruby will actually set GEM_HOME/GEM_PATH if the Ruby prefix is not writable, but otherwise just write to the Ruby prefix, in part to avoid these potential incompatibilities: |
|
For other Ruby managers: Adapting |
|
@eregon I agree that we need to be careful to avoid the problems you mentioned (sorry, just realized I hadn't actually said that earlier, just thought it). However, revisiting this, I have to wonder: why do 2.6.0, 2.6.1, 2.6.2, 2.6.3, 2.6.4 and 2.6.5 all use As far as I know it would be unique for each Ruby implementation+version combination, and JRuby already appears to do this without issue — I have This would, in theory, resolve the problem @eregon raised and allow using Regarding @MSP-Greg's remarks about CI: as long as this is implemented in terms of making (We could also coordinate with the folks who maintain various CI systems or common base containers in an attempt to mitigate those negative effects of this change, but I think that's a separate discussion for after we decide if and how this change would be done.) |
|
@duckinator Currently it's like My experience as a Ruby implementor and contributor to all 3 major Ruby managers is: it's a bad idea to share gems (at least for gems with native extensions). My recommendation is if you want to install gems as a user, then install Ruby as a user too, which is what most Rubyists do already. If you want for some reason to have Ruby installed in system directories, then you have to choose: do you want to share gems too between multiple users (then you need |
|
Anyway, if we somehow change the default in RubyGems, we should only not use the default Gem home if it's not writable. If it's writable, we should use the default gem home, because it's safe, convenient, guaranteed to be in PATH, etc. |
With my Fedora/RHEL maintainer hat, I disagree with this. If people are using Ruby distributed with OS, the |
|
I don't have strong feelings about this, as long whatever the default can be changed. The one question I have is what will Bundler do? At present, with no path changes, I believe it always installs to |
Yes, I 100% agree with this. I think what I'm asking boils down to this:
Any questions I asked about how to do so can wait until after we determine if it's helpful. 🙂 |
|
I work with a lot of repos with both Windows and CI issues. Because of that, I have a lot of installed Rubies for local testing, and I also swap patch versions when needed. Because of that, almost all my gems are installed in The vast majority of my work is with MRI Ruby. I suspect @eregon is often working with non MRI Rubies.
Personally, I would like RUBY_PLATFORM as part of the path, as mswin & mingw Ruby builds don't work with each other's gems. But, as to build arguments, that's tricky, maybe a hash or something? Same issue with 32 bit and 64 bit Windows Rubies, but that's less common than in the past (few people use 32 bit). At some point, |
|
@duckinator If There is still the concern that My experience with shared gems issues is mostly with MRI and native extensions. |
I think that is the more common case, and a lot of things will break. I'm glad I'm not involved with jekyll... I assume you mean the 'bin directory for --user-install gems'... |
|
Thinking again about this I'm convinced "automatically use --user-install if the default gems directory is not writable" is the only reasonable solution:
I think the next step is to create a PR with this approach. I don't think I will have time soon. |
|
Just adding my thoughts to the discussion, since @eregon and myself have been discussing how to set (or not set)
|
|
In order,
BTW, it seems RubyGems already warns for That's nice, one step is already done. Although it's a bit buried in the output. |
|
Correct me if I am wrong, but doesn't $ GEM_HOME="$PWD/test_gems" gem install --verbose rake ... /home/postmodern/.gem/ruby/gems/rake-13.0.1/.github/workflows/macos.yml /home/postmodern/.gem/ruby/gems/rake-13.0.1/.github/workflows/ubuntu-rvm.yml /home/postmodern/.gem/ruby/gems/rake-13.0.1/.github/workflows/ubuntu.yml /home/postmodern/.gem/ruby/gems/rake-13.0.1/.github/workflows/windows.yml I'd assume making
I'm interested in hearing everyone's thoughts. |
@eregon If I'm understanding correctly, then yeah I think something like this is probably the solution.
@postmodern My understanding is that @eregon's idea can be summarized with the following pseudocode: if !File.writable?(gem_home)
default_args += ' --user-home'
endWhich is different than what is done in this PR in that if you don't pass |
997bfd6 to
c90fcf8
Compare
|
#2847 (comment) is the good start point for us. I update the this pull-request with it. |
|
The PR looks good to me now. About @postmodern Could you test that holds? |
|
@hsbt Could you add some tests for this PR to make sure it works as intended and keeps working? |
|
Yes, I try to do that. But I was suprised the current |
|
I'm also fine with the proposed solution. Only addition I'd like to propose is to show a warning when this fallback happens, in case the user actually expects to install to the system location and has a permissions issue which she wants to fix. Maybe something like:
Thoughts? |
|
That sounds good, I would just swap both suggestions, as fixing permissions (if possible) is a better fix (for |
|
Bundler ignores This does it: --- a/lib/rubygems/path_support.rb
+++ b/lib/rubygems/path_support.rb
@@ -23,7 +23,7 @@ class Gem::PathSupport
# hashtable, or defaults to ENV, the system environment.
#
def initialize(env)
- @home = env["GEM_HOME"] || Gem.default_dir
+ @home = env["GEM_HOME"] || Gem.user_dir
if File::ALT_SEPARATOR
@home = @home.gsub(File::ALT_SEPARATOR, File::SEPARATOR)However |
|
@felipec My understanding is this is only about running What do you mean Bundler ignores |
|
Just to get clarification, is |
It's not a typically situation, but I have issues with Does I don't know, I'm only Windows, but that will change soon... |
|
Closing in favor of #5327. |
Description:
Fixes #1394
Tasks:
I will abide by the code of conduct.