Forum: Ruby on Rails rspec - bash: rspec: command not found

Posted by nobosh (Guest)
on 2010-08-30 05:48
(Received via mailing list)
Hello, I'm going through the Rails 3 book (which is awesome by the
way) here: http://railstutorial.org/chapters/static-pages#top

In the book it has me using "rspec" which is installed:
bundle show rspec
/Library/Ruby/Gems/1.8/gems/rspec-2.0.0.beta.18

But when I go to run the test, "rspec spec/" I get "-bash: rspec:
command not found"

Did I miss a step? thxs!
Posted by nobosh (Guest)
on 2010-08-30 06:50
(Received via mailing list)
Same issue with this command in the tutorial: "spork --bootstrap"
Posted by nobosh (Guest)
on 2010-09-02 06:50
(Received via mailing list)
Any ideas?
Posted by Chris Mear (Guest)
on 2010-09-02 08:07
(Received via mailing list)
On 30 August 2010 04:30, nobosh <bhellman1@gmail.com> wrote:
> Did I miss a step? thxs!
As you've installed your gems with Bundler, try this instead:

bundle exec rspec spec

Bundler doesn't necessarily install gems in the standard location,
which is possibly why the rspec executable isn't in your $PATH (which
is why you got the 'command not found' error). Either way, when you're
using Bundler, you almost always want to run Ruby commands in the
context of the bundle, which is what bundle exec does.

Chris
Posted by nobosh (Guest)
on 2010-09-02 17:37
(Received via mailing list)
Also, I tried "bundle exec rspec spec" but that had no effect.
Posted by Aleksey Gureiev (Guest)
on 2010-09-02 17:47
Attachment: PGP.sig (496 Bytes)
(Received via mailing list)
Do you have RSpec installed (not as a bundler gem)? Bundler won't 
install binaries for you -- will just load the correct Ruby classes. Try 
installing RSpec with "gem install rspec" or "sudo gem install rspec" 
(keep an eye on the gem version) and try again.

- A
Posted by nobosh (Guest)
on 2010-09-02 17:48
(Received via mailing list)
Thanks Chris, I'll try that now...

By the way, I get this error:

$ spec
/Library/Ruby/Site/1.8/rubygems.rb:335:in `bin_path': can't find
executable spec for rspec-2.0.0.beta.18 (Gem::Exception)
  from /usr/bin/spec:19


Is there a PATH config option somewhere?
Posted by nobosh (Guest)
on 2010-09-02 17:58
(Received via mailing list)
Here's some info that might help:


mtvl08a231701:sample_app me$ echo $PATH
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/usr/
X11/bin



mtvl08a231701:sample_app me$ gem ENV
RubyGems Environment:
  - RUBYGEMS VERSION: 1.3.7
  - RUBY VERSION: 1.8.7 (2009-06-12 patchlevel 174) [universal-
darwin10.0]
  - INSTALLATION DIRECTORY: /Library/Ruby/Gems/1.8
  - RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/
Versions/1.8/usr/bin/ruby
  - EXECUTABLE DIRECTORY: /usr/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - universal-darwin-10
  - GEM PATHS:
     - /Library/Ruby/Gems/1.8
     - /Users/me/.gem/ruby/1.8
     - /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/
ruby/gems/1.8
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
     - :sources => ["http://gems.rubyforge.org/", "http://
gemcutter.org/"]
  - REMOTE SOURCES:
     - http://gems.rubyforge.org/
     - http://gemcutter.org/






------ Does that look right?
Posted by nobosh (Guest)
on 2010-09-02 18:35
(Received via mailing list)
Ok this work, found here: http://gembundler.com/ (Also pasted below)
I hope it helps someone else finding this...


Run an executable that comes with a gem in your bundle
$ bundle exec rspec spec/models
In some cases, running executables without bundle exec may work, if
the executable happens to be installed in your system and does not
pull in any gems that conflict with your bundle.

However, this is unreliable and is the source of considerable pain.
Even if it looks like it works, it may not work in the future or on
another machine.

If you want a way to get a shortcut to gems in your bundle
$ bundle install --binstubs
$ bin/rspec spec/models
The executables installed into bin are scoped to the bundle and will
always work


B
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.