我有一个bash脚本,安装rbenv
到/usr/local
,并将所需的环境变量添加到/etc/profile
。我的用户是root
:bash脚本中的源/ etc/profile
#!/bin/bash
exec {log_fd}>log.txt
git clone https://github.com/rbenv/rbenv.git /usr/local/rbenv >&$log_fd 2>&1
git clone https://github.com/rbenv/ruby-build.git /usr/local/rbenv/plugins/ruby-build >&$log_fd 2>&1
echo 'export RBENV_ROOT=/usr/local/rbenv' >> /etc/profile >&$log_fd 2>&1
echo 'export PATH="/usr/local/rbenv/bin:$PATH"' >> /etc/profile >&$log_fd 2>&1
echo 'if which rbenv > /dev/null; then eval "$(rbenv init - --no-rehash)"; fi' >> /etc/profile >&$log_fd 2>&1
. /etc/profile
然而,PATH变量没有被导出,因为它应该,但RBENV_ROOT是!
~#: printenv
RBENV_ROOT=/usr/local/rbenv
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
MAIL=/var/mail/root
LANG=en_US.UTF-8
RBENV_SHELL=bash
我希望看到/usr/local/rbenv/
作为路径的一部分,对不对?
我也试着开关了语法添加的路径,但是这并没有帮助:
echo 'export PATH=$PATH:/usr/local/rbenv/bin' >> /etc/profile 2>&1
在你想知道的情况下,我将输出重定向,因为这是所有的内一个whiptail菜单。
那么,为什么要显示一个变量RBENV_ROOT
,但不是我所谓的更新PATH
?
这就是我正在处理的问题......我可以从相同的脚本中获取它,因此我不必启动新的登录shell? – Godzilla74
可以'rbenv init - --no-rehash'重置'PATH' ?! –