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

Ruby with --with-sitedir=no configuration #7414

Open
voxik opened this issue Jan 23, 2024 · 1 comment
Open

Ruby with --with-sitedir=no configuration #7414

voxik opened this issue Jan 23, 2024 · 1 comment
Labels

Comments

@voxik
Copy link
Contributor

voxik commented Jan 23, 2024

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:

def generate_default_dirs
prefix = options[:prefix]
site_or_vendor = options[:site_or_vendor]
if prefix.empty?
lib_dir = RbConfig::CONFIG[site_or_vendor]
bin_dir = RbConfig::CONFIG["bindir"]
else
lib_dir = File.join prefix, "lib"
bin_dir = File.join prefix, "bin"
end
[prepend_destdir_if_present(lib_dir), prepend_destdir_if_present(bin_dir)]
end

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).

@voxik voxik added the RubyGems label Jan 23, 2024
@voxik
Copy link
Contributor Author

voxik commented Jan 24, 2024

There actually are small traces of handling the missing vendor dir. That means also JRuby might struggle to pass these test cases and indeed, the whole test file is just disabled:

end unless Gem.java_platform?

This is related to the following test failure:

  1) Failure:
TestGemInstallUpdateOptions#test_add_install_update_options [/builddir/build/BUILD/ruby-3.3.0/test/rubygems/test_gem_install_update_options.rb:36]:
Failed assertion, no message given.

Where the hidden reason for the test failure is this exception:

#<Gem::OptionParser::InvalidOption: --vendor your platform is not supported>

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

No branches or pull requests

1 participant