我已经安装nvm并将其附加到我的/home/www-data/.bashrc
打电话nvm有效。
bash
nvm
Run Code Online (Sandbox Code Playgroud)
作品
但
$ bash -c nvm
bash: nvm: command not found
Run Code Online (Sandbox Code Playgroud)
不起作用。
当我指定 rcfile 时也是如此
$ bash --rcfile /home/www-data/.bashrc -c "nvm"
bash: nvm: command not found
Run Code Online (Sandbox Code Playgroud)
这是为什么?
在最终结果中,我想在 RoboFile exec() 命令中使用 nvm 并尝试将其包装到其中,bash -c因为nvm它是一个 bash 函数而不是真正的脚本。
这是为什么?
当使用 调用时-c,bash 作为非交互式shell 运行。不读取默认的交互式 shell 启动文件 ( /etc/bash.bashrc、 )。~/.bashrc即使您强制~/.bashrc读取,其主体也可能不会被执行 - 例如,默认的 Ubuntu 主体(在帐户创建期间从 /etc/skel 复制)包括以下行
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
Run Code Online (Sandbox Code Playgroud)
它绕过了以下所有内容。
您可以强制使用交互式 shell bash -ic,但这可能会导致其他问题,具体取决于您的.bashrc.
| 归档时间: |
|
| 查看次数: |
520 次 |
| 最近记录: |