Share gems between Ruby minor versions#502
Open
leoarnold wants to merge 1 commit into
Open
Conversation
ASDF itself treats every install as a separate entity and does not have a concept of sharing data between installs. Luckily, Rubygems already provides such a concept through [`Gem.user_dir`](https://github.com/ruby/rubygems/blob/v4.0.12/lib/rubygems/defaults.rb#L103-L109) which holds a value like ```text /home/johndoe/.gem/4.0.0 ``` There are two features to note here: - Since ASDF will usually install everything into the user's home directory (i.e. `~/.asdf/`), we can do the same with the Ruby gems (by using `~/.gem`) without loss of generality. - While `RUBY_VERSION` changes with every Ruby release, the built-in value `RbConfig::CONFIG["ruby_version"]` stays the same for all versions of Ruby which are binary compatible. For example, all Ruby releases in the `3.4.X` series will have `3.4.0` as the value of `RbConfig::CONFIG["ruby_version"]`. So, in order to have communal gem homes for binary compatible releases of Ruby, all we need to do is to use `Gem.user_dir` as `GEM_HOME`. We set this value at runtime using `bin/exec-env` Fixes asdf-vm#119
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ASDF itself treats every install as a separate entity and does not have a concept of sharing data between installs.
Luckily, Rubygems already provides such a concept through
Gem.user_dirwhich holds a value likeThere are two features to note here:
~/.asdf/), we can do the same with the Ruby gems (by using~/.gem) without loss of generality.RUBY_VERSIONchanges with every Ruby release, the built-in valueRbConfig::CONFIG["ruby_version"]stays the same for all versions of Ruby which are binary compatible. For example, all Ruby releases in the3.4.Xseries will have3.4.0as the value ofRbConfig::CONFIG["ruby_version"].So, in order to have communal gem homes for binary compatible releases of Ruby, all we need to do is to use
Gem.user_dirasGEM_HOME. We set this value at runtime usingbin/exec-envFixes #119