Project

General

Profile

Actions

Bug #21828

closed

An incorrect warning message related to `benchmark` is shown when using `benchmark-ips`

Bug #21828: An incorrect warning message related to `benchmark` is shown when using `benchmark-ips`

Added by y-yagi (Yuji Yaginuma) about 2 months ago. Updated about 1 month ago.

Status:
Closed
Target version:
-
ruby -v:
ruby 4.0.1 (2026-01-13 revision e04267a14b) +PRISM [x86_64-linux]
[ruby-core:124443]

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) about 2 months ago Actions #1 [ruby-core:124444]

  • Status changed from Open to Assigned
  • Assignee set to hsbt (Hiroshi SHIBATA)

Updated by khasinski (Chris Hasiński) about 2 months ago Actions #2

  • 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) about 2 months ago Actions #3 [ruby-core:124449]

  • 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) about 1 month ago Actions #4 [ruby-core:124494]

  • 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

Updated by y-yagi (Yuji Yaginuma) about 1 month ago · Edited Actions #5 [ruby-core:124586]

  • 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.

Actions

Also available in: PDF Atom