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

Make --default and --install-dir options to gem install play nice together #3906

Merged
merged 9 commits into from Sep 15, 2020

Conversation

deivid-rodriguez
Copy link
Member

Description:

These options are probably not really used in real life together, but I happened to need them while writing a spec for a bundler issue fix. In particular, for #3757.

What was the end-user or developer problem that led to this PR?d

The problem is that when --default and --install-dir options are given to gem install, the default specification file should be installed to the specifications/default folder in install-dir, not to the one in the default gem directory.

What is your fix for the problem, implemented in this PR?

The fix seemed really simple, but due to the cumbersome setup of rubygems tests, it broke a lot of tests, so I had to refactor rubygems test setup to play nice with the change. More information is given in the individual commits.

Tasks:

  • Describe the problem / feature
  • Write tests
  • Write code to solve the problem
  • Get code review from coworkers / friends

I will abide by the code of conduct.

`Gem.use_paths` already does this.
Currently tests use two different gem layouts at the same time. For
example:

* `tmp/test_rubygems_25698/default/`, where default gem executables are installed.
* `tmp/test_rubygems_25698/gemhome/`, where other gems are installed.

This is quite unintuitive, and does not match realworld rubygems setups,
where these locations are usually the same.

This commit changes the setup so that this location is shared. Two
tweaks are needed to get tests passing because there's a couple of
places in the code where `rubygems` does some stuff differently if
`Gem.default_dir` != `Gem.dir`. In particular,

* `bindir` is set to `File.join(Gem.dir, "bin")` instead of `RbConfig::CONFIG["bindir"]`.
* Checking for executable overwrites is skipped.

Since after make this change these locations are now the same, we need
to adapt to these behavioral differences.
The previous `Gem.ensure_gem_subdirectories` ensures this.
`install_default_specs` already installs default specs.
With this combination of flags, `rubygems` should install the default
specification to `--install-dir`, not to the default rubygems
installation.

I doubt this has any realworld use cases, but fixing it is handy for me
in order to be able to write a test for a bug fix in `bundler` related
to `bundle clean --force` removing executables of default gems.
@hsbt
Copy link
Member

hsbt commented Aug 27, 2020

Basically it seems good. I will check the behavior changes of the default gems installation.

@deivid-rodriguez
Copy link
Member Author

@hsbt Did you have time to look at this? I don't think it should affect any realworld behavior since it's a very niche combination of flags. In any case, if it would affect I believe it's too fix a bug so it's fine.

But great to double check of course 👍.

@hsbt
Copy link
Member

hsbt commented Sep 4, 2020

Sorry, I'm working on RubyKaigi takeout 2020 as stuff in this week. I'll review this after that 🙇

@deivid-rodriguez
Copy link
Member Author

Sure, thanks! And keep up the good work 💪.

@deivid-rodriguez
Copy link
Member Author

@hsbt friendly ping :)

@deivid-rodriguez
Copy link
Member Author

Thanks so much @hsbt!

@deivid-rodriguez deivid-rodriguez merged commit 40fc322 into master Sep 15, 2020
@deivid-rodriguez deivid-rodriguez deleted the fix_install_as_default_with_install_dir branch September 15, 2020 13:28
deivid-rodriguez added a commit that referenced this pull request Dec 7, 2020
…stall_dir

Make `--default` and `--install-dir` options to `gem install` play nice together

(cherry picked from commit 40fc322)
deivid-rodriguez added a commit that referenced this pull request Dec 7, 2020
…stall_dir

Make `--default` and `--install-dir` options to `gem install` play nice together

(cherry picked from commit 40fc322)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants