Bash 终端显示';没有这样的文件或目录';对于启动时的PATH变量
当我启动终端时,我收到以下消息:Bash 终端显示';没有这样的文件或目录';对于启动时的PATH变量,bash,path-variables,Bash,Path Variables,当我启动终端时,我收到以下消息: bash: cd: PATH=/Users/ryan/Users/ryan/Documents/Pebble-Dev/PebbleSDK-2.0-BETA3/bin:/Users/ryan/pebble-dev/PebbleSDK-2.0-BETA4/bin:/Users/ryan/.rvm/gems/ruby-2.0.0-head/bin:/Users/ryan/.rvm/gems/ruby-2.0.0-head@global/bin:/Users/ryan/
bash: cd: PATH=/Users/ryan/Users/ryan/Documents/Pebble-Dev/PebbleSDK-2.0-BETA3/bin:/Users/ryan/pebble-dev/PebbleSDK-2.0-BETA4/bin:/Users/ryan/.rvm/gems/ruby-2.0.0-head/bin:/Users/ryan/.rvm/gems/ruby-2.0.0-head@global/bin:/Users/ryan/.rvm/rubies/ruby-2.0.0-head/bin:/Users/ryan/.rvm/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin: No such file or directory
我意识到有多个SDK,第一个SDK的路径肯定是错误的。找不到从何处提取
另外,当我在终端中键入echo$PATH
时,我得到:
/Users/ryan/pebble-dev/PebbleSDK-2.0-BETA4/bin:/Users/ryan/pebble-dev/PebbleSDK-2.0-BETA4/bin:/Users/ryan/pebble-dev/PebbleSDK-2.0-BETA4/bin:/Users/ryan/Documents/Pebble-Dev/PebbleSDK-2.0-BETA3/bin:/Users/ryan/pebble-dev/PebbleSDK-2.0-BETA4/bin:/Users/ryan/.rvm/gems/ruby-2.0.0-head/bin:/Users/ryan/.rvm/gems/ruby-2.0.0-head@global/bin:/Users/ryan/.rvm/rubies/ruby-2.0.0-head/bin:/Users/ryan/.rvm/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
这也是不对的,因为它有更多的SDK
我有三个问题:
1) 初始路径从何而来?
2) echo$PATH
从何处提取?
3为什么它们不同
谢谢
更新1:
这是我在/etc/bashrc
中看到的:
# System-wide .bashrc file for interactive bash(1) shells.
if [ -z "$PS1" ]; then
return
fi
PS1='\h:\W \u\$ '
# Make bash check its window size after a process completes
shopt -s checkwinsize
# Tell the terminal about the working directory at each prompt.
if [ "$TERM_PROGRAM" == "Apple_Terminal" ] && [ -z "$INSIDE_EMACS" ]; then
update_terminal_cwd() {
# Identify the directory using a "file:" scheme URL,
# including the host name to disambiguate local vs.
# remote connections. Percent-escape spaces.
local SEARCH=' '
local REPLACE='%20'
local PWD_URL="file://$HOSTNAME${PWD//$SEARCH/$REPLACE}"
printf '\e]7;%s\a' "$PWD_URL"
}
PROMPT_COMMAND="update_terminal_cwd; $PROMPT_COMMAND"
fi
这是我在/etc/profile
中看到的:
# System-wide .profile for sh(1)
if [ -x /usr/libexec/path_helper ]; then
eval `/usr/libexec/path_helper -s`
fi
if [ "${BASH-no}" != "no" ]; then
[ -r /etc/bashrc ] && . /etc/bashrc
fi
您提到的
.bashrc
、.bash\u profile
和.profile
文件在哪里?检查~/.bashrc
或.bash\u profile
以获取作为cd
参数传递赋值的代码路径=…
,真正的问题是,在您的配置文件中,您试图将分配传递给路径
作为cd
的参数吗?我不知道……这不是我的机器上发生的。我可以从哪里开始寻找呢?.bashrc
、.bash\u profile
和。profile
将是很好的起点。不太可能,但可能是系统文件,如/etc/profile
和/etc/bashrc
@chepner,更新了我关于您上次评论的问题。它们将位于您的主目录中,即您启动新终端时所在的目录。您能否在此基础上展开?我对Unix终端相当陌生,并且理解您所说的“将赋值路径作为参数传递给cd的代码”是什么意思。如果启动文件包含类似于cd PATH=…
的行,shell会将其解释为请求将工作目录更改为名为PATH=…
的目录。