-
-
Notifications
You must be signed in to change notification settings - Fork 192
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
Use RUBY_ENGINE_VERSION to decide the GEM_HOME #410
Conversation
share/chruby/chruby.sh
Outdated
@@ -46,13 +46,14 @@ function chruby_use() | |||
eval "$(RUBYGEMS_GEMDEPS="" "$RUBY_ROOT/bin/ruby" - <<EOF | |||
puts "export RUBY_ENGINE=#{Object.const_defined?(:RUBY_ENGINE) ? RUBY_ENGINE : 'ruby'};" | |||
puts "export RUBY_VERSION=#{RUBY_VERSION};" | |||
puts "export RUBY_ENGINE_VERSION=#{defined?(RUBY_ENGINE_VERSION) ? RUBY_ENGINE_VERSION : RUBY_VERSION};" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think defined?(RUBY_ENGINE_VERSION)
here should be Object.const_defined?(:RUBY_ENGINE_VERSION)
, since mruby doesn't implement the defined?
keyword.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, fixed.
I wonder if we even need to check that RUBY_ENGINE_VERSION
is defined, it's been there for a long time, but probably better safe than sorry.
I tried with MRuby 1.4.0 and 2.0.0, and it works except chruby mruby
shows:
trace (most recent call last):
[0] -:4
-:4: uninitialized constant LoadError (NameError)
(which is the same on master
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was glad you checked, since RUBY_ENGINE_VERSION
was added to CRuby in 2.3.0.
* Such that each installed Ruby has its own GEM_HOME, even if RUBY_VERSION remains the same for multiple releases of a non-MRI Ruby implementation. * This is particularly important for TruffleRuby, where different releases with the same RUBY_VERSION might compile C extensions differently, and each release should have a different GEM_HOME.
5dfbf52
to
d38fc77
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JRuby sets --env-shebang
by default and it rarely makes API changes without a RUBY_VERSION
bump, so it currently effectively shares gems between RUBY_ENGINE_VERSION
s of the same RUBY_VERSION
. This change would mean that most JRuby versions would no longer share gems. On the other hand, the new behavior is consistent between engines, in that none would share gems between versions.
In the future, we could consider more broadly supporting sharing gems between versions of the same ABI if RubyGems adopts a default --env-shebang
.
I think this is also safer for JRuby. JRuby doesn't have C extensions but it has JRuby extensions which access JRuby internals that could change between JRuby releases with the same Pure-ruby gems could be shared arbitrarily between all installed Rubies, I think that would be a way to share many gems safely if desired. |
I like this feature as it returns chruby to it's original behavior back when the patch-level was included in the version string. However, changing |
@postmodern Good to hear 😃 I think
Do you mean an entry in the changelog, and/or something else? |
Definitely a ChangeLog entry and maybe a note in the README. |
@postmodern I added a ChangeLog entry and updated the document paths for |
@postmodern Does the PR look good now? Could you merge it? |
@postmodern @havenwood This is becoming a real problem for TruffleRuby users, so I would like to merge this or use I think chruby (and Ruby managers in general, and Bundler, and RubyGems) should use either:
For A third way would be to just use RubyGems'
Or maybe we should really solve this in RubyGems by defaulting to the user directory first, but I think that is going to be a long battle. |
I'd love to use I think this PR is the best path for now. |
We could also try to go the JRuby route with CRuby and TruffleRuby and enable --env-shebang upstream. It makes sense to me to make the change in RubyGems, but it unfortunately didn't make the RubyGem 3.0 release so it'll likely have to wait until 4.0 on the RubyGems side. |
I gave this more thought over the weekend, and actually I think the best way would be use the directory name used by chruby for the user gem home. For instance, That way, even if I have @havenwood @postmodern Would you be OK with that? I'll make a PR soon with that idea. |
@eregon using the ruby install directory name for the gem home directory name is an interesting idea. This might also require compiling rubies with different installation directories (ex: I would also like to point out that RubyGems now stores the C extension library files in sub-directories based on the host architecture, Ruby ABI version, and static vs
This does now allow rubygems to keep C extensions for different Ruby ABI versions or configurations separate. The only remaining issue are the absolute env-shebang which will explicitly load the ruby which was used to install the gem last. |
@postmodern Very interesting, I did not know RubyGems uses different directories per ABI version. FWIW, here is the current bug:
Because both use the same compiled extension:
Here is what happens when using latest master, which sets
So it does list msgpack in |
@postmodern @havenwood I've been playing with a radical idea: not setting any It's really awesome for developing TruffleRuby, because in that case I like to have MRI chosen with And of course, the diff is pretty nice and makes Now, the open issues with that approach:
What do you think? |
@eregon just so I'm totally crystal clear, what exactly is causing that Not setting We could derive I also feel the need to point out chruby explicitly forbids Ruby-specific workarounds. Any solution we come up with has to work with all (current/stable) Rubies out-of-the-box and all possible setups (such as non-user-writable rubies in |
They have the same
Right, that's issue 1 above, and I think the most problematic. It works fine for me, because I never install a ruby version globally, but there are other use cases that Passing In summary, it's sad that RubyGems defaults are not convenient and even tend to force using
Which is issue 3 above, indeed.
That sounds very exotic, already just by having 2 MRIs of the same This stricter gem separation is what both RVM and rbenv do (RVM by setting
That would be fine too, except that one would also needs to care about And of course, env-shebang still blocks this (and forever will by the the rule below).
Right. The line is a bit blurry to me though because, e.g., I am sorry for this very long thread. I think I got a pretty full understanding of the situation now. |
If the problem is fixed upstream, I always advocate for releasing a new version, encouraging users to upgrade, and moving forward.
This definitely can seem confusing since the user may not know the gem dir is reused, and may require
I have advocated for this in the past, but to no avail. Imo, it makes sense that if someone runs
While I am pro-upgrading and moving forward, unfortunately it would require a lot of work (PR and proving it would not break backwards compatibility) for RubyGems to consider accepting the feature.
I already pointed out that RubyGems uses different directories for shared vs static built extensions. Extensions built against Rubies without
Again, this doesn't seem to be an issue. Unless you are using a much older version of RubyGems prior to the
Technically true, although all Rubies supported
It is looking like this is the consensus. However, there are two downsides that we must recognize. If each Ruby gets it's own separate gem home...
I understand your desire to fix this for TruffleRuby users, but we must consider the negative impact on other users. How do we mitigate these negative impacts? Possibly a separate script for managing gem installation directories? Thoughts? |
Of course, we should have 19.2.0 soon with that fix.
Did you discuss this on the RubyGems tracker or so? That idea sounds great to me, I'd be curious why some people disagree.
Yes I know, I meant even though RubyGems doesn't mix them up, it causes
Doesn't RubyGems have a command to export a list of installed gems, that can be easily imported with RubyGems again?
By patch-release version, I assume you mean Z in X.Y.Z (not the old This is already the case, every installation of MRI already uses its own gem directory, so at least it's not any worse than before for MRI, and it's correct for other implementations. |
Closing this PR in favor of #419 |
GEM_HOME
, even ifRUBY_VERSION
remains the same for multiple releases of a non-MRI Ruby implementation.RUBY_VERSION
might compile C extensions differently, and each release should have a differentGEM_HOME
.cc @postmodern @havenwood