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

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

First, a problem arose when upgrading to Capistrano 3. Capistrano now uses / usr / bin / env before each command when deploying to make sure the environment setting is correct.

When Capistrano is sent to create symbolic links to the necessary shared directory and related files, it tries to execute commands like:

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

... and then it throws errors:

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

I understand that this is not a Capistrano error, so I started troubleshooting with ssh'ing on my server and trying the same command and I get the same error (which is at least good for consistency). Then I try to execute the same command without / usr / bin / env:

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

And it works !!!! Maybe you see a real solution that I can’t?

only the / usr / bin / env command is output here:

 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 also tried commands like the following to find potential link loops:

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

But does not give the correct results:

 lrwxrwxrwx 1 deployer deployer ... 
+5
source share
2 answers

You may not be using the same ln utility.

When called directly from the interactive shell, ln can be canceled, for example. using alias or some shell function ln() {...;} .

This does not happen when /usr/bin/env tries to do this (AFAIK looks for ln in PATH ). I suspect that the detected ln has problems, so you get this error.

This is an example script that might look like 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" 

Now try 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 

Then just ln (remember that we are alias ed 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 

So my suggestion is: look at ln issues, for example. by searching for all the various alternatives that may be visible. In bash you can run this:

 $ type -a ln 
+1
source

Try to find symbolic link loops:

 find . -follow -printf "" 
0
source

Source: https://habr.com/ru/post/1209141/


All Articles