简体   繁体   English

为什么在OSX的$ PATH中找不到应用程序中的符号链接?

[英]Why isn't symlink in application being found in $PATH in OSX?

I've always been a little wobbly on OSX environment variables, but I figured that, so long as /usr/local/bin was in my $PATH , that everything residing in that folder would be usable as a command in the shell. 我一直对OSX环境变量有些困惑,但是我发现,只要/usr/local/bin$PATH ,驻留在该文件夹中的所有内容都可以在shell中用作命令。

This doesn't appear to be happening. 这似乎没有发生。 $ echo $PATH gives me: $ echo $PATH给我:

/Users/[username]/.nvm/versions/node/v0.12.7/bin:/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin /用户/ [用户名] /。nvm /版本/节点/v0.12.7/bin:/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

My /usr/local/bin folder contains a symlink to an application; 我的/usr/local/bin文件夹包含一个到应用程序的符号链接。 let's call it some-application . 我们称其为some-application But typing some-application in the shell yields the classic bash error: 但是在shell中键入some-application产生经典的bash错误:

-bash: some-application: command not found -bash:某些应用程序:找不到命令

It was a simple mistake on my part. 就我而言,这是一个简单的错误。 I had created the symlink using a bad link location: 我使用错误的链接位置创建了符号链接:

$ ln -s /some/non-existent/location/some-application /usr/local/bin/some-application

There was no error on creating this 'link'. 创建此“链接”没有错误。 The symlink name was the one used in the bash error, masking the fact that it couldn't find the original location, not the link. symlink名称是bash错误中使用的名称,掩盖了它找不到原始位置而不是链接的事实。

For me, I would have either expected an error to be thrown on creation of the link, or at least for bash to detail which path couldn't be resolved. 对我来说,我要么期望在创建链接时会抛出一个错误,要么至少是bash详细说明无法解析的路径。 Something like this: 像这样:

-bash: /some/non-existent/location/some-application: No such file or directory -bash:/ some /不存在/ location / some-application:没有这样的文件或目录

Oh well. 那好吧。 Case closed. 案件结案。

PS 聚苯乙烯

Any light being shed on why it behaves this way might be helpful to myself and others. 阐明为什么这种行为的任何方式都可能对自己和他人有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM