rubyinstaller2 icon indicating copy to clipboard operation
rubyinstaller2 copied to clipboard

Avoid method redefinition warning

Open deivid-rodriguez opened this issue 1 year ago • 3 comments

We're getting some test failures in rubygems because we run gem commands in verbose mode, in situations where the default GEM_HOME is not writable.

I'm not sure of the root cause (why GEM_HOME is not writable), since it only happens sporadically so I guess some other specs may be leaking permission changes or something. Also we could probably switch those to run in non verbose mode, or manually skip the warnings. But it seems best to not let the warning be printed in the first place, since that's exactly what's intended here.

This PR is a hack to achieve that.

deivid-rodriguez avatar Jan 30 '24 12:01 deivid-rodriguez

I'm now thinking that maybe the issue is multiple processes trying to write/delete this sentinel file concurrently? If that's the case, maybe adding the PID to the file name could help?

deivid-rodriguez avatar Jan 30 '24 18:01 deivid-rodriguez

Oh, and one last thing! Similar logic has now landed to RubyGems, although it's slightly different in approach and functionally:

  • It's not done on every rubygems require, but only when installing gems (I like this better to the approach here).
  • It's not done by actually trying to write a file, but by checking for writability (I think the approach here is more bullet proof).
  • In RubyGems we don't mess with bindir, or bundler, just change the default install_dir to something writable.

We may want to eventually unify all this!

deivid-rodriguez avatar Jan 30 '24 18:01 deivid-rodriguez

Ooops, closed accidentally.

deivid-rodriguez avatar Jan 31 '24 13:01 deivid-rodriguez

Fixed a typo and rebased.

deivid-rodriguez avatar Mar 18 '24 10:03 deivid-rodriguez