Bug #21828
closedAn incorrect warning message related to `benchmark` is shown when using `benchmark-ips`
Description
Descrition¶
When using benchmark-ips gem with Ruby 4.0.0, the warning related to benchmark gem is shown.
Step to reproduce¶
# Gemfile
# frozen_string_literal: true
source "https://rubygems.org"
gem "benchmark-ips"
# script.rb
require "benchmark/ips"
$ bundle exec ruby -v script.rb
ruby 4.0.0 (2025-12-25 revision 553f1675f3) +PRISM [x86_64-linux]
script.rb:1: warning: benchmark/ips is found in benchmark, which is not part of the default gems since Ruby 4.0.0.
You can add benchmark to your Gemfile or gemspec to fix this error.
Expected behavior¶
The warning for benchmark isn't shown when using benchmark-ips.
Updated by hsbt (Hiroshi SHIBATA) 2 months ago
- Status changed from Open to Assigned
- Assignee set to hsbt (Hiroshi SHIBATA)
Updated by khasinski (Chris Hasiński) 2 months ago
- Status changed from Assigned to Closed
Applied in changeset git|768862868472fb1800e556effb0e37be2fbaec52.
Fix incorrect bundled gems warning for hyphenated gem names
When requiring a file like "benchmark/ips", the warning system would
incorrectly warn about the "benchmark" gem not being a default gem,
even when the user has "benchmark-ips" (a separate third-party gem)
in their Gemfile.
The fix checks if a hyphenated version of the require path exists in
the bundle specs before issuing a warning. For example, requiring
"benchmark/ips" now checks for both "benchmark" and "benchmark-ips"
in the Gemfile.
[Bug #21828]
Updated by hsbt (Hiroshi SHIBATA) 2 months ago
- Backport changed from 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN, 4.0: UNKNOWN to 3.2: DONTNEED, 3.3: DONTNEED, 3.4: DONTNEED, 4.0: REQUIRED
Updated by k0kubun (Takashi Kokubun) 2 months ago
- Backport changed from 3.2: DONTNEED, 3.3: DONTNEED, 3.4: DONTNEED, 4.0: REQUIRED to 3.2: DONTNEED, 3.3: DONTNEED, 3.4: DONTNEED, 4.0: DONE
ruby_4_0 8d764da35768073c2e21ffeffa27ff2f3ab589b0.
Updated by y-yagi (Yuji Yaginuma) about 2 months ago
· Edited
- ruby -v changed from ruby 4.0.0 (2025-12-25 revision 553f1675f3) +PRISM [x86_64-linux] to ruby 4.0.1 (2026-01-13 revision e04267a14b) +PRISM [x86_64-linux]
Thanks for the fix, but I still get the same warning on Ruby 4.0.1.
$ bundle exec ruby -v script.rb
ruby 4.0.1 (2026-01-13 revision e04267a14b) +PRISM [x86_64-linux]
/home/y-yagi/.rbenv/versions/4.0.1/lib/ruby/gems/4.0.0/gems/benchmark-ips-2.14.0/lib/benchmark/ips.rb:2: warning: benchmark/timing is found in benchmark, which is not part of the default gems since Ruby 4.0.0.
You can add benchmark to your Gemfile or gemspec to fix this error.
Updated by Eregon (Benoit Daloze) 5 days ago
- Status changed from Closed to Open
Re-opening since it's still a problem on master and on 4.0.1, so the fix doesn't seem to work.
Another reproduction from https://github.com/evanphx/benchmark-ips/pull/148 is:
git clone git@github.com:evanphx/benchmark-ips.git
cd benchmark-ips
bundle
bundle exec rake
which gives:
/home/eregon/code/benchmark-ips/test/test_benchmark_ips.rb:2: warning: benchmark/ips is found in benchmark, which is not part of the default gems since Ruby 4.0.0.
You can add benchmark to your Gemfile or gemspec to fix this error.
...
Updated by hsbt (Hiroshi SHIBATA) 5 days ago
- Status changed from Open to Closed
The additional changes has been merged. I believe they fixed that.
Please look the merged commit at stable branch at first.
Updated by Eregon (Benoit Daloze) 5 days ago
· Edited
- Status changed from Closed to Open
As I said:
Eregon (Benoit Daloze) wrote in #note-6:
still a problem on master
I have tried with ruby 4.1.0dev (2026-03-11T07:46:22Z master c08f977ac7) +PRISM [x86_64-linux] specifically.
Please try the reproduction before closing.
Updated by Eregon (Benoit Daloze) 5 days ago
Also happens on 4.0-dev from ruby-build (ruby 4.0.1 (2026-03-10 revision 21f2bbf322) +PRISM [x86_64-linux]).
Updated by Eregon (Benoit Daloze) 5 days ago
Interestingly it seems fixed for the original reproduction in the issue description, but not for the new reproduction of running benchmark-ips's tests.
Updated by Eregon (Benoit Daloze) 5 days ago
A main difference between both reproductions are the Gemfile.lock, for the reproduction in the issue description:
GEM
remote: https://rubygems.org/
specs:
benchmark-ips (2.14.0)
PLATFORMS
ruby
x86_64-linux
DEPENDENCIES
benchmark-ips
CHECKSUMS
benchmark-ips (2.14.0) sha256=b72bc8a65d525d5906f8cd94270dccf73452ee3257a32b89fbd6684d3e8a9b1d
BUNDLED WITH
4.1.0.dev
and for the reproduction from https://bugs.ruby-lang.org/issues/21828#note-6:
GEM
remote: https://rubygems.org/
specs:
drb (2.2.3)
minitest (6.0.2)
drb (~> 2.0)
prism (~> 1.5)
prism (1.9.0)
rake (13.3.1)
PLATFORMS
ruby
x86_64-linux
DEPENDENCIES
minitest
rake (>= 10.5)
CHECKSUMS
drb (2.2.3) sha256=0b00d6fdb50995fe4a45dea13663493c841112e4068656854646f418fda13373
minitest (6.0.2) sha256=db6e57956f6ecc6134683b4c87467d6dd792323c7f0eea7b93f66bd284adbc3d
prism (1.9.0) sha256=7b530c6a9f92c24300014919c9dcbc055bf4cdf51ec30aed099b06cd6674ef85
rake (13.3.1) sha256=8c9e89d09f66a26a01264e7e3480ec0607f0c497a861ef16063604b1b08eb19c
BUNDLED WITH
4.0.3
So it seems like the fix only works when there is a dependency on the benchmark-ips gem, but there could be benchmark/something files outside a gem and then it still warns incorrectly.
Updated by hsbt (Hiroshi SHIBATA) 5 days ago
- Status changed from Open to Closed
Applied in changeset git|679e4069217104f4fe1d887ec48aa8c3537245b2.
Suppress bundled gems warning for subfeatures found outside stdlib [Bug #21828]
Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com
Updated by Eregon (Benoit Daloze) 5 days ago
Thank you for the quick fix!