While testing the --prefer-local option introduced in #5657 I noticed it does not install an older version when specifically locked in Gemfile.
Describe the problem as clearly as you can
(debian-sid)pravi@mahishi:/tmp$ cat Gemfile
source 'https://rubygems.org'
gem 'ipaddr', '1.2.2'
This is locked to an older version due issues in gitlab - https://gitlab.com/gitlab-org/gitlab/-/issues/376417
bundle install --prefer-local
Could not find gem 'ipaddr (= 1.2.2)' in locally installed gems.
The source contains the following gems matching 'ipaddr':
* ipaddr-1.2.4
So in case the locally installed version cannot satisfy the specified constraint, this should get installed from rubygems.org
Did you try upgrading rubygems & bundler?
Using bundler 2.3.20
Post steps to reproduce the problem
Sample Gemfile is provided above and system has a newer ipaddr via ruby.
Which command did you run?
bundle install --prefer-local
What were you expecting to happen?
I was expecting bundler to install ipaddr 1.2.2 from rubygems.org as locally available version 1.2.4 is not satisfying the constraint specified in Gemfile, ie, '1.2.2'
What actually happened?
It failed to install the required version.
If not included with the output of your command, run bundle env and paste the output below
(debian-sid)pravi@mahishi:/tmp$ bundle env
Environment
Bundler 2.3.20
Platforms ruby, x86_64-linux
Ruby 3.1.2p20 (2022-04-12 revision 4491bb740a9506d76391ac44bb2fe6e483fec952) [x86_64-linux]
Full Path /usr/bin/ruby3.1
Config Dir /etc
RubyGems 3.3.15
Gem Home /var/lib/gems/3.1.0
Gem Path /home/pravi/.gem/ruby/3.1.0:/var/lib/gems/3.1.0:/usr/local/lib/ruby/gems/3.1.0:/usr/lib/ruby/gems/3.1.0:/usr/lib/x86_64-linux-gnu/ruby/gems/3.1.0:/usr/share/rubygems-integration/3.1.0:/usr/share/rubygems-integration/all:/usr/lib/x86_64-linux-gnu/rubygems-integration/3.1.0
User Home /home/pravi
User Path /home/pravi/.gem/ruby/3.1.0
Bin Dir /usr/local/bin
Tools
Git 2.40.1
RVM not installed
rbenv not installed
chruby not installed
Bundler Build Metadata
Built At 2022-08-10
Git SHA 4fd2813f54
Released Version true
Gemfile
Gemfile
source 'https://rubygems.org'
gem 'ipaddr', '1.2.2'
Gemfile.lock
<No /tmp/Gemfile.lock found>
While testing the --prefer-local option introduced in #5657 I noticed it does not install an older version when specifically locked in Gemfile.
Describe the problem as clearly as you can
This is locked to an older version due issues in gitlab - https://gitlab.com/gitlab-org/gitlab/-/issues/376417
So in case the locally installed version cannot satisfy the specified constraint, this should get installed from rubygems.org
Did you try upgrading rubygems & bundler?
Using bundler 2.3.20
Post steps to reproduce the problem
Sample Gemfile is provided above and system has a newer ipaddr via ruby.
Which command did you run?
bundle install --prefer-local
What were you expecting to happen?
I was expecting bundler to install ipaddr 1.2.2 from rubygems.org as locally available version 1.2.4 is not satisfying the constraint specified in Gemfile, ie, '1.2.2'
What actually happened?
It failed to install the required version.
If not included with the output of your command, run
bundle envand paste the output below(debian-sid)pravi@mahishi:/tmp$ bundle env
Environment
Bundler Build Metadata
Gemfile
Gemfile
Gemfile.lock