![Los comandos Bash no funcionan en Mac](https://rvso.com/image/50592/Los%20comandos%20Bash%20no%20funcionan%20en%20Mac.png)
Hola, abro la ventana de mi terminal en Mac Os 10.6.8 mientras intento actualizar mi Ruby a 1.9.3 y el terminal me da esta respuesta inmediatamente cuando lo abro:
-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
Intenté cambiar mi camino pero no funcionó. No estoy seguro de cómo solucionar este problema y he estado leyendo un montón de foros. ¿Algunas ideas?
Aquí está el 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.
Respuesta1
Bien, el problema principal aquí era que tenía espacios separando las entradas del directorio en su $PATH
y que tenía estos espacios en variables sin comillas que confundían bash
.
Lo que quería hacer en este caso era agregar un directorio a su ruta. La sintaxis correcta es PATH="/foo:/bar/baz:$PATH
. Agregar $PATH
al final significa que su valor actual se agregará al final de la variable, de esa manera no sobrescribirá lo que ya estaba allí. Los directorios $PATH
se leen en orden, así que agréguelo al principio si desea que se busquen los nuevos directorios al final: PATH="$PATH:/foo:/bar"
.
Otro problema era que tenías muchas rutas duplicadas. Puedes encontrarlos ejecutando
$ 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
Finalmente, estabas exportando $PATH
varias veces, lo cual no tiene sentido. Eliminé todos los duplicados, arreglé tu sintaxis y terminé con esto:
# 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.
Copie ese archivo, abra su terminal y ejecute estos comandos:
/bin/cp ~/.bash_profile ~/bash_profile.bad
/bin/cat > ~/.bash_profile
El primero hará una copia de seguridad de tu actual ~/.bash_profile
(por si acaso). El segundo parecerá no hacer nada pero se habrá abierto ~/.bash_profile
para escritura. Simplemente pegue lo que di arriba directamente en la terminal, luego presione Entery luego CtrlC. Eso debería hacer que todo vuelva a la normalidad.
NOTA: Estabas especificando /bin
, /sbin
y /usr/bin
en /usr/local/bin
tu .bash_profile
. Es casi seguro que ya estén en su cuenta $PATH
y no es necesario agregarlos. Si faltan ( echo $PATH
para ver el valor actual), simplemente agréguelos usando la sintaxis que describí anteriormente.