안녕하세요, Ruby를 1.9.3으로 업데이트하려고 하는데 Mac Os 10.6.8에서 터미널 창을 열고 있는데 터미널을 열자마자 터미널에서 다음과 같은 응답이 표시됩니다.
-bash: export: /Library/Frameworks/Python.framework/Versions/Current/bin': not a valid identifier
-bash: export:/Library/Frameworks/Python.framework/Versions/2.7/bin': not a valid identifier
-bash: export: /Library/Frameworks/Python.framework/Versions/Current/bin': not a valid identifier
-bash: export:/Library/Frameworks/Python.framework/Versions/Current/bin': not a valid identifier
-bash: export: /usr/bin': not a valid identifier
-bash: export:/bin': not a valid identifier
-bash: export: /usr/sbin': not a valid identifier
-bash: export:/sbin': not a valid identifier
-bash: export: /usr/local/bin': not a valid identifier
-bash: export:/usr/local/git/bin': not a valid identifier
-bash: export: /usr/X11/bin': not a valid identifier
-bash: export:/Users/oskarniburski/.rvm/bin': not a valid identifier
-bash: export: /usr/X11R6/bin': not a valid identifier
-bash: export:/Library/Frameworks/Python.framework/Versions/Current/bin': not a valid identifier
-bash: export: /Library/Frameworks/Python.framework/Versions/2.7/bin': not a valid identifier
-bash: export:/Library/Frameworks/Python.framework/Versions/Current/bin': not a valid identifier
-bash: export: /Library/Frameworks/Python.framework/Versions/Current/bin': not a valid identifier
-bash: export:/usr/bin': not a valid identifier
-bash: export: /bin': not a valid identifier
-bash: export:/usr/sbin': not a valid identifier
-bash: export: /sbin': not a valid identifier
-bash: export:/usr/local/bin': not a valid identifier
-bash: export: /usr/local/git/bin': not a valid identifier
-bash: export:/usr/X11/bin': not a valid identifier
-bash: export: /Users/oskarniburski/.rvm/bin': not a valid identifier
-bash: export:/usr/X11R6/bin': not a valid identifier
나는 진로를 바꾸려고 노력했지만 소용이 없었다. 나는 이 문제를 해결하는 방법을 모르고 수많은 포럼을 읽었습니다. 어떤 아이디어가 있나요?
이것은 bash_profile입니다:
$ /bin/cat ~/.bash_profile
# Setting PATH for MacPython 2.5
# The orginal version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/Current/bin:${PATH}"
export PATH
# Setting PATH for MacPython 2.5
# The orginal version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/Current/bin:${PATH}"
export PATH
# Setting PATH for Python 2.7
# The orginal version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"
export PATH
# Setting PATH for EPD_free-7.3-2
# The orginal version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/Current/bin:${PATH}"
export PATH
# Setting PATH for Python 3.3
# The orginal version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.3/bin:${PATH}"
export PATH
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
export PATH=/usr/local/bin:/Library/Frameworks/Python.framework/Versions/3.3/bin /Library/Frameworks/Python.framework/Versions/Current/bin /Library/Frameworks/Python.framework/Versions/2.7/bin /Library/Frameworks/Python.framework/Versions/Current/bin /Library/Frameworks/Python.framework/Versions/Current/bin /usr/bin /bin /usr/sbin /sbin /usr/local/bin /usr/local/git/bin /usr/X11/bin /Users/oskarniburski/.rvm/bin /usr/X11R6/bin
export PATH=/usr/local/bin:/Library/Frameworks/Python.framework/Versions/3.3/bin /Library/Frameworks/Python.framework/Versions/Current/bin /Library/Frameworks/Python.framework/Versions/2.7/bin /Library/Frameworks/Python.framework/Versions/Current/bin /Library/Frameworks/Python.framework/Versions/Current/bin /usr/bin /bin /usr/sbin /sbin /usr/local/bin /usr/local/git/bin /usr/X11/bin /Users/oskarniburski/.rvm/bin /usr/X11R6/bin
##
# Your previous /Users/oskarniburski/.bash_profile file was backed up as /Users/oskarniburski/.bash_profile.macports-saved_2013-09-26_at_17:32:30
##
# MacPorts Installer addition on 2013-09-26_at_17:32:30: adding an appropriate PATH variable for use with MacPorts.
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
# Finished adapting your PATH environment variable for use with MacPorts.
답변1
자, 여기서 가장 큰 문제는 디렉토리 항목을 구분하는 공백이 있고 $PATH
참조되지 않는 변수에도 공백이 있어서 bash
.
이 경우 원하는 작업은 경로에 디렉터리를 추가하는 것입니다. 올바른 구문은 입니다 PATH="/foo:/bar/baz:$PATH
. end $PATH
to end는 현재 값이 변수 끝에 추가되어 이미 존재하는 값을 덮어쓰지 않음을 의미합니다. 의 디렉터리는 $PATH
순차적으로 읽혀지므로 새 디렉터리를 마지막으로 검색하려면 다음을 시작 부분에 추가하세요 PATH="$PATH:/foo:/bar"
.
또 다른 문제는 중복된 경로가 많다는 것입니다. 다음을 실행하여 찾을 수 있습니다.
$ echo $PATH | perl -pne 's/:/\n/g' | sort | uniq -d
/bin
/Library/Frameworks/Python.framework/Versions/2.7/bin
/Library/Frameworks/Python.framework/Versions/3.3/bin
/Library/Frameworks/Python.framework/Versions/Current/bin
/sbin
/usr/bin
/usr/local/bin
/usr/sbin
마지막으로 여러 번 내보내는 것은 $PATH
의미가 없습니다. 중복 항목을 모두 제거하고 구문을 수정한 결과 다음과 같이 되었습니다.
# Setting PATH for MacPython 2.5
# The orginal version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/Current/bin:${PATH}"
# Setting PATH for Python 2.7
# The orginal version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"
# Setting PATH for Python 3.3
# The orginal version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.3/bin:${PATH}"
# Load RVM into a shell session *as a function*
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
PATH="/usr/local/git/bin:/usr/X11/bin:/Users/oskarniburski/.rvm/bin:/usr/X11R6/bin:$PATH"
##
# Your previous /Users/oskarniburski/.bash_profile file was backed up
# as /Users/oskarniburski/.bash_profile.macports-saved_2013-09-26_at_17:32:30
##
# MacPorts Installer addition on 2013-09-26_at_17:32:30: adding an appropriate PATH
# variable for use with MacPorts.
export PATH="/opt/local/bin:/opt/local/sbin:$PATH"
# Finished adapting your PATH environment variable for use with MacPorts.
파일을 복사하고 터미널을 열고 다음 명령을 실행하십시오.
/bin/cp ~/.bash_profile ~/bash_profile.bad
/bin/cat > ~/.bash_profile
첫 번째는 ~/.bash_profile
만일을 대비해 현재 데이터를 백업합니다. 두 번째는 아무것도 하지 않는 것처럼 보이지만 쓰기용으로 열립니다 ~/.bash_profile
. 위에서 제공한 내용을 터미널에 직접 붙여넣고 을 클릭하고 Enter을 클릭 하세요 CtrlC. 이렇게 하면 모든 것이 정상으로 돌아갑니다.
참고: /bin
귀하는 에 있습니다 /sbin
. 이는 이미 귀하의 것이므로 추가할 필요가 없습니다. 누락된 경우(현재 값 참조) 위에서 설명한 구문을 사용하여 추가하면 됩니다./usr/bin
/usr/local/bin
.bash_profile
$PATH
echo $PATH