systemd prepending /bin to Environment PATH

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-22 00:28:54

问题


I'm trying to setup my Bamboo agents as a systemd service. The service file looks like this:

[Unit]
Description=Atlassian Bamboo Agent
After=syslog.target network.target

[Service]
Type=forking
User=bamboo
Group=bamboo
ExecStart=/opt/bamboo-1/bin/bamboo-agent.sh start
ExecStop=/opt/bamboo-1/bin/bamboo-agent.sh stop
Environment="PATH=/opt/rh/devtoolset-3/root/bin/:/usr/local/bin:/usr/bin"

[Install]
WantedBy=multi-user.target

When I check the process environment, the PATH is correctly set to what I expect, with with the only exception that my PATH is prepended with /bin.

cat /proc/12345/environ <--- 12345 is my Bamboo PID
...
PATH=/bin:/opt/rh/devtoolset-3/root/bin/:/usr/local/bin:/usr/bin
...

That means my builds will use the wrong gcc, cmake, etc.

Is there any way to prevent /bin to be prepended to the PATH?


回答1:


I created a test service that just printed out the path after setting Environment= with a new path, and found it worked as expected on Ubuntu 16.04 with systemd 229.

I conclude that something in your script is pre-pending /bin to your environment.

Nothing in the systemd.exec man page suggests that systemd is designed to behave the way you observe.



来源:https://stackoverflow.com/questions/39576006/systemd-prepending-bin-to-environment-path

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!