bash 要求:找不到命令
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18214409/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
require: command not found
提问by Ava
which ruby
- /usr/local/bin/ruby
which ruby
—— /usr/local/bin/ruby
.bash_profile
has the above path
.bash_profile
有上面的路径
I have not left any trailing spaces before #!/usr/bin/env ruby
in the ruby script
我之前没有#!/usr/bin/env ruby
在 ruby 脚本中留下任何尾随空格
When I try to run sh ruby_script
, it gives require: command not found
. It is not able to recognize any of the ruby commands.
当我尝试运行时sh ruby_script
,它给出了require: command not found
. 它无法识别任何 ruby 命令。
I checked all the other posts getting the same error, and fixed everything accordingly. What else could I be missing?
我检查了所有其他帖子都得到了相同的错误,并相应地修复了所有内容。我还能缺少什么?
回答by konsolebox
Running sh ruby_script
is wrong. You must run ruby ruby_script
instead. If the file is executable run ./ruby_script
.
跑步sh ruby_script
是错误的。你必须运行ruby ruby_script
。如果文件是可执行的,请运行./ruby_script
.
回答by ThisSuitIsBlackNot
sh ruby_script
is invoking the shell. Try either
sh ruby_script
正在调用外壳。尝试任一
/path/to/ruby_script
or
或者
ruby /path/to/ruby_script