当我在终端中输入命令时,出现错误 - “找不到命令”

发布于 2024-10-17 01:04:41 字数 253 浏览 7 评论 0原文

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

删除会话 2024-10-24 01:04:41

我怀疑你有一些东西覆盖了你的默认路径(比如 .bash_profile 或 .bashrc) open 在 os x 上是一个有效的命令,对我来说 man open 返回

NAME
     open -- open files and directories

SYNOPSIS
     open [-e] [-t] [-f] [-W] [-R] [-n] [-g] [-h] [-b bundle_identifier]
          [-a application] file ... [--args arg1 ...]

DESCRIPTION
     The open command opens a file (or a directory or URL), just as if you had
     double-clicked the file's icon. If no application name is specified, the
     default application as determined via LaunchServices is used to open the
     specified files.....

同样,有可能 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 returns

NAME
     open -- open files and directories

SYNOPSIS
     open [-e] [-t] [-f] [-W] [-R] [-n] [-g] [-h] [-b bundle_identifier]
          [-a application] file ... [--args arg1 ...]

DESCRIPTION
     The open command opens a file (or a directory or URL), just as if you had
     double-clicked the file's icon. If no application name is specified, the
     default application as determined via LaunchServices is used to open the
     specified files.....

Likewise 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 or man 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.

讽刺将军 2024-10-24 01:04:41

找出问题所在的第一步是查看当前的 PATH 是什么。

echo $PATH

如果返回一个空行,则表明出现了严重错误。您可以通过运行以下命令临时修复它:

export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin

这应该会为您提供ruby,以及openman以及一堆其他命令。

问题是,PATH 说的是“在这些目录中查找二进制文件”,而不是“这是我想要使用的二进制文件的明确列表”。

The first step to figuring out what's gone wrong is to see what your current PATH is.

echo $PATH

If that returns a blank line, something has gone horribly wrong. You can fix it temporarily by running:

export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin

And that should get you ruby, as well as open, and man, 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.”

-残月青衣踏尘吟 2024-10-24 01:04:41

未安装红宝石。您需要从他们的网站此处安装它。
同样,“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?

国际总奸 2024-10-24 01:04:41

如果您已经安装了 Ruby,它的位置是否已在您的 PATH 变量中设置?如果没有,您可以将其添加到您的 .bash_profile 中,如下所示:

echo 'export PATH=/wherever/ruby/is/located:$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:

echo 'export PATH=/wherever/ruby/is/located:$PATH' >> ~/.bash_profile
倥絔 2024-10-24 01:04:41

有什么东西正在搞乱你的 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.

哽咽笑 2024-10-24 01:04:41

只需输入 bash_filename./_filename

just type bash_filename or ./_filename

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文