我在.bashrc文件中添加了scala,但是当我关闭我的mac并将其重新打开时,它找不到它。当我做的时候
source ~/.bashrc
一切都恢复正常了。我会说问题一般是整个文件,但问题是,我还有其他的东西在之前工作得很好,但问题是scala持续存在。有谁知道这是为什么并解释我为什么会遇到这个问题?这是我的.bashrc文件中的内容,它正确运行rvm和mysql,但不是scala:
PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
export PATH="/usr/local/mysql/bin:$PATH"
export PATH="/Users/Zeroe/scala-2.9.1-1/bin:$PATH"
答案 0 :(得分:34)
我通过向这些脚本添加echo "${BASH_SOURCE[0]}"
来找出此图表。
+-----------------+ +------FIRST-------+ +-----------------+
| | | ~/.bash_profile | | |
login shell -------->| /etc/profile |-->| ~/.bash_login ------>| ~/.bashrc |
| | | ~/.profile | | |
+-----------------+ +------------------+ +-----------------+
+-----------------+ +-----------------+
| | | |
interactive shell -->| ~/.bashrc -------->| /etc/bashrc |
| | | |
+-----------------+ +-----------------+
+-----------------+
| |
logout shell ------->| ~/.bash_logout |
| |
+-----------------+
注意强>
[]-->[]
表示 source by workflow
(自动)。[--->[]
表示 source by convention
(手动。如果没有,没有任何事情发生。)。FIRST
表示 find the first available, ignore rest
答案 1 :(得分:6)
您的shell可能是一个登录shell,在这种情况下,bash将按顺序读取各种配置文件:
/etc/profile
~/.bash_profile
~/.bash_login
~/.profile
通常从其中一个文件中获取~/.bashrc
,因此您也可以获得相同的登录shell配置。
这是我的~/.profile
包含的内容:
# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.
# the default umask is set in /etc/profile; for setting the umask
# for ssh logins, install and configure the libpam-umask package.
#umask 022
# if running bash
if [ -n "$BASH_VERSION" ]; then
# include .bashrc if it exists
if [ -f "$HOME/.bashrc" ]; then
. "$HOME/.bashrc"
fi
fi
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi
export LANGUAGE="en_US:en"
export LC_MESSAGES="en_US.UTF-8"
export LC_CTYPE="en_US.UTF-8"
export LC_COLLATE="en_US.UTF-8"