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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 06:14:31  来源:igfitidea点击:

require: command not found

rubybash.bash-profile

提问by Ava

which ruby- /usr/local/bin/ruby

which ruby—— /usr/local/bin/ruby

.bash_profilehas the above path

.bash_profile有上面的路径

I have not left any trailing spaces before #!/usr/bin/env rubyin 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_scriptis wrong. You must run ruby ruby_scriptinstead. If the file is executable run ./ruby_script.

跑步sh ruby_script是错误的。你必须运行ruby ruby_script。如果文件是可执行的,请运行./ruby_script.

回答by ThisSuitIsBlackNot

sh ruby_scriptis invoking the shell. Try either

sh ruby_script正在调用外壳。尝试任一

/path/to/ruby_script

or

或者

ruby /path/to/ruby_script