为什么 maven 使用“?"?作为我的主目录 [英] Why does maven use "?" as my home directory
问题描述
有谁知道为什么在 Centos 5.x 上的 maven 无法找到用户设置,除非我使用-s"?
Does anyone know why maven on Centos 5.x can't find user settings unless I use '-s'?
- 主页设置为/home/build
- $HOME/.m2/settings.xml 存在,归用户所有,用户可以读取
- 我正在使用全新下载的 mvn 3.0.4(3.0.3 也失败)
我怀疑我的环境中有些东西妨碍了我,但我不确定是什么.
I suspect something in my environment is getting in the way, but I'm not sure what.
找不到用户设置 -- 未使用-s"
[build@...]$ echo $HOME; mvn clean -X|grep setting
/home/build
[DEBUG] Reading global settings from .../apache-maven-3.0.4/conf/settings.xml
[DEBUG] Reading user settings from ?/.m2/settings.xml
[DEBUG] Imported: org.apache.maven.settings < plexus.core
查找用户设置 -- 使用了-s"
[build@...]$ echo $HOME; mvn clean -X -s $HOME/.m2/settings.xml|grep setting
/home/build
[DEBUG] Reading global settings from .../apache-maven-3.0.4/conf/settings.xml
[DEBUG] Reading user settings from /home/build/.m2/settings.xml
[DEBUG] Imported: org.apache.maven.settings < plexus.core
谢谢
彼得
推荐答案
"su" 命令是这个特定问题的核心.su"可以作为另一个用户执行命令.在不带 "-" 的情况下使用时,它不会处理用于该用途的启动脚本,这在某些情况下会导致混合环境.
"su" command lies at the core of this particular issue. "su" can execute commands as another user. When used without the "-" it doesn't process startup scripts for that use which can lead to hybrid environments in some cases.
在编写 init.d 启动脚本时,请务必在调用命令时使用su -",否则您的构建系统用户将使用 root 用户的环境变量(包括 HOME)执行
When writing an init.d startup script be sure to use "su -" when invoking commands or your build system user will execute using root user's environment variables (HOME included)
某些操作系统的问题,因为 BAMBOO_USER 在 root 用户的环境下运行
su $BAMBOO_USER -c "cd ${BAMBOO_HOME}; nohup java -Dbamboo.home=${BAMBOO_HOME} ... &"
更合适的init.d脚本
su - $BAMBOO_USER -c "cd ${BAMBOO_HOME}; nohup java -Dbamboo.home=${BAMBOO_HOME} ... &"
这篇关于为什么 maven 使用“?"?作为我的主目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!