Cannot set custom $PATH for Qt Creator on OS X 10.10

1.7k views Asked by At

I use Qt Creator with custom build system (ninja). The issue is that the $PATH variable passed to the Qt Creator IDE is absolutely vanilla: /usr/bin:/bin:/usr/sbin:/sbin.

So I have to write bash -c '/path/to/ninja list of targets' instead of just ninja list of targets, or perform build steps in a terminal, not in the IDE.

I tried all known recipes to set up the $PATH.

  • ~/.bash_profile and ~/.profile
  • /etc/paths
  • /etc/paths.d/*
  • /etc/launchd.conf (setenv PATH .....)
  • ~/Library/LaunchAgents/*.plist (sh -c 'launchtcl setenv PATH $PATH:.....')
  • /Library/LaunchAgents/*.plist

The idea of using launch agenes is described in a StackOverflow answer.

None works! Any arbitrary environment var in my custom .plist file sets correctly, - any but the PATH. (I have tested it simply: created a custom build step echo xzxzxz=$XZXZXZ path=$PATH where xzxzxz is also set in my launch agent).

It's interesting that if I launch Qt Creator from bash session ('/Applications/Qt Creator.app/Contents/MacOS/Qt Creator' &), it gets correct PATH, same as the bash itself.

Also it's interesting that the PATH assigned with the launch agent is later overwritten. There I wrote sh -c 'launchctl setenv PATH $PATH:/HELLOWORLD', but I don't see that HELLOWORLD in echo $PATH. So, there are a race condition, someone rebuilds the PATH from /etc/paths and /etc/paths.d later.

Thus:

  • is there an exhaustive and up-to-date explanation how to set up environment variables, and particularly PATH, on OSX 10.10 ?
  • why the PATH becomes vanilla?
  • how to win with Qt Creator?
1

There are 1 answers

5
Tobias Hunger On

You could just update the path to the build environment of your project inside Qt Creator.

Newer versions (>3.3 AFAIR, 3.4 for certain) allow to set environment overrides in each the kit, so that you could have it for all projects using those.