Rspec not found #36

Closed
ghost opened this Issue Jan 25, 2012 · 24 comments

Comments

Projects
None yet
@ghost

ghost commented Jan 25, 2012

I'm not sure this is necessarily an issue with the package, but hopefully you can help.

When i run a single rspec test, i get this output:

/bin/sh: rspec: command not found

In the console, i copy and paste the command that as created:

cd '/Users/user/Dropbox/code/app/' && rspec spec/controllers/profile_controller_spec.rb -l 163

When I run that command in Terminal, it works fine. Any why it wouldn't work from Sublime?

@gs

This comment has been minimized.

Show comment
Hide comment
@gs

gs Jan 25, 2012

Collaborator

Hi,

does the error occures also with running the whole file?

And how do you start sublime 2? Do you start it from console (http://www.sublimetext.com/docs/2/osx_command_line.html) ?

Br,
Grzegorz

Collaborator

gs commented Jan 25, 2012

Hi,

does the error occures also with running the whole file?

And how do you start sublime 2? Do you start it from console (http://www.sublimetext.com/docs/2/osx_command_line.html) ?

Br,
Grzegorz

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Jan 25, 2012

The error occurs when i run all tests as well.

I aliased the command and kick is off usually from my project directory in Terminal. I just tried to start the app from the applications folder and load it that way and it produced the same result.

ghost commented Jan 25, 2012

The error occurs when i run all tests as well.

I aliased the command and kick is off usually from my project directory in Terminal. I just tried to start the app from the applications folder and load it that way and it produced the same result.

@gs

This comment has been minimized.

Show comment
Hide comment
@gs

gs Jan 25, 2012

Collaborator

Tests does not work if the Sublime is started from applications folder.

But its strange that it does not work when you start it from console in you projects folder.

But does it ever worked for you ?

Br,
Grzegorz

Collaborator

gs commented Jan 25, 2012

Tests does not work if the Sublime is started from applications folder.

But its strange that it does not work when you start it from console in you projects folder.

But does it ever worked for you ?

Br,
Grzegorz

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Jan 25, 2012

I had linked it to a different directory. I recreated the link and started it from the terminal and tests work now. Thanks.

ghost commented Jan 25, 2012

I had linked it to a different directory. I recreated the link and started it from the terminal and tests work now. Thanks.

@ghost ghost closed this Jan 25, 2012

@gja

This comment has been minimized.

Show comment
Hide comment
@gja

gja Jan 30, 2012

Collaborator

This is caused (most likely) because you are using an intrusive ruby management tool, such as RVM.

If you would like this to work better, I suggest using rbenv.

Collaborator

gja commented Jan 30, 2012

This is caused (most likely) because you are using an intrusive ruby management tool, such as RVM.

If you would like this to work better, I suggest using rbenv.

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Jan 30, 2012

I already use Rbenv. I figured out what it was already.

On Jan 30, 2012, at 12:57 AM, Tejas Dinkar
reply@reply.github.com
wrote:

This is caused (most likely) because you are using an intrusive ruby management tool, such as RVM.

If you would like this to work better, I suggest using rbenv.


Reply to this email directly or view it on GitHub:
#36 (comment)

ghost commented Jan 30, 2012

I already use Rbenv. I figured out what it was already.

On Jan 30, 2012, at 12:57 AM, Tejas Dinkar
reply@reply.github.com
wrote:

This is caused (most likely) because you are using an intrusive ruby management tool, such as RVM.

If you would like this to work better, I suggest using rbenv.


Reply to this email directly or view it on GitHub:
#36 (comment)

@ghost ghost reopened this Feb 14, 2012

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Feb 14, 2012

I got this error again. I haven't changed anything. I have a shortcut created in /usr/local/bin, which is in my PATH.

I got to the project from command line and run "subl ."

when I run the tests using Command - Shift - R, I get "/bin/sh: rspec: command not found". When I look at the console, and see the command generated, if I type is in the console, it works fine.

any ideas?

ghost commented Feb 14, 2012

I got this error again. I haven't changed anything. I have a shortcut created in /usr/local/bin, which is in my PATH.

I got to the project from command line and run "subl ."

when I run the tests using Command - Shift - R, I get "/bin/sh: rspec: command not found". When I look at the console, and see the command generated, if I type is in the console, it works fine.

any ideas?

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Feb 14, 2012

Nevermind.

I ended up just forcing Rspec to run through "bundle exec" in the user settings and it finds it now.

ghost commented Feb 14, 2012

Nevermind.

I ended up just forcing Rspec to run through "bundle exec" in the user settings and it finds it now.

@ghost ghost closed this Feb 14, 2012

@ghost ghost reopened this Feb 14, 2012

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Feb 14, 2012

Despite what I mentioned before, now it says it can't find bundle exec. I'm not sure what else to do at this point. It works right when I change it, and then it seems to break on subsequent opens.

Works fine in the console
cd '/Users/bhilkert/Dropbox/code/meeteor/' && bundle exec rspec spec/requests/my_network_spec.rb -l 15

Doesn't work from within Sublime.

ghost commented Feb 14, 2012

Despite what I mentioned before, now it says it can't find bundle exec. I'm not sure what else to do at this point. It works right when I change it, and then it seems to break on subsequent opens.

Works fine in the console
cd '/Users/bhilkert/Dropbox/code/meeteor/' && bundle exec rspec spec/requests/my_network_spec.rb -l 15

Doesn't work from within Sublime.

@gs

This comment has been minimized.

Show comment
Hide comment
@gs

gs Feb 15, 2012

Collaborator

Hi,
To check if I understand correctly your problem:

So you start sublime in your project folder, you have normal structure and you modified the RubyTest.sublime-settings file...when you start test CTRL + ` shows the problem :

'bundle exec' not found?

If I am correct... than I have no idea whats the problem.. :D

Collaborator

gs commented Feb 15, 2012

Hi,
To check if I understand correctly your problem:

So you start sublime in your project folder, you have normal structure and you modified the RubyTest.sublime-settings file...when you start test CTRL + ` shows the problem :

'bundle exec' not found?

If I am correct... than I have no idea whats the problem.. :D

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Feb 15, 2012

Yeah that's exactly the steps. Hmmm....

ghost commented Feb 15, 2012

Yeah that's exactly the steps. Hmmm....

@gja

This comment has been minimized.

Show comment
Hide comment
@gja

gja Feb 16, 2012

Collaborator

http://yehudakatz.com/2011/05/30/gem-versioning-and-bundler-doing-it-right/

Always do a bundler --binstubs

and add ./bin to the start of your path

On Wed, Feb 15, 2012 at 7:04 PM, Brandon Hilkert <
reply@reply.github.com

wrote:

Yeah that's exactly the steps. Hmmm....


Reply to this email directly or view it on GitHub:

#36 (comment)

Collaborator

gja commented Feb 16, 2012

http://yehudakatz.com/2011/05/30/gem-versioning-and-bundler-doing-it-right/

Always do a bundler --binstubs

and add ./bin to the start of your path

On Wed, Feb 15, 2012 at 7:04 PM, Brandon Hilkert <
reply@reply.github.com

wrote:

Yeah that's exactly the steps. Hmmm....


Reply to this email directly or view it on GitHub:

#36 (comment)

@hale

This comment has been minimized.

Show comment
Hide comment
@hale

hale Feb 20, 2012

I also have this problem. Running

bundler --binstubs

fixed it for me

hale commented Feb 20, 2012

I also have this problem. Running

bundler --binstubs

fixed it for me

@gs

This comment has been minimized.

Show comment
Hide comment
@gs

gs Feb 21, 2012

Collaborator

Hi,

If rspec is not found and you are using bundler then edit file:
RubyTest.sublime-settings and edit commands by adding bundle exec like below:

"ruby_unit_exec": "bundle exec ruby -Itest",
"ruby_cucumber_exec": "bundle exec cucumber --no-color",
"ruby_rspec_exec": "bundle exec rspec",

Collaborator

gs commented Feb 21, 2012

Hi,

If rspec is not found and you are using bundler then edit file:
RubyTest.sublime-settings and edit commands by adding bundle exec like below:

"ruby_unit_exec": "bundle exec ruby -Itest",
"ruby_cucumber_exec": "bundle exec cucumber --no-color",
"ruby_rspec_exec": "bundle exec rspec",

@ghost ghost closed this Feb 24, 2012

@preadaptation

This comment has been minimized.

Show comment
Hide comment
@preadaptation

preadaptation Nov 9, 2012

(If anyone is still interested:) Another way of setting RubyTest's path to current RVM rspec is:

"run_rspec_command": "$(~/.rvm/bin/rvm gemdir)/bin/rspec {relative_path}",
"run_single_rspec_command": "$(~/.rvm/bin/rvm gemdir)/bin/rspec {relative_path} -l{line_number}",

(If anyone is still interested:) Another way of setting RubyTest's path to current RVM rspec is:

"run_rspec_command": "$(~/.rvm/bin/rvm gemdir)/bin/rspec {relative_path}",
"run_single_rspec_command": "$(~/.rvm/bin/rvm gemdir)/bin/rspec {relative_path} -l{line_number}",
@bronson

This comment has been minimized.

Show comment
Hide comment
@bronson

bronson Dec 11, 2012

@preadaptation agreed, that seems cleanest. It works for different Rubies being used in different projects and regardless of how your profile is set. Here's how I did the same thing for rbenv:

{
  "run_rspec_command": "$HOME/.rbenv/bin/rbenv exec rspec {relative_path}",
  "run_single_rspec_command": "$HOME/.rbenv/bin/rbenv exec rspec {relative_path} -l{line_number}"
}

It really would be nice to have RubyTest automatically use rvm or rbenv if available.

bronson commented Dec 11, 2012

@preadaptation agreed, that seems cleanest. It works for different Rubies being used in different projects and regardless of how your profile is set. Here's how I did the same thing for rbenv:

{
  "run_rspec_command": "$HOME/.rbenv/bin/rbenv exec rspec {relative_path}",
  "run_single_rspec_command": "$HOME/.rbenv/bin/rbenv exec rspec {relative_path} -l{line_number}"
}

It really would be nice to have RubyTest automatically use rvm or rbenv if available.

@yellowaj

This comment has been minimized.

Show comment
Hide comment
@yellowaj

yellowaj Dec 16, 2012

@preadaptation that fixed things for me - thanks!

@preadaptation that fixed things for me - thanks!

@gja

This comment has been minimized.

Show comment
Hide comment
@gja

gja Dec 17, 2012

Collaborator

@bronson If you want to be more specific, you can just set tings to
$HOME/.rbenv/shims/rspec {relative_path}

Collaborator

gja commented Dec 17, 2012

@bronson If you want to be more specific, you can just set tings to
$HOME/.rbenv/shims/rspec {relative_path}

@klippx

This comment has been minimized.

Show comment
Hide comment
@klippx

klippx Dec 19, 2012

@bronson thanks, that worked great for me!

klippx commented Dec 19, 2012

@bronson thanks, that worked great for me!

@rayning0

This comment has been minimized.

Show comment
Hide comment
@rayning0

rayning0 Mar 15, 2013

I spent many hours struggling with this same problem! I could not get rspec to run within Sublime Text 2, using the Michael Hartl "Ruby on Rails Tutorial." It kept saying

/bin/sh: rspec: command not found

I finally realized that the RubyTest package (https://github.com/maltize/sublime-text-2-ruby-tests) was looking in the WRONG PLACE for my RVM!

On my Mac, the path for RubyTest is /Library/Application Support/Sublime Text 2/Packages/Ruby Test

First, to make RubyTest seek the RVM, I changed the parameter in RubyTest.sublime-settings from

"check_for_rvm": false, to "check_for_rvm": true,

Then I dug into the Python code of run_ruby_test.py: https://github.com/maltize/sublime-text-2-ruby-tests/blob/master/run_ruby_test.py

At line 130, inside class BaseRubyTask, it had the wrong path for my RVM:

rvm_cmd = os.path.expanduser('~/.rvm/bin/rvm-auto-ruby')

I changed it to the full correct path: rvm_cmd = os.path.expanduser('/usr/local/rvm/bin/rvm-auto-ruby')

If this is not your path, find the correct path by typing

"which rvm-auto-ruby" and substitute that instead.

After saving run_ruby_test.py, I went to Terminal, cd to my Rails application directory, and ran "spork"

Finally, I opened static_pages_spec.rb in Sublime Text 2. Now all the tests work from it!

I spent many hours struggling with this same problem! I could not get rspec to run within Sublime Text 2, using the Michael Hartl "Ruby on Rails Tutorial." It kept saying

/bin/sh: rspec: command not found

I finally realized that the RubyTest package (https://github.com/maltize/sublime-text-2-ruby-tests) was looking in the WRONG PLACE for my RVM!

On my Mac, the path for RubyTest is /Library/Application Support/Sublime Text 2/Packages/Ruby Test

First, to make RubyTest seek the RVM, I changed the parameter in RubyTest.sublime-settings from

"check_for_rvm": false, to "check_for_rvm": true,

Then I dug into the Python code of run_ruby_test.py: https://github.com/maltize/sublime-text-2-ruby-tests/blob/master/run_ruby_test.py

At line 130, inside class BaseRubyTask, it had the wrong path for my RVM:

rvm_cmd = os.path.expanduser('~/.rvm/bin/rvm-auto-ruby')

I changed it to the full correct path: rvm_cmd = os.path.expanduser('/usr/local/rvm/bin/rvm-auto-ruby')

If this is not your path, find the correct path by typing

"which rvm-auto-ruby" and substitute that instead.

After saving run_ruby_test.py, I went to Terminal, cd to my Rails application directory, and ran "spork"

Finally, I opened static_pages_spec.rb in Sublime Text 2. Now all the tests work from it!

@hamxiaoz

This comment has been minimized.

Show comment
Hide comment
@hamxiaoz

hamxiaoz Mar 17, 2013

@rayning0 I'm having the exact same problem. However, for me, the solution is just simply turning on 'check_for_rvm' and leave everything else unchanged.

'check_for_rvm' : true

@rayning0 I'm having the exact same problem. However, for me, the solution is just simply turning on 'check_for_rvm' and leave everything else unchanged.

'check_for_rvm' : true
@rayning0

This comment has been minimized.

Show comment
Hide comment
@rayning0

rayning0 Mar 17, 2013

Yeah, my problem was I installed RVM in the wrong place, under root (admin), instead of my user account. Thus RVM is not in the expected spot on my Mac hard drive. Just doing "check_for_rvm: true" would not work for me.

Yeah, my problem was I installed RVM in the wrong place, under root (admin), instead of my user account. Thus RVM is not in the expected spot on my Mac hard drive. Just doing "check_for_rvm: true" would not work for me.

@iloveitaly

This comment has been minimized.

Show comment
Hide comment
@iloveitaly

iloveitaly Dec 29, 2014

If you are using rbenv via homebrew and rspec 3.1 use this RubyTest.sublime-settings config:

{
  "run_rspec_command": "eval \"$(/usr/local/bin/rbenv init -)\"; bundle exec rspec {relative_path}",
  "run_single_rspec_command": "eval \"$(/usr/local/bin/rbenv init -)\"; bundle exec rspec {relative_path}:{line_number}"
}

If you are using rbenv via homebrew and rspec 3.1 use this RubyTest.sublime-settings config:

{
  "run_rspec_command": "eval \"$(/usr/local/bin/rbenv init -)\"; bundle exec rspec {relative_path}",
  "run_single_rspec_command": "eval \"$(/usr/local/bin/rbenv init -)\"; bundle exec rspec {relative_path}:{line_number}"
}
@newmen

This comment has been minimized.

Show comment
Hide comment
@newmen

newmen Feb 20, 2015

I fixed it in #250

newmen commented Feb 20, 2015

I fixed it in #250

This issue was closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment