-bash: rspec: 命令未找到

问题描述:

我在/Library/Ruby/Gems/1.8/gems/rspec-2.6.0/lib 中找到了 rspec我什至在我的 .bash_profile 中添加了一个路径:PATH="/usr/local/bin:/Library/Ruby/Gems/1.8/gems/rspec-2.6.0/lib:

I found rspec in /Library/Ruby/Gems/1.8/gems/rspec-2.6.0/lib I even put a path to it in my .bash_profile: PATH="/usr/local/bin:/Library/Ruby/Gems/1.8/gems/rspec-2.6.0/lib:

但是当我在终端中输入 rspec 时,我找不到命令.即使我与文件 rspec 位于同一目录中?

But when I enter rspec in terminal I get command not found. Even when I'm in the same directory as the file rspec?

除了是个菜鸟,我做错了什么?

Besides being a noob, what am I doing wrong?

*更新:*我能够使用bundle exec rspec"来执行 rspec,但我想弄清楚为什么我不能只使用 rspec.

*Update:*I was able to execute rspec using "bundle exec rspec" but I'd like to figure out why I can't just use rspec.

要使文件作为二进制可执行文件,您通常需要:

for a file to be executable as a binary you generally need to:

(a) make the file executable by running chmod 755 /path/to/scripts/awesometask.gem 
(b) add a "shebang" to the top of the file (first line) that contains the path of the interpreter for the script: #!/usr/bin/ruby 
(c) execute file with full path: /path/to/scripts/awesometask.gem 
or
(c1) add the folder where the file is to PATH: PATH=$PATH:/path/to/scripts