Skip to content


Subversion checkout URL

You can clone with
Download ZIP


"bundle exec rspec spec" not working on JRuby/Windows #1689

celsodantas opened this Issue · 25 comments

I'm trying to run

bundle exec rspec spec

and I'm always getting this:

$ bundle exec rspec spec
bundler: command not found: rspec
Install missing gem executables with `bundle install`

If I run this

$ bundle exec rspec

It works! I mean, the code works but as I need to pass the spec/ folder, it doesn't do what I want. =[

But it work fine if I use like this:

$ bundle exec "rspec spec"

But as I'm trying to use Guard, it runs the rspec with no "quotes".

This are my configurations:

$ jruby -v
jruby 1.6.7 (ruby-1.8.7-p357) (2012-02-22 3e82bc8) (Java HotSpot(TM) Client VM 1.7.0) [Windows 7-x86-java]

Windows 7

$ gem -v

More info about my configuration (Gemfile[.lock] and bundle config)


Having the same problem.


Seems to be an issue going from 1.6.6 which works ok.

Moving to 1.6.7 and suddenly every exec produces
bundler: command not found:

Looks like issue with

lib/bundler/cli.rb : Kernel.exec(*ARGV)

Changing to system(*ARGV) and it runs.

Doubt this is the solution, as guess the subtle differences between Kernel.exec vs system are important to bundler.

So maybe a JRuby issue with Kernel exec introduced in 1.6.7 ?


Same happened in even with JRuby 1.6.6.

I'm running on a Windows 7 Professional 32bits.

$ jruby -v
jruby 1.6.6 (ruby-1.8.7-p357) (2012-01-30 5673572) (Java HotSpot(TM) Client VM 1.7.0) [Windows 7-x86-java] 

If I update the lib/bundler/cli.rb to use this:

desc "exec", "Run the command in context of the bundle"
long_desc <<-D
  Exec runs a command, providing it access to the gems in the bundle. While using
  bundle exec you can require and call the bundled gems as if they were installed
  into the systemwide Rubygems repository.
def exec(*)
  ARGV.shift # remove "exec"


    # Run
    if RUBY_DESCRIPTION =~ /Windows|(win|mingw)32/
  rescue Errno::EACCES
    Bundler.ui.error "bundler: not executable: #{ARGV.first}"
    exit 126
  rescue Errno::ENOENT
    Bundler.ui.error "bundler: command not found: #{ARGV.first}"
    Bundler.ui.warn  "Install missing gem executables with `bundle install`"
    exit 127

It works fine. But think Kernel.exec/Kernel.system call should be in a different class/module.

Do you guys think adding system verification (if Windows or not) is the best solution?


I'm only using Ruby On Rails for a couple of months now, so I wouldn't now if that is the best solution.


Me neither, I am totally unfamilar with bundler, I just needed to crack on and found that using system worked, hence my post, but since bundler sets up the environment in which things should run, I suspect Kernel exec maybe important.

May be worth cross posting to JRuby guys as they are very helpful and maybe an issue with Kernel exec ?

kgx commented

This issue occurs with all bundle exec commands followed by multiple arguments using JRuby on Windows. For example bundle exec rake assets:compile fails, but bundle exec "rake assets:precompile" (quoted) works fine.


yep, @kgx you're totally correct. Do you think it's a JRuby or Bundle issue?

kgx commented

The more I look at Kernel API the more I think it is a JRuby problem, because it is behaving differently from Ruby MRI on the same platform. I think the intent of bundle exec must be to call Kernel.exec(*ARGV), and replace the bundle process with the target command in the same shell, instead of opening a subshell. At least that is my interpretation...


Has anyone opened an issue with JRuby to get their opinions on this? Perhaps we can pull @headius into this issue.


Same issue here

jruby (ruby-1.9.2-p312) (2012-05-01 26e08ba) (Java HotSpot(TM) Client VM
 1.6.0_29) [Windows Server 2008-x86-java]

Opened a new ticket in jrubys bugtracker:


Having same problem with Windows 7 and Jruby


I'm not sure what would be causing this. Perhaps it's not actually launching JRuby in the subprocess?

Has anyone tried JRuby 1.7? In 1.7 we have improved "exec" on Windows so it actually does an exec (replace current process).

Is this only a Windows issue?


@headius It appears to be exclusive to windows. I'll verify on Monday whether it is occurring with 1.7 or not.


Bump - seeing the same issue here.


@semmons99 I think Monday has come and gone?

Anyone been able to test JRuby 1.7 (ideally master) to see if this is still an issue?


@headius: That's strange. I posted a followup that same day.

Here's the gist I created that day. It was a pretty simple test of creating a Rakefile and trying to execute it with Bundler. It did raise an entirely different error than in I just compiled and ran with master and received the same error.


Ok...I will investigate this and try to have things 100% for 1.7pre2.


Ok, I fixed one issue in the current native exec on unix, which allows your example to work properly (it was having trouble finding the executable and was not propagating env).


With this, bundle exec is working again on JRuby master.

I do not have a Windows instance handy to spin up, but that will be next.


@headius: I just ran with JRuby master and received, what appears to be, the same error. Here's the gist.


Indeed it does appear to be the same error. I have not attempted to fix Windows exec yet.

I think I can fix the NPE but the underlying cause is likely that exec is failing to execute properly.


This commit will prevent the null pointer, but it will still be failing to exec properly: jruby/jruby@27911f0


I'm having the same issue, but I found that if I quoted the command like

bundle exec 'cucumber --help'

instead of

bundle exec cucumber --help

things would work. NFI why.


Since the last Thor update, bundler will interpret options as if they were passed to exec. Sorry, and this is something that we want to fix.


Please re-open if this is still an issue.

@xaviershay xaviershay closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.