MacOS – Xquartz on Mavericks 10.9 fails

macosmacportsx11xquartz

There is an issue with running xquartz on my system. I installed it by using the link from the Apple website. However when I run xquartz from terminal I get:

:~$ xquartz
/Applications/Utilities/XQuartz.app/Contents/MacOS/X11: line 10: /usr/local/bin/bash: No such file or directory
/Applications/Utilities/XQuartz.app/Contents/MacOS/X11: line 10: exec: /usr/local/bin/bash: cannot execute: No such file or directory

This is preventing me from launching xquartz/x11 applications that I downloaded through macports. How can I resolve this so that xquartz runs properly?

Best Answer

/Applications/Utilities/XQuartz.app/Contents/MacOS/X11 is just a shell script that executes whatever is defined as $SHELL in your environment:

case $(basename "${SHELL}") in
    bash)          exec -l "${SHELL}" --login -c 'exec "${@}"' - "${@}" ;;

(etc).

In your case, it look as though $SHELL is set to /usr/local/bin/bash, which doesn't exist. What's interesting, though, is that since you have a prompt at which you have typed xquartz, you clearly are running a shell of some description. However, it doesn't correspond to the value of $SHELL.

Two suggestions for how this might happen:

  1. $SHELL will normally reflect the login shell for your user. You can set that in System Preferences -> Users & Groups -> right click on your username and choose "Advanced Options". If you set this to an invalid value, you won't normally be able to open a terminal... unless you go into the Terminal.app preferences and set the "Shells open with:" option to something which does exist. You'll then get a working terminal with a non-existent $SHELL.
  2. Alternatively, it might be something in your shell startup scripts (.bashrc, .profile, etc) which export a misleading value of $SHELL to the environment. If you have customized any of these, take a look and make sure you're not setting things up incorrectly.