Skip to content
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

RubyGems mutates RbConfig and sets it to incorrect values #5371

Closed
eregon opened this issue Feb 21, 2022 · 2 comments · Fixed by #5626
Closed

RubyGems mutates RbConfig and sets it to incorrect values #5371

eregon opened this issue Feb 21, 2022 · 2 comments · Fixed by #5626
Labels

Comments

@eregon
Copy link
Contributor

eregon commented Feb 21, 2022

RubyGems mutates RbConfig sitearchdir and sitelibdir when building a C extension gem.

RbConfig should never be mutated, as it can lead to various issues.
One of them is actually RubyGems no longer being able to find where to insert in $LOAD_PATH:

rubygems/lib/rubygems.rb

Lines 573 to 581 in c98464e

def self.load_path_insert_index
$LOAD_PATH.each_with_index do |path, i|
return i if path.instance_variable_defined?(:@gem_prelude_index)
end
index = $LOAD_PATH.index RbConfig::CONFIG['sitelibdir']
index || 0
end

This issue was made more obvious as rake-compiler copied this logic:
rake-compiler/rake-compiler#202

Could these global mutations be avoided by RubyGems?
Maybe make install sitearchdir=... or so would work instead?

This might also come up as an issue as loading RubyGems is made more lazy (https://bugs.ruby-lang.org/issues/18568).

I will abide by the code of conduct.

@deivid-rodriguez
Copy link
Member

I tried the approach suggested at rake-compiler/rake-compiler#202 and it seems to work and make things simpler, so I'm good with doing this.

@eregon
Copy link
Contributor Author

eregon commented Jun 15, 2022

Great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants