/usr/bin/env:ln:符号链接级别过多 [英] /usr/bin/env: ln: Too many levels of symbolic links

查看:56
本文介绍了/usr/bin/env:ln:符号链接级别过多的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题使我丧命,我觉得我已经尝试了一切.

This problem is killing me and I feel like I've tried everything.

首先,升级到Capistrano 3时开始出现问题.Capistrano现在在部署每个命令之前先使用/usr/bin/env,以确保环境设置正确.

First off, the problem started happening when upgrading to Capistrano 3. Capistrano now utilizes /usr/bin/env before every command when deploying, to make sure the environment setup is correct.

Capistrano要创建到必要的共享目录和相应文件的符号链接时,会尝试执行以下命令:

When Capistrano goes to create symlinks to the necessary shared directory and respective files, it attempts commands like:

/usr/bin/env ln -s /full/path /different/full/path

...然后出现错误:

...and then it errors out:

/usr/bin/env: ln: Too many levels of symbolic links

我意识到这不是Capistrano的错,所以我开始通过将服务器SSH并尝试相同的命令来进行故障排除,并且收到了相同的错误(至少对于保持一致性很有帮助).然后,我尝试不带/usr/bin/env的同一命令:

I realize it's not Capistrano's fault, so I began troubleshooting by ssh'ing to my server and trying the same command, and I receive the same error (which at least is good for consistency). I then try the same command without /usr/bin/env:

ln -s /full/path /different/full/path

它有效!!!!也许您可以看到我看不到的真正解决方案?

And it works!!!! Maybe you can see the real solution that I can't?

这是/usr/bin/env命令的输出:

here is the output of just the /usr/bin/env command:

rvm_bin_path=/home/deployer/.rvm/bin
GEM_HOME=/home/deployer/.rvm/gems/ruby-1.9.3-p392
TERM=xterm-256color
SHELL=/bin/bash
IRBRC=/home/deployer/.rvm/rubies/ruby-1.9.3-p392/.irbrc
SSH_CLIENT=...
OLDPWD=/home/deployer/Sites/example.com
MY_RUBY_HOME=/home/deployer/.rvm/rubies/ruby-1.9.3-p392
SSH_TTY=/dev/pts/0
USER=deployer
LS_COLORS= .....
_system_type=Linux
rvm_path=/home/deployer/.rvm
SSH_AUTH_SOCK=....
rvm_prefix=/home/deployer
MAIL=/var/mail/deployer
PATH=/home/deployer/.rvm/gems/ruby-1.9.3-p392/bin:/home/deployer/.rvm/gems/ruby-1.9.3-p392@global/bin:/home/deployer/.rvm/rubies/ruby-1.9.3-p392/bin:/home/deployer/.rvm/bin:/opt/rubyee/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/home/deployer/.rvm/bin
PWD=/home/deployer/Sites
LANG=en_US.UTF-8
_system_arch=i386
_system_version=12.04
rvm_version=1.26.4 (latest)
SHLVL=1
HOME=/home/deployer
LOGNAME=deployer
GEM_PATH=/home/deployer/.rvm/gems/ruby-1.9.3-p392:/home/deployer/.rvm/gems/ruby-1.9.3-p392@global
SSH_CONNECTION=....
LESSOPEN=| /usr/bin/lesspipe %s
LESSCLOSE=/usr/bin/lesspipe %s %s
RUBY_VERSION=ruby-1.9.3-p392
_system_name=Ubuntu
_=/usr/bin/env

我还尝试了以下命令,以查找潜在的符号链接循环:

I have also tried commands like the following, to find potential symlink loops:

find . -maxdepth 20 -type l -exec ls -ld {} +

但未产生正确的结果:

lrwxrwxrwx 1 deployer deployer ...

推荐答案

您可能没有使用相同的 ln 实用工具.

You might not being using the same ln utility.

直接从交互式外壳调用它时, ln 可能会被覆盖,例如通过 alias 或通过某些shell函数 ln(){...;} .

When invoking it directly from the interactive shell, ln might be overridden e.g. by an alias or by some shell function ln() {...;}.

/usr/bin/env 尝试执行此操作时不会发生这种情况(AFAIK会在 PATH 中查找 ln .).我怀疑它找到的 ln 存在问题,所以您遇到此错误.

This does not happen when /usr/bin/env tries to do that (AFAIK it looks for ln in PATH). I suspect that the ln it finds has issues, so you are getting this error.

这是一个示例场景,可能与您的情况类似:

This is an example scenario that might be similar to your case:

# start from an empty directory
$ ls -l
total 0
# create a problematic `ln` in the current directory
$ ln -s ln ln
$ ls -l
total 0
lrwxrwxrwx 1 me me 2 Jan  7 20:28 ln -> ln
# have an alias for the "real" ln
$ alias ln=/bin/ln
# mess up PATH
$ PATH="$PWD"

现在让我们尝试两种选择,首先是/usr/bin/env :

Now let's try the two alternatives, /usr/bin/env goes first:

$ /usr/bin/env ln -s /some/path /tmp/path
/usr/bin/env: ln: Too many levels of symbolic links

然后是普通的 ln (请记住我们对其进行了 alias 别名)

Then plain ln (remember that we aliased it):

$ ln -s /some/path /tmp/path
$ echo $?
0
$ /bin/ls -l /tmp/path
lrwxrwxrwx 1 me me 10 Jan  7 20:31 /tmp/path -> /some/path

所以我的建议是:研究 ln 的问题,例如通过找到所有可能可见的替代方法.在 bash 中,您可以运行以下命令:

So my suggestion is: look at issues with ln, e.g. by finding all different alternatives that might be visible. In bash you might run this:

$ type -a ln

这篇关于/usr/bin/env:ln:符号链接级别过多的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆