2012-03-31 48 views
3

我在我的.bashrc文件中添加了scala,但是当我关闭我的mac并重新打开时,它找不到它。当我做主目录中的.bashrc是否应该自动加载?

source ~/.bashrc 

一切恢复正常。我会说整个文件的问题一般,但问题是,我有其他的东西在那里工作得很好,但问题是持续与scala。有人知道这是为什么,并解释为什么我得到这个问题?这是什么在我的.bashrc文件,其正常运行RVM和MySQL,但不斯卡拉:

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" 
+2

参见[这里](http://apple.stackexchange.com/questions/12993/why-doesnt-bashrc-run-automatically)。 – ughoavgfhw 2012-03-31 04:34:48

+0

嗯,非常感谢链接。当我有机会时,我会尝试。绝对把它作为一个答案,所以我可以接受它,如果它的工作。 – Andy 2012-03-31 04:39:06

回答

6

你的shell可能是一个登录shell,在这种情况下,bash将在顺序读取各种配置文件的文件:

  1. /etc/profile
  2. ~/.bash_profile
  3. ~/.bash_login
  4. ~/.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" 
26

我加入echo "${BASH_SOURCE[0]}"对这些脚本想通了这张图。

     +-----------------+ +------FIRST-------+ +-----------------+ 
        |     | | ~/.bash_profile | |     | 
login shell -------->| /etc/profile |-->| ~/.bash_login ------>| ~/.bashrc  | 
        |     | | ~/.profile  | |     | 
        +-----------------+ +------------------+ +-----------------+ 
        +-----------------+ +-----------------+ 
        |     | |     | 
interactive shell -->| ~/.bashrc -------->| /etc/bashrc  | 
        |     | |     | 
        +-----------------+ +-----------------+ 
        +-----------------+ 
        |     | 
logout shell ------->| ~/.bash_logout | 
        |     | 
        +-----------------+ 

  1. []-->[]装置source by workflow(自动)。
  2. [--->[]表示source by convention(手动。如果没有,没有任何事情发生。)。
  3. FIRST装置find the first available, ignore rest
+0

这确实是一个很好的答案。 – 2012-03-31 08:39:59

+0

不错的图片 - 比通常在这个东西上看到的文本文档的墙更好。 – 2012-04-07 06:47:43

相关问题