Skip to content
This repository

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

Closed
celsodantas opened this Issue March 01, 2012 · 25 comments
Celso Dantas

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
1.8.15

More info about my configuration (Gemfile[.lock] and bundle config)
https://gist.github.com/1949650

Lieven Cardoen

Having the same problem.

tom statter

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 ?

Celso Dantas

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.
D
def exec(*)
  ARGV.shift # remove "exec"

  Bundler.setup

  begin
    # Run
    if RUBY_DESCRIPTION =~ /Windows|(win|mingw)32/
        Kernel.system(*ARGV) 
    else
        Kernel.exec(*ARGV)
    end
  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
  end
end

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?

Lieven Cardoen

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

tom statter

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 ?

Keith Gaputis
kgx commented May 02, 2012

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.

Celso Dantas

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

Keith Gaputis
kgx commented May 02, 2012

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

Shane Emmons

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

Falk Pauser
fpauser commented May 15, 2012

Same issue here

jruby 1.6.7.2 (ruby-1.9.2-p312) (2012-05-01 26e08ba) (Java HotSpot(TM) Client VM
 1.6.0_29) [Windows Server 2008-x86-java]
Falk Pauser
fpauser commented May 15, 2012

Opened a new ticket in jrubys bugtracker: http://jira.codehaus.org/browse/JRUBY-6663

Karthik Narayanan

Having same problem with Windows 7 and Jruby 1.6.7.2

Charles Oliver Nutter

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?

Shane Emmons

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

Ciarán Archer

Bump - seeing the same issue here.

Charles Oliver Nutter

@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?

Shane Emmons

@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 1.6.7.2. I just compiled and ran with master and received the same error.

Charles Oliver Nutter

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

Charles Oliver Nutter

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

jruby/jruby@f8d2275

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.

Shane Emmons

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

Charles Oliver Nutter

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.

Charles Oliver Nutter

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

LukeGT

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.

André Arko
Owner

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.

Xavier Shay
Collaborator

Please re-open if this is still an issue.

Xavier Shay xaviershay closed this August 10, 2013
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.