ruby / ruby/rubygems

--install-dir vs --only_install_dir

Open
#5,585 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

RubyGems
Dominant language
Ruby
Stars
4k
Forks
1.9k
Avg merge
1d 2h
Merged PRs (30d)
81

Description

$ gem -v
2.7.6.3

$ ruby -v
ruby 2.5.9p229 (2021-04-05 revision 67939) [x86_64-linux]

$ gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 2.7.6.3
  - RUBY VERSION: 2.5.9 (2021-04-05 patchlevel 229) [x86_64-linux]
  - INSTALLATION DIRECTORY: /usr/share/gems
  - USER INSTALLATION DIRECTORY: /builddir/.gem/ruby
  - RUBY EXECUTABLE: /usr/bin/ruby
  - EXECUTABLE DIRECTORY: /usr/bin
  - SPEC CACHE DIRECTORY: /builddir/.gem/specs
  - SYSTEM CONFIGURATION DIRECTORY: /etc
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-linux
  - GEM PATHS:
     - /usr/share/gems
     - /builddir/.gem/ruby
     - /usr/local/share/gems
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - https://rubygems.org/
  - SHELL PATH:
     - /usr/bin
     - /bin
     - /usr/sbin
     - /sbin
     - /usr/local/sbin

$ gem install nokogiri:1.6.7.1 rake:0.9.6 rack:1.6.13 i18n:0.9.0 activesupport:4.2.7 --no-document --conservative --install-dir=~/g
Fetching: mini_portile2-2.0.0.gem (100%)
Successfully installed mini_portile2-2.0.0
Fetching: nokogiri-1.6.7.1.gem (100%)
Building native extensions. This could take a while...
Successfully installed nokogiri-1.6.7.1
Fetching: rake-0.9.6.gem (100%)
Successfully installed rake-0.9.6
Fetching: rack-1.6.13.gem (100%)
Successfully installed rack-1.6.13
Fetching: concurrent-ruby-1.1.10.gem (100%)
Successfully installed concurrent-ruby-1.1.10
Fetching: i18n-0.9.0.gem (100%)
Successfully installed i18n-0.9.0
Fetching: thread_safe-0.3.6.gem (100%)
Successfully installed thread_safe-0.3.6
Fetching: minitest-5.15.0.gem (100%)
Successfully installed minitest-5.15.0
Fetching: tzinfo-1.2.9.gem (100%)
Successfully installed tzinfo-1.2.9
Fetching: json-1.8.6.gem (100%)
Building native extensions. This could take a while...
Successfully installed json-1.8.6
Fetching: i18n-0.9.5.gem (100%)
Successfully installed i18n-0.9.5
Fetching: activesupport-4.2.7.gem (100%)
Successfully installed activesupport-4.2.7
12 gems installed

In the example above, the i18n is installed twice in different versions. This is due to --install-dir option implying also --only_install_dir in a non-transparent way. I don't think this is correct behavior. The --install-dir documentation only says:

https://github.com/rubygems/rubygems/blob/765996dde91e3b8e8108d5e6d9ff155425888ecb/lib/rubygems/installer.rb#L168

If the installation directory is still the same, its content should be reflected for resolution IMO. However the implementation derives the the --only_install_dir from the presence of --install-dir:

https://github.com/rubygems/rubygems/blob/765996dde91e3b8e8108d5e6d9ff155425888ecb/lib/rubygems/dependency_installer.rb#L68

Later submitting this value to the resolver with completely different meaning:

https://github.com/rubygems/rubygems/blob/765996dde91e3b8e8108d5e6d9ff155425888ecb/lib/rubygems/dependency_installer.rb#L288

Sorry for testing with outdated version of Ruby/RubyGems, but checking the code, it seems the behavior has not changed.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the referenced logic in lib/rubygems/installer.rb and lib/rubygems/dependency_installer.rb, especially the cited handling of --install-dir and --only_install_dir. Reproduce the gem install command from the report and inspect how the resolver treats the two options. Done means the installation-directory contents are reflected in dependency resolution without the options being conflated.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.