Mac终端错误:-bash:/Users/tim/.profile:没有这样的文件或目录

时间:2016-10-20 14:34:59

标签: terminal

每次打开新的终端窗口时,我都会看到以下内容。

<div id="container">
    <div>1</div>
    <div>2</div>
    <div>3</div>
    <div>4</div>
    <div>5</div>
    <div>6</div>
    <div>7</div>
    <div>8</div>
    <div>9</div>
    <div>10</div>
</div>

我不知道为什么会发生这种情况或在哪里寻找解决方法;我的个人资料位于-bash: /Users/tim/.profile: No such file or directory 而不是/Users/tim/.bash_profile

有关如何解决此问题的任何想法?

4 个答案:

答案 0 :(得分:30)

这也发生在我身上,我注意到我.bash_profile的顶部有:

source ~/.profile

我的理解是,在MacOS / OS X上,.bash_profile优先于.profile,因此不需要后一个文件。

要修复,我只需从文件顶部删除source ~/.profile

希望有所帮助。

编辑:原创海报评论说他刚刚创建了一个空白.profile来解决这个问题。

答案 1 :(得分:3)

我今天遇到了同样的问题,我猜这是因为我使用清洁应用程序,并且该应用程序认为此文件浪费空间,因此将其删除。 touch ~/.profile可以帮助我。

答案 2 :(得分:2)

我在切换到 M1 芯片 MacBook 后遇到了这个问题。我找到了解决方案,按照以下步骤应该可以解决问题:

第一个:将以下代码添加到 ~/.bash_profile(只需在终端中运行此代码)

export NVM_DIR="$HOME/.nvm"

[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm

[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion

第二:在终端中运行以下代码

source ~/.bash_profile

这应该可以解决问题,您可以检查 nvm -v。但是,如果问题仍然存在,请尝试以下步骤:

打开~/.zshrc文件,在文件顶部添加以下代码并保存。

source ~/.bash_profile

source ~/.zshrc

(如果您不知道如何访问 ~/.zshrc 在它前面添加任何代码编辑器在终端中,我使用 VS 代码因此代码 ~/.zshrc)。 这应该可以解决问题。

答案 3 :(得分:0)

只需打开.bash_profile文件并在第一行中注释。

就我而言

source ~/.profile
export PATH="/usr/local/sbin:$PATH"

#source ~/.profile
export PATH="/usr/local/sbin:$PATH"

另一种方法是您仅在以下文件夹中的同一文件夹中创建文件 。 bash_profile 存在。

但是,如果您出于任何目的不需要.profile的话,第一个就不错了

相关问题