Describe the problem as clearly as you can
When attempting to run a bundler-{x} executable using a bundle {x} when the x executable is in the local directory, Bundler returns an Errno::ENOENT: No such file or directory error
Did you try upgrading rubygems & bundler?
Yes
Post steps to reproduce the problem
I found this while trying to setup typo aliases (tbqh I accidentally type bundel isntall or some variety of it when in a hurry fairly often and got annoyed). The repro is quite simple:
> bundle test-repro
Could not find command "test-repro".
> echo "which ruby" > bundler-test-repro
> chmod +x bundler-test-repro
> bundle test-repro
I believe this is an issue in CLI::handle_no_command_error, specifically in Bundler::which:
|
def which(executable) |
|
executable_path = find_executable(executable) |
|
return executable_path if executable_path |
|
|
|
if (paths = ENV["PATH"]) |
|
quote = '"' |
|
paths.split(File::PATH_SEPARATOR).find do |path| |
|
path = path[1..-2] if path.start_with?(quote) && path.end_with?(quote) |
|
executable_path = find_executable(File.expand_path(executable, path)) |
|
return executable_path if executable_path |
|
end |
|
end |
|
end |
The first line, executable_path = find_executable(executable), returns the executable name without any path if the executable is present in the local working directory. Lower in that method, while looping through the PATH environment variable entries, the method calls File.expand_path first, which results in full file paths being returned. Replacing find_executable(executable) with find_executable(File.expand_path(executable)) seems to fix the issue:
irb(main):001> require 'bundler'
=> true
irb(main):002> command_path = Bundler.find_executable('bundler-test-repro')
=> "bundler-test-repro"
irb(main):003> Kernel.exec(command_path, *ARGV[1..-1])
(irb):4:in 'Kernel.exec': No such file or directory - bundler-test-repro (Errno::ENOENT)
from (irb):4:in '<main>'
from <internal:kernel>:168:in 'Kernel#loop'
from /Users/josh.wise/.rbenv/versions/3.4.9/lib/ruby/gems/3.4.0/gems/irb-1.17.0/exe/irb:9:in '<top (required)>'
from /Users/josh.wise/.rbenv/versions/3.4.9/bin/irb:25:in 'Kernel#load'
from /Users/josh.wise/.rbenv/versions/3.4.9/bin/irb:25:in '<main>'
irb(main):004> command_path = Bundler.find_executable(File.expand_path('bundler-test-repro'))
=> "/Users/josh.wise/notarize/notarize-api/bundler-test-repro"
irb(main):005> Kernel.exec(command_path, *ARGV[1..-1])
/Users/josh.wise/.rbenv/versions/3.4.9/bin/ruby
Which command did you run?
Any custom bundler-{x} command that's defined in the local working directory
What were you expecting to happen?
The custom bundler-{x} command should run as expected as per the man page:
PLUGINS
When running a command that isn´t listed in PRIMARY COMMANDS or UTILITIES, Bundler will try to find an executable on your path named
bundler-<command> and execute it, passing down any extra arguments to it.
What happened instead?
--- ERROR REPORT TEMPLATE -------------------------------------------------------
Errno::ENOENT: No such file or directory - bundler-test-repro
/Users/josh.wise/.rbenv/versions/3.4.9/lib/ruby/gems/3.4.0/gems/bundler-4.0.8/lib/bundler/cli.rb:194:in 'Kernel.exec'
/Users/josh.wise/.rbenv/versions/3.4.9/lib/ruby/gems/3.4.0/gems/bundler-4.0.8/lib/bundler/cli.rb:194:in 'Bundler::CLI.handle_no_command_error'
/Users/josh.wise/.rbenv/versions/3.4.9/lib/ruby/gems/3.4.0/gems/bundler-4.0.8/lib/bundler/vendor/thor/lib/thor/command.rb:32:in 'Bundler::Thor::Command#run'
/Users/josh.wise/.rbenv/versions/3.4.9/lib/ruby/gems/3.4.0/gems/bundler-4.0.8/lib/bundler/vendor/thor/lib/thor/command.rb:144:in 'Bundler::Thor::DynamicCommand#run'
/Users/josh.wise/.rbenv/versions/3.4.9/lib/ruby/gems/3.4.0/gems/bundler-4.0.8/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in 'Bundler::Thor::Invocation#invoke_command'
/Users/josh.wise/.rbenv/versions/3.4.9/lib/ruby/gems/3.4.0/gems/bundler-4.0.8/lib/bundler/vendor/thor/lib/thor.rb:538:in 'Bundler::Thor.dispatch'
/Users/josh.wise/.rbenv/versions/3.4.9/lib/ruby/gems/3.4.0/gems/bundler-4.0.8/lib/bundler/cli.rb:35:in 'Bundler::CLI.dispatch'
/Users/josh.wise/.rbenv/versions/3.4.9/lib/ruby/gems/3.4.0/gems/bundler-4.0.8/lib/bundler/vendor/thor/lib/thor/base.rb:584:in 'Bundler::Thor::Base::ClassMethods#start'
/Users/josh.wise/.rbenv/versions/3.4.9/lib/ruby/gems/3.4.0/gems/bundler-4.0.8/lib/bundler/cli.rb:29:in 'Bundler::CLI.start'
/Users/josh.wise/.rbenv/versions/3.4.9/lib/ruby/gems/3.4.0/gems/bundler-4.0.8/exe/bundle:28:in 'block in <top (required)>'
/Users/josh.wise/.rbenv/versions/3.4.9/lib/ruby/gems/3.4.0/gems/bundler-4.0.8/lib/bundler/friendly_errors.rb:118:in 'Bundler.with_friendly_errors'
/Users/josh.wise/.rbenv/versions/3.4.9/lib/ruby/gems/3.4.0/gems/bundler-4.0.8/exe/bundle:20:in '<top (required)>'
/Users/josh.wise/.rbenv/versions/3.4.9/bin/bundle:25:in 'Kernel#load'
/Users/josh.wise/.rbenv/versions/3.4.9/bin/bundle:25:in '<main>'
Environment
Bundler 4.0.8
Platforms ruby, arm64-darwin-25
Ruby 3.4.9p82 (2026-03-11 revision 76cca827ab52ab1d346a728f068d5b8da3e2952b) [arm64-darwin-25]
Full Path /Users/josh.wise/.rbenv/versions/3.4.9/bin/ruby
Config Dir /Users/josh.wise/.rbenv/versions/3.4.9/etc
RubyGems 3.6.9
Gem Home /Users/josh.wise/.rbenv/versions/3.4.9/lib/ruby/gems/3.4.0
Gem Path /Users/josh.wise/.local/share/gem/ruby/3.4.0:/Users/josh.wise/.rbenv/versions/3.4.9/lib/ruby/gems/3.4.0
User Home /Users/josh.wise
User Path /Users/josh.wise/.local/share/gem/ruby/3.4.0
Bin Dir /Users/josh.wise/.rbenv/versions/3.4.9/bin
Tools
Git 2.50.1 (Apple Git-155)
RVM not installed
rbenv rbenv 1.3.2
chruby not installed
Bundler Build Metadata
Timestamp 2026-03-11
Git SHA 1a32b76b73
Bundler settings
gems.contribsys.com
Set for your local app (/Users/josh.wise/notarize/notarize-api/.bundle/config): "daf018b1:[REDACTED]"
gems.graphql.pro
Set for your local app (/Users/josh.wise/notarize/notarize-api/.bundle/config): "gql_281_8447f019352:[REDACTED]"
with
Set for your local app (/Users/josh.wise/notarize/notarize-api/.bundle/config): [:debug]
Describe the problem as clearly as you can
When attempting to run a
bundler-{x}executable using abundle {x}when thexexecutable is in the local directory, Bundler returns anErrno::ENOENT: No such file or directoryerrorDid you try upgrading rubygems & bundler?
Yes
Post steps to reproduce the problem
I found this while trying to setup typo aliases (tbqh I accidentally type
bundel isntallor some variety of it when in a hurry fairly often and got annoyed). The repro is quite simple:I believe this is an issue in
CLI::handle_no_command_error, specifically inBundler::which:rubygems/bundler/lib/bundler.rb
Lines 479 to 491 in 3e3addb
The first line,
executable_path = find_executable(executable), returns the executable name without any path if the executable is present in the local working directory. Lower in that method, while looping through thePATHenvironment variable entries, the method callsFile.expand_pathfirst, which results in full file paths being returned. Replacingfind_executable(executable)withfind_executable(File.expand_path(executable))seems to fix the issue:Which command did you run?
Any custom
bundler-{x}command that's defined in the local working directoryWhat were you expecting to happen?
The custom
bundler-{x}command should run as expected as per the man page:What happened instead?
--- ERROR REPORT TEMPLATE -------------------------------------------------------
Environment
Bundler Build Metadata
Bundler settings