我有一个程序.path.py
,它打印一个导出命令PATH
。在我的程序中,.bashrc
我在顶部有一个条目$(python $HOME/.prefix/.path.py)
,但当我通过 ssh 登录时,甚至运行source $HOME/.bashrc
这些路径都不会导出。手动运行$(python $HOME/.prefix/.path.py)
可以正常工作。在我使用过的其他 Linux 系统上,这种方法通常可以正常工作,只是在我的 Ubuntu 14.04 桌面上不行。
有人能帮我解决这个问题吗?评论中提供任何有用的附加信息。请注意,此文本中没有换行符,只有空格。
export PATH=/home/username/.prefix/calc/bin:/home/username/.prefix/misc/bin:/home/username/.prefix/testu01/bin:/home/username/.prefix/calc/bin:/home/username/.prefix/misc/bin:/home/username/.prefix/testu01/bin:/home/username/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/opt/intel/bin/ CPLUS_INCLUDE_PATH=/home/username/.prefix/calc/include:/home/username/.prefix/misc/include:/home/username/.prefix/testu01/include:/home/username/.prefix/calc/include:/home/username/.prefix/misc/include:/home/username/.prefix/testu01/include:/home/username/.prefix/calc/include:/home/username/.prefix/misc/include:/home/username/.prefix/testu01/include: LIBRARY_PATH=/home/username/.prefix/calc/lib:/home/username/.prefix/calc/lib64:/home/username/.prefix/misc/lib:/home/username/.prefix/misc/lib64:/home/username/.prefix/testu01/lib:/home/username/.prefix/testu01/lib64:/home/username/.prefix/calc/lib:/home/username/.prefix/calc/lib64:/home/username/.prefix/misc/lib:/home/username/.prefix/misc/lib64:/home/username/.prefix/testu01/lib:/home/username/.prefix/testu01/lib64:/home/username/.prefix/calc/lib:/home/username/.prefix/calc/lib64:/home/username/.prefix/misc/lib:/home/username/.prefix/misc/lib64:/home/username/.prefix/testu01/lib:/home/username/.prefix/testu01/lib64: C_INCLUDE_PATH=/home/username/.prefix/calc/include:/home/username/.prefix/misc/include:/home/username/.prefix/testu01/include:/home/username/.prefix/calc/include:/home/username/.prefix/misc/include:/home/username/.prefix/testu01/include:/home/username/.prefix/calc/include:/home/username/.prefix/misc/include:/home/username/.prefix/testu01/include: LD_LIBRARY_PATH=/home/username/.prefix/calc/lib:/home/username/.prefix/calc/lib64:/home/username/.prefix/misc/lib:/home/username/.prefix/misc/lib64:/home/username/.prefix/testu01/lib:/home/username/.prefix/testu01/lib64:/home/username/.prefix/calc/lib:/home/username/.prefix/calc/lib64:/home/username/.prefix/misc/lib:/home/username/.prefix/misc/lib64:/home/username/.prefix/testu01/lib:/home/username/.prefix/testu01/lib64:/home/username/.prefix/calc/lib:/home/username/.prefix/calc/lib64:/home/username/.prefix/misc/lib:/home/username/.prefix/misc/lib64:/home/username/.prefix/testu01/lib:/home/username/.prefix/testu01/lib64:
答案1
~/.bashrc
仅适用于非登录 shell,因此当您使用 ssh 登录时不会获取它。
改用.bash_profile
。
有关的: http://www.joshstaiger.org/archives/2005/07/bash_profile_vs.html
答案2
在 Ubuntu 上,此方法确实有效。但是,默认设置中有一行.bashrc
设置了 PATH,但没有现有 PATH。我的脚本需要移至 的底部.bashrc
。