Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Install default and bundled gems into dedicated directories
Previously, all default/bundled gems were installed into single location such as `/usr/local/lib/ruby/gems/3.3.0+0`. However, the same location is used for user installed gems, which is not optimal. With this change, the default gems goes into `/usr/local/lib/ruby/default_gems/3.3.0+0` while the bundled gems goes into `/usr/local/lib/ruby/bundled_gems/3.3.0+0`. User installed gems continues to land in `/usr/local/lib/ruby/gems/3.3.0+0`.
- Loading branch information
Showing
2 changed files
with
39 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
module Gem | ||
class << self | ||
|
||
def bundled_gems_dir | ||
File.join(RbConfig::CONFIG["rubylibprefix"], "bundled_gems", RbConfig::CONFIG["ruby_version"]) | ||
end | ||
|
||
def default_gems_dir | ||
File.join(RbConfig::CONFIG["rubylibprefix"], "default_gems", RbConfig::CONFIG["ruby_version"]) | ||
end | ||
|
||
undef :default_specifications_dir if method_defined? :default_specifications_dir | ||
|
||
if method_defined? :default_path | ||
alias orig_default_path default_path | ||
undef :default_path | ||
end | ||
|
||
## | ||
# Path to specification files of default gems. | ||
|
||
def default_specifications_dir | ||
@default_specifications_dir ||= File.join(Gem.default_gems_dir, "specifications", "default") | ||
end | ||
|
||
## | ||
# Default gem load path | ||
|
||
def default_path | ||
path = orig_default_path | ||
path << bundled_gems_dir | ||
path << default_gems_dir | ||
path | ||
end | ||
|
||
end | ||
end |
This file contains 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