ruby / ruby/rubygems

Ruby with `--with-sitedir=no` configuration

Open
#7,414 1 comment 1 reaction 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

I am trying to prepare minimal and self contained Ruby RPM package. Therefore I chose to configure Ruby using --with-sitedir=no --with-vendordir=no configuration options. And now I am facing test suite errors such as:

111) Error:
TestGemCommandsSetupCommand#test_execute_regenerate_binstubs:
Errno::ENOENT: No such file or directory @ dir_chdir0 - $(sitedir)/ruby3.3/rubygems
    /builddir/build/BUILD/ruby-3.3.0/lib/rubygems/commands/setup_command.rb:465:in `chdir'
    /builddir/build/BUILD/ruby-3.3.0/lib/rubygems/commands/setup_command.rb:465:in `files_in'
    /builddir/build/BUILD/ruby-3.3.0/lib/rubygems/commands/setup_command.rb:509:in `block in remove_old_lib_files'
    /builddir/build/BUILD/ruby-3.3.0/lib/rubygems/commands/setup_command.rb:506:in `each'
    /builddir/build/BUILD/ruby-3.3.0/lib/rubygems/commands/setup_command.rb:506:in `remove_old_lib_files'
    /builddir/build/BUILD/ruby-3.3.0/lib/rubygems/commands/setup_command.rb:170:in `execute'
    /builddir/build/BUILD/ruby-3.3.0/test/rubygems/test_gem_commands_setup_command.rb:68:in `test_execute_regenerate_binstubs'

If I understand correctly, the $(sitedir) actually comes from here:

https://github.com/rubygems/rubygems/blob/4198033da31a834ad892f82d6f91d46404d79d33/lib/rubygems/commands/setup_command.rb#L449-L462

In normal situation, with the default site dir configuration, the RbConfig::CONFIG[site_or_vendor] would be expanded into proper path. However, with disabled site dir, the RbConfig does not have value for the sitedir, therefore the $(sitedir) is kept. It seems that the Ruby's rbinstall.rb script handles this scenario:

https://github.com/ruby/ruby/blob/a846d391d38b34fcc4f90adef967c166c923bd56/tool/rbinstall.rb#L354-L361

IOW, I don't think this is just test suite error. The test suite error correctly points out that there might be user scenario, which is not correctly handled (is it trying to update RubyGems via gem update?). If this is valid Ruby configuration, I believe that RubyGems should properly handle this situation (even if "properly" was just reporting that there is no location for updated RubyGems).

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 lib/rubygems/commands/setup_command.rb around lines 449-462 and test/rubygems/test_gem_commands_setup_command.rb, then compare the handling in tool/rbinstall.rb around lines 354-361. Run the cited setup-command test with --with-sitedir=no and --with-vendordir=no; done means the configuration has defined, correct behavior without the ENOENT failure.

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
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.