ansible-collections / community.general

Ansible Community General Collection
https://galaxy.ansible.com/ui/repo/published/community/general/
GNU General Public License v3.0
836 stars 1.53k forks source link

gem: ERROR: Use --install-dir or --user-install but not both #3259

Open dmsimard opened 3 years ago

dmsimard commented 3 years ago

Summary

Installing a gem with no arguments (other than state: present) yields the error ERROR: Use --install-dir or --user-install but not both on Fedora 34. Doesn't reproduce on Debian 10. I would test on Debian 11 but cloud images aren't available yet.

It is likely due to a change in one of the newer versions of rubygems.

Issue Type

Bug Report

Component Name

gem

Ansible Version

ansible [core 2.11.3] 
> ansible-galaxy collection list community.general

# /home/dmsimard/dev/virtualenvs/ansible/lib/python3.9/site-packages/ansible_collections
Collection        Version
----------------- -------
community.general 3.5.0

Configuration

Not relevant

OS / Environment

Fedora 34:

$ rpm -qa |grep gem
rubygem-bigdecimal-3.0.0-149.fc34.x86_64
ruby-default-gems-3.0.2-149.fc34.noarch
rubygem-bundler-2.2.22-149.fc34.noarch
rubygem-io-console-0.5.7-149.fc34.x86_64
rubygem-psych-3.3.0-149.fc34.x86_64
rubygems-3.2.22-149.fc34.noarch
rubygem-json-2.5.1-201.fc34.x86_64
rubygem-rdoc-6.3.1-149.fc34.noarch

Debian 10:

$ dpkg -l |grep -i ruby
ii  libruby2.5:amd64                  2.5.5-3+deb10u3              amd64        Libraries necessary to run Ruby 2.5
ii  rake                              12.3.1-3+deb10u1             all          ruby make-like utility
ii  ruby                              1:2.5.1                      amd64        Interpreter of object-oriented scripting language Ruby (default version)
ii  ruby-bundler                      1.17.3-3+deb10u1             all          Manage Ruby application dependencies (runtime)
ii  ruby-dev:amd64                    1:2.5.1                      amd64        Header files for compiling extension modules for Ruby (default version)
ii  ruby-did-you-mean                 1.2.1-1                      all          smart error messages for Ruby > 2.3
ii  ruby-minitest                     5.11.3-1                     all          Ruby test tools supporting TDD, BDD, mocking, and benchmarking
ii  ruby-molinillo                    0.6.4-1                      all          generic dependency resolution algorithm
ii  ruby-net-http-persistent          2.9.4-2                      all          Manages persistent connections using Net::HTTP
ii  ruby-net-telnet                   0.1.1-2                      all          telnet client library
ii  ruby-power-assert                 1.1.1-1                      all          library showing values of variables and method calls in an expression
ii  ruby-test-unit                    3.2.8-1                      all          unit testing framework for Ruby
ii  ruby-thor                         0.19.4-1                     all          Ruby scripting framework
ii  ruby-xmlrpc                       0.3.0-2                      all          XMLRPC library for Ruby
ii  ruby2.5                           2.5.5-3+deb10u3              amd64        Interpreter of object-oriented scripting language Ruby
ii  ruby2.5-dev:amd64                 2.5.5-3+deb10u3              amd64        Header files for compiling extension modules for the Ruby 2.5
ii  ruby2.5-doc                       2.5.5-3+deb10u3              all          Documentation for Ruby 2.5
ii  rubygems-integration              1.11+deb10u1                 all          integration of Debian Ruby packages with Rubygems

Steps to Reproduce

# Install ruby-bundler on debian or rubygems on fedora

- name: Install pluto planet aggregator
  community.general.gem:
    name: pluto
    state: present

Expected Results

gem installation should work.

Actual Results

TASK [feed-aggregator : Install pluto planet aggregator] ***********************************************************************************************************************************************************************************************************************************
fatal: [rss.community.eng.ansible.com]: FAILED! => {"changed": false, "cmd": "/usr/bin/gem install --user-install --no-document pluto", "msg": "ERROR:  Use --install-dir or --user-install but not both", "rc": 1, "stderr": "ERROR:  Use --install-dir or --user-install but not both\n", "stderr_lines": ["ERROR:  Use --install-dir or --user-install but not both"], "stdout": "", "stdout_lines": []}

Code of Conduct

ansibullbot commented 3 years ago

Files identified in the description:

If these files are inaccurate, please update the component name section of the description or use the !component bot command.

click here for bot help

ansibullbot commented 3 years ago

cc @None @johanwiren click here for bot help

dmsimard commented 3 years ago

I am able to reproduce the issue straight from CLI on fedora34:

# /usr/bin/gem install --user-install --no-document pluto
ERROR:  Use --install-dir or --user-install but not both

I was confused because I am not specifying --install-dir but if I check /usr/bin/gem install --help I see the following at the end:

  Defaults:
    --both --version '>= 0' --document --no-force
    --install-dir /usr/share/gems --lock

So it picks up --install-dir from the defaults which conflicts with the --user-install ?

Edit: debian 10 also provides a default --install-dir (--install-dir /var/lib/gems/2.5.0) but yet doesn't reproduce the issue.

dmsimard commented 3 years ago

I ended up finding that @robertdebock (hi long time no see!) filed this issue before the split out to community.general: https://github.com/ansible/ansible/issues/50434 which suggests a workaround by setting user_install: no.

This can work but doesn't solve the use case where gems are expected to be installed in the user directory by default so I'll leave this issue opened.

ansibullbot commented 2 years ago

Files identified in the description:

If these files are incorrect, please update the component name section of the description or use the !component bot command.

click here for bot help