Uploaded image for project: 'RHEL'
  1. RHEL
  2. RHEL-58435

`gem install --install-dir` and `--bindir` behavior differs from documentation

    • Icon: Bug Bug
    • Resolution: Won't Do
    • Icon: Blocker Blocker
    • None
    • CentOS Stream 8, CentOS Stream 9
    • ruby
    • None
    • None
    • None
    • rhel-sst-pt-python-ruby-nodejs
    • ssg_core_services
    • 3
    • None
    • None
    • None
    • None
    • All
    • None

      What were you trying to do that didn't work?

      Method operating_system_defaults at https://gitlab.com/redhat/centos-stream/rpms/ruby/-/blob/c9s/operating_system.rb#L98-110 forces binary files to be written to bin/ in the user's home directory when `gem install` is executed as a non-root user, ignoring the GEM_HOME environment setting.

      From https://guides.rubygems.org/command-reference/#gem-environment: "RubyGems' default local repository can be overridden with the GEM_PATH and GEM_HOME environment variables. GEM_HOME sets the default repository to install into. "

      The expected behavior is for binstubs to be installed to the $GEM_HOME/bin by default, which differs from the CentOS Stream 8 & 9 implementations.

       

      Referring to the line at https://gitlab.com/redhat/centos-stream/rpms/ruby/-/blob/c9s/operating_system.rb#L103 :

      If the user specifies `-no-user-install`, having the operating_system_defaults method inject `-bindir #{File.join [Dir.home, 'bin']}` to put binstubs in the user's home directory (as it does now) doesn't make sense.

      If the user specifies `-install-dir`, `gem install` will fail with output "ERROR: Use --install-dir or --user-install but not both" because operating_system_defaults adds `user-install`. This renders the `-install-dir` option unusable on its own.

      Both issues can be worked around by passing in additional arguments (see Steps to Reproduce section), but the solutions are unintuitive.

      Suggestion: how about not adding both `-user-install` and `bindir...` if the user specifies either `no-user-install` or `-install-dir`?

      What is the impact of this issue to you?

      Please provide the package NVR for which the bug is seen:

      ruby-3.0.7-162.el9

      How reproducible is this bug?:

      Always

      Steps to reproduce

      As a user other than root:
      > mkdir gem_home
      > export GEM_HOME=$PWD/gem_home
      > gem install bundler -v 1.17.3
      > ls ~/bin/bundler # confirm that the bundler executable was written to ~/bin
      > ls $GEM_HOME/bin # fails, directory doesn't exist

      Work-around:
      > gem install bundler -v 1.17.3 --bindir $GEM_HOME/bin

      Also,
      > gem install bundler --install-dir $GEM_HOME
      ERROR: Use --install-dir or --user-install but not both

      Work-around:
      > gem install bundler --install-dir $GEM_HOME --no-user-install

      Expected results

      The bin directory should be created at $GEM_HOME/bin.

      Actual results

      The bin directory is created in the user's home directory, ~/bin.

              ruby-maint ruby-maint
              emacalinao E Macalinao (Inactive)
              ruby-maint ruby-maint
              bot rhel-cs-apps-subsystem-qe bot rhel-cs-apps-subsystem-qe
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: