[英]-bash: /usr/local/bin/rbenv: /usr/bin/env: bad interpreter: Permission denied shows up everytime I try to use npm
Everytime I try to use npm I get the error above. 每次我尝试使用npm时,都会收到上述错误。 Python works fine on my computer but npm and node never work.
Python在我的计算机上工作正常,但是npm和node永远无法工作。
The error message you're getting suggests that executable script /usr/local/bin/rbenv
has a shebang line specifying executable /usr/bin/env
( #!/usr/bin/env ...
). 您收到的错误消息表明, 可执行脚本
/usr/local/bin/rbenv
有一个shebang行,指定可执行文件/usr/bin/env
( #!/usr/bin/env ...
)。
The fact that it says Permission denied
means that, for some reason, /usr/bin/env
is not executable , or at least not executable by you . 它说
Permission denied
的事实意味着,由于某种原因, /usr/bin/env
是不可执行的 ,或者至少不是您可执行的 。
This is highly unusual , because /usr/bin/env
is a frequently used standard utility. 这是非常不寻常的 ,因为
/usr/bin/env
是经常使用的标准实用程序。 I would start investigating there, such as by running ls -l /usr/bin/env
to see the permissions. 我将从那里开始调查,例如通过运行
ls -l /usr/bin/env
来查看权限。
More broadly, the question is why rbenv
- a utility for managing multiple Ruby environments - is involved here at all . 更广泛地说, 问题是为什么在这里完全涉及
rbenv
一种用于管理多个Ruby环境的实用程序 。
I suggest deactivating it at least temporarily while troubleshooting - comment out the line that loads rbenv
in your shell's profile/initialization file (in Bash: ~/.bash_profile
or ~/.bashrc
- see https://github.com/sstephenson/rbenv#how-rbenv-hooks-into-your-shell ), then open a new terminal window. 我建议至少在故障排除时暂时将其停用 -注释掉在外壳程序的配置文件/初始化文件中加载
rbenv
的行(在Bash中: ~/.bash_profile
或~/.bashrc
请参见https://github.com/sstephenson/rbenv #how-rbenv-hooks-into-your-shell ),然后打开一个新的终端窗口。
Finally, some background info on how npm
is normally launched on a Unix system: 最后,一些有关如何在Unix系统上正常启动
npm
背景信息 :
npm
is a symlink located in your $PATH
that points to an executable script named npm-cli.js
. npm
是位于$PATH
中的符号链接,指向名为npm-cli.js
的可执行脚本。 npm-cli.js
, despite containing JavaScript, actually uses #!/bin/sh
as its shebang line, which means that the shell ( sh
) initially executes the file. npm-cli.js
尽管包含JavaScript,但实际上使用#!/bin/sh
作为其shebang行,这意味着shell ( sh
) 最初将执行该文件。 npm-cli.js
is in fact the only line that sh
executes: npm-cli.js
的第二行是sh
执行的唯一行:
// 2>/dev/null; exec "`dirname "$0"`/node" "$0" "$@"
//
so that node later ignores it (since, in JavaScript, it is a comment ), given that the line's sole purpose is to invoke node . //
开头,因此节点以后将忽略它(因为在JavaScript中,它是一个注释 ),因为该行的唯一目的是调用node 。 //
is an attempt to run //
as a command , which invariably fails, so 2>/dev/null
is appended to suppress the error message. //
是作为命令运行//
的尝试,它总是失败,因此附加了2>/dev/null
来抑制错误消息。 exec "`dirname "$0"`/node" "$0" "$@"
then effectively relays invocation of the script at hand to the node
executable: exec "`dirname "$0"`/node" "$0" "$@"
然后将当前脚本的调用有效地传递给node
可执行文件:
exec
replaces the running sh
instance with the command specified. exec
用指定的命令替换正在运行的sh
实例。 "`dirname "$0"`/node"`
specifies the node executable as residing in the same directory as the the npm
symlink (which makes sense, given that both node
and npm
are always installed in the same directory). "`dirname "$0"`/node"`
将节点可执行文件指定为与npm
符号链接位于同一目录中(考虑到node
和npm
始终安装在同一目录中,这是有意义的)。 $0
refers to the script itself (the npm
symlink) $0
引用脚本本身( npm
符号链接) "$@"
simply passes all arguments passed to npm
through. "$@"
只是将传递给npm
所有参数传递npm
。 node
executable that is used to execute the npm
script is from the same Node.js version. npm
脚本的node
可执行文件来自同一 Node.js版本。 If a simple #!/usr/bin/env node
shebang were used, then whatever node
executable comes first in the $PATH
would be used. #!/usr/bin/env node
shebang,则将使用$PATH
第一个出现的node
可执行文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.