bash: ~/.bash_profile: 没有那个文件或目录

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26289176/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 21:42:02  来源:igfitidea点击:

bash: ~/.bash_profile: No such file or directory

bash

提问by Mohamed El Mahallawy

I keep getting this error:

我不断收到此错误:

bash: ~/.bash_profile: No such file or directory

Here is my bash_profile:

这是我的 bash_profile:

alias ngrok=/Users/mmahalwy/Desktop/Code/ngrok

export CLICOLOR=1
export LSCOLORS=GxFxCxDxBxegedabagaced

alias ls='ls -GFh'

function prompt {
??local BLACK="\[3[0;30m\]"
??local BLACKBOLD="\[3[1;30m\]"
??local RED="\[3[0;31m\]"
??local REDBOLD="\[3[1;31m\]"
??local GREEN="\[3[0;32m\]"
??local GREENBOLD="\[3[1;32m\]"
??local YELLOW="\[3[0;33m\]"
??local YELLOWBOLD="\[3[1;33m\]"
??local BLUE="\[3[0;34m\]"
??local BLUEBOLD="\[3[1;34m\]"
??local PURPLE="\[3[0;35m\]"
??local PURPLEBOLD="\[3[1;35m\]"
??local CYAN="\[3[0;36m\]"
??local CYANBOLD="\[3[1;36m\]"
??local WHITE="\[3[0;37m\]"
??local WHITEBOLD="\[3[1;37m\]"
??local RESETCOLOR="\[\e[00m\]"

??export PS1="\n$RED\u $PURPLE@ $GREEN\w $BLUE[\#] → $RESETCOLOR"
??export PS2="| → $RESETCOLOR"
}

# prompt

export PATH=/usr/local/bin:$PATH

source ~/.git-completion.bash

if [ -f `brew --prefix`/etc/bash_completion ]; then
    . `brew --prefix`/etc/bash_completion
fi


source ~/.profile
source /Users/mmahalwy/.iterm2_shell_integration.bash

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*

UPDATE

更新

The problem was a trailing "~/.bash_profile" 38L, 1070Cwhich I had copied by mistake from vim. Thanks for the help!

问题是"~/.bash_profile" 38L, 1070C我错误地从 vim 复制的尾随。谢谢您的帮助!

回答by PersianGulf

Bash has ~/.profileinstead of ~/.bash_profile

Bash~/.profile代替了~/.bash_profile

Content of ~/.profile:

内容~/.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

回答by Mohamed El Mahallawy

UPDATE

更新

The problem was a trailing "~/.bash_profile" 38L, 1070C which I had copied by mistake from vim. Thanks for the help!

问题是尾随的“~/.bash_profile” 38L, 1070C 是我错误地从 vim 复制的。谢谢您的帮助!

回答by Kiran Jasvanee

In my case I was receiving the following error.

就我而言,我收到以下错误。

-bash: /Users/mac241/.rvm/scripts/rvm: No such file or directory
-bash: /Users/mac241/.rvm/scripts/rvm: No such file or directory

After few checks, I got to know when I created .bash_profilefile, below two commands already was prewritten on the file.

经过几次检查,我知道什么时候创建.bash_profile文件,下面两个命令已经预先写在文件上。

source /Users/mac241/.rvm/scripts/rvm
source /Users/mac241/.rvm/scripts/rvm  

based on error, I got to know this are the problems and after I removed, It started working. Hope you are written and defined those commands only which you required to auto run up on shell start.

基于错误,我知道这是问题所在,删除后,它开始工作。希望您只编写和定义了在 shell 启动时自动运行所需的那些命令。