当我在终端中输入命令时,出现错误 - “找不到命令”
gal-harths-iMac:~ galharth$ ruby -v
-bash: ruby: command not found
gal-harths-iMac:~ galharth$ open -e .bash_profile
-bash: open: command not found
我该怎么办?
我的 .bash_profile 和 .profile 和 .bashrc 是空的,我需要在其中写一些东西吗?..
gal-harths-iMac:~ galharth$ ruby -v
-bash: ruby: command not found
gal-harths-iMac:~ galharth$ open -e .bash_profile
-bash: open: command not found
what shoud i do?
my .bash_profile and .profile and .bashrc are empty, i need to write something in them?..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
我怀疑你有一些东西覆盖了你的默认路径(比如 .bash_profile 或 .bashrc) open 在 os x 上是一个有效的命令,对我来说
man open
返回同样,有可能 ruby 已安装,但不在小路。我最好的猜测是删除或重命名您的 .bashrc 和 .bash_profile 文件,然后以该用户身份注销并重新登录,以重置您的 bash 会话。
要测试是否是用户级别问题,请在系统偏好设置下创建一个新帐户->帐户,然后以该用户身份登录,打开终端并输入 ruby -v 或 man open 等,看看是否可以在默认用户帐户上执行此操作。如果有效,那么很可能是您在“gal-harth”帐户中自定义的一些 bash 设置。
I suspect that you have something overriding your default path (like .bash_profile or .bashrc) open is a valid command on os x, for me
man open
returnsLikewise it is possible ruby is installed but not on the path. My best guess would be to delete or rename your .bashrc and .bash_profile files and log off as that user and log back in, to reset your bash session.
To test if it is a user level issue, create a new account under system preferences -> accounts and then log in as that user, open a terminal and type
ruby -v
orman open
, etc to see if you can do it on a default user account. If that works, it is most certainly some bash settings you have customized in your 'gal-harth' account.找出问题所在的第一步是查看当前的
PATH
是什么。如果返回一个空行,则表明出现了严重错误。您可以通过运行以下命令临时修复它:
这应该会为您提供
ruby
,以及open
和man
以及一堆其他命令。问题是,
PATH
说的是“在这些目录中查找二进制文件”,而不是“这是我想要使用的二进制文件的明确列表”。The first step to figuring out what's gone wrong is to see what your current
PATH
is.If that returns a blank line, something has gone horribly wrong. You can fix it temporarily by running:
And that should get you
ruby
, as well asopen
, andman
, and a bunch of other commands.The thing is, the
PATH
says “Look in these directories for binary files” and not “Here is an explicit list of binary files I want to use.”未安装红宝石。您需要从他们的网站此处安装它。
同样,“open”也不是我听说过的任何 bash 命令。
经过进一步思考,您是否尝试安装rvm?
Ruby is not installed. You need to install it from their website here.
Similarly, "open" is not any bash command I've ever heard of.
Upon further reflection, are you trying to install rvm?
如果您已经安装了 Ruby,它的位置是否已在您的 PATH 变量中设置?如果没有,您可以将其添加到您的 .bash_profile 中,如下所示:
If you have already installed Ruby, is its location already set in your PATH variable? If not, you can add it to your .bash_profile like this:
有什么东西正在搞乱你的 PATH ——你不需要有 .profile (或其任何变体)来正确设置默认 PATH。一般来说,当 PATH 出错时,是因为在各个配置文件之一中设置了错误。当您说 .bash_profile 和 .profile 和 .bashrc 为空时,您的意思是它们存在但其中没有任何内容,或者它们根本不存在?另外,您有 .bash_login 或 .bashrc 文件吗?
我会仔细看看你的主目录。使用 /bin/ls -ld ~/.* 列出主目录中的所有不可见文件,并查找名称中包含“sh”、“profile”或“rc”的任何文件。另外,运行
/usr/bin/grep PATH ~/.*
来查看是否有任何不可见文件提及 PATH —— 如果有的话,它们很可能是可疑的。Something is screwing up your PATH -- you shouldn't need to have a .profile (or any of its variants) to have the default PATH set properly. Generally, when the PATH gets screwed up, it's because it's being set wrong in one of the various profile files. When you say .bash_profile and .profile and .bashrc are empty, do you mean they exist but don't have anything in them, or they don't exist at all? Also, do you have a .bash_login or .bashrc file?
I'd take a closer look around your home directory. Use
/bin/ls -ld ~/.*
to list all of the invisible files in your home directory, and look for anything with "sh", "profile", or "rc" in the name. Also, run/usr/bin/grep PATH ~/.*
to see if any of the invisible files mention PATH -- if any do, they're likely suspects.只需输入
bash_filename
或./_filename
just type
bash_filename
or./_filename