Can not start XQuartz

x11

I can't start Inkscape and Gimp.
I have the latest Xcode and the latest xQuartz installed.

My logs shows:

6/2/12 1:30:15.957 PM org.macosforge.xquartz.startx: lockfile: Sorry, giving up on "/var/folders/9x/qkjwtrd52qbb5bcvb0zk4rqw0000gn/T//font_cache.lock"
...
6/2/12 1:56:41.324 AM [0x0-0xe20e2].org.inkscape.Inkscape: /Applications/Inkscape.app/Contents/Resources/bin/inkscape: line 132: cp: command not found
...
6/2/12 1:30:16.046 PM org.macosforge.xquartz.startx: /opt/X11/bin/startx: line 240: hostname: command not found

However I have the path set up. In my terminal (both normal and X11 terminal) the hostname command and the cp command executes correctly.

Best Answer

It is important for the XQuartz app to inherit a proper PATH from launchd. The path of the systemwide launchd is /usr/bin:/bin:/usr/sbin:/sbin by default; you can check its value by running

sudo launchctl getenv PATH

If is not as expected, it has most likely been set by a command in /etc/launchd.conf. (This file contains commands in the format expected by launchctl; see the manual page for the latter.)

When you log in, launchd forks a process that becomes the per-user launchd. This inherits the environment from the system launchd, but its environment can be further altered by the commands in /etc/launchd-user.conf and the contents of ~/.MacOSX/environment.plist. Look in these places for alterations to the PATH environment variable, and make sure it at least contains the four paths mentioned above. You can check its value by running

launchctl getenv PATH

(note: no sudo). While experimenting, you can change the environment of your launchd by running

launchctl setenv PATH /usr/bin:/bin:/usr/sbin:/sbin

and then stopping and restarting XQuartz.app. But once you have a solution that works, use either one of /etc/launchd-user.conf or ~/.MacOSX/environment.plist to set the appropriate value permanently. Use the former for all users, and the latter if it's a personal preference.