-bash: /usr/bin/mvn: Too many levels of symbolic links
Posted 陌上花开
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了-bash: /usr/bin/mvn: Too many levels of symbolic links相关的知识,希望对你有一定的参考价值。
问题背景:
root 用户安装了maven,切换到jenkins 用户可以正常执行mvn 命令,但是jenkins job 构建任务却无法执行mvn命令,报错如下:/bin/sh: 1: mvn: not found
1、root用户安装maven
root# mvn -v Apache Maven 3.5.2 (138edd61fd100ec658bfa2d307c43b76940a5d7d; 2017-10-18T07:58:13Z) Maven home: /usr/share/maven Java version: 1.8.0_151, vendor: Oracle Corporation Java home: /usr/java/jdk1.8.0_151/jre Default locale: en_US, platform encoding: UTF-8 OS name: "linux", version: "3.13.0-135-generic", arch: "amd64", family: "unix"
2、root用户配置/etc/profile 文件,并source 使配置生效
export M2_HOME=/usr/share/maven
export PATH=$PATH:${M2_HOME}/bin
3、切换到ubuntu用户执行mvn命令,报错
[email protected]$ whereis mvn mvn: /usr/bin/mvn /usr/bin/X11/mvn /usr/share/man/man1/mvn.1.gz [email protected]$ /usr/bin/mvn -v -bash: /usr/bin/mvn: Too many levels of symbolic links
4、root用户下查看/usr/bin/mvn 软连接信息
[email protected]# whereis mvn mvn: /usr/bin/mvn /usr/bin/X11/mvn /usr/share/man/man1/mvn.1.gz
[email protected]# ll /usr/bin/mvn lrwxrwxrwx 1 root root 3 Dec 8 13:44 /usr/bin/mvn -> mvn
5、更改软连接方式
[email protected]# rm -f /usr/bin/mvn [email protected]# ln -s /usr/share/maven/bin/mvn /usr/bin/mvn [email protected]# ll /usr/bin/mvn lrwxrwxrwx 1 root root 24 Dec 8 13:47 /usr/bin/mvn -> /usr/share/maven/bin/mvn*
6、ubuntu用户下再次验证
[email protected]$ mvn -v Apache Maven 3.5.2 (138edd61fd100ec658bfa2d307c43b76940a5d7d; 2017-10-18T07:58:13Z) Maven home: /usr/share/maven Java version: 1.8.0_151, vendor: Oracle Corporation Java home: /usr/java/jdk1.8.0_151/jre Default locale: en_US, platform encoding: UTF-8 OS name: "linux", version: "3.13.0-135-generic", arch: "amd64", family: "unix"
总结:
建立软连接的时候,尽量采用绝对路径,避免采用相对路径建立软链接。
以上是关于-bash: /usr/bin/mvn: Too many levels of symbolic links的主要内容,如果未能解决你的问题,请参考以下文章
ActiveMQ Channel was inactive for too long: localhost/127.0.0.1:8161
如何处理 R0915: Too many statements (69/50) (too-many-statements) in pylint?