ruby / ruby/rubygems

--conservative is not working.

Open
#8,485 1 comment 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 always tries to upgrade the dependencies of the to-be-installed package even with the --conservative flag set. In my case I'm trying to avoid updating a gem installed (and managed) by the host OS (Gentoo).
In this e.g. ostruct and bigdecimal gems are already installed and part of the ruby installation --

gem search -d -l ostruct

*** LOCAL GEMS ***

ostruct (0.5.5)
    Author: Marc-Andre Lafortune
    Homepage: https://github.com/ruby/ostruct
    Licenses: Ruby, BSD-2-Clause
    Installed at (default): /usr/lib64/ruby/gems/3.2.0

    Class to build custom data structures, similar to a Hash.

gem search -d -l bigdecimal

*** LOCAL GEMS ***

bigdecimal (3.1.3)
    Authors: Kenta Murata, Zachary Scott, Shigeo Kobayashi
    Homepage: https://github.com/ruby/bigdecimal
    Licenses: Ruby, bsd-2-clause
    Installed at (default): /usr/lib64/ruby/gems/3.2.0

    Arbitrary-precision decimal floating-point number library.

I'm trying to install the 'oj' gem --

gem dependency -r -v 3.16.9 oj
Gem oj-3.16.9
  bigdecimal (>= 3.0)
  minitest (~> 5, development)
  ostruct (>= 0.2)
  rake-compiler (>= 0.9, < 2.0, development)
  test-unit (~> 3.0, development)

The currently installed bigdecimal and ostruct versions of the gem are good enough to satisfy the dependencies. However --

gem install --conservative --minimal-deps --explain -v 3.16.9 oj
Gems to install:
  ostruct-0.6.1
  bigdecimal-3.1.9
  oj-3.16.9
RubyGems Environment:
  - RUBYGEMS VERSION: 3.4.22
  - RUBY VERSION: 3.2.5 (2024-07-26 patchlevel 208) [x86_64-linux]
  - INSTALLATION DIRECTORY: /usr/lib64/ruby/gems/3.2.0
  - USER INSTALLATION DIRECTORY: /home/de/.local/share/gem/ruby/3.2.0
  - RUBY EXECUTABLE: /usr/bin/ruby32
  - GIT EXECUTABLE: /usr/bin/git
  - EXECUTABLE DIRECTORY: /usr/bin
  - SPEC CACHE DIRECTORY: /home/de/.local/share/gem/specs
  - SYSTEM CONFIGURATION DIRECTORY: /etc
  - RUBYGEMS PLATFORMS:
     - ruby
     - x86_64-linux
  - GEM PATHS:
     - /usr/lib64/ruby/gems/3.2.0
     - /home/de/.local/share/gem/ruby/3.2.0
     - /usr/local/lib64/ruby/gems/3.2.0
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => true
     - :bulk_threshold => 1000
     - "install" => "--install-dir /home/de/.local/share/gem/ruby/3.2.0 --bindir /home/de/bin"
     - "uninstall" => "--install-dir /home/de/.local/share/gem/ruby/3.2.0 --bindir /home/de/bin"
     - "update" => "--install-dir /home/de/.local/share/gem/ruby/3.2.0 --bindir /home/de/bin"
  - REMOTE SOURCES:
     - https://rubygems.org/
  - SHELL PATH:
     - /usr/local/sbin
     - /usr/local/bin
     - /usr/bin
     - /opt/bi

If I gem install --ignore-dependencies oj oj works as expected since the dependencies are already complete.

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 by reproducing the dependency resolution shown by gem install --conservative --minimal-deps --explain -v 3.16.9 oj, comparing it with --ignore-dependencies. Trace the gem install handling of --conservative and --minimal-deps through dependency resolution. Done means already-installed, compatible ostruct and bigdecimal gems are retained while installing oj.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.