14

I am trying to use /etc/paths.d to add an executable to my path variable but I have no success so far.

The full path of the executable file is: /opt/ImageMagick/bin/convert

/etc/paths.d contains two files: 40-XQuartz and ImageMagick

The 40-XQuartz contains one line: /opt/X11/bin
The ImageMagick contains one line: /opt/ImageMagick/bin

My echo $PATH gives:

/Users/Administrator/.rbenv/shims:/Users/Administrator/.rbenv/bin:/Users/Administrator/bin:/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/local/mysql/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin

So it seems that only the first file (40-XQuartz) does its job. The permissions of the two files (40-XQuartz and ImageMagick) are exactly the same so my question is why the first one works and the second one is not.

I am running OS X Mavericks.

  • What shell do you use? What's about /etc/paths? – Max Ried Apr 30 '14 at 10:40
  • Adding stiff to /etc/paths.d works for me, but I restart whatever terminal application I am using (ITerm2 in my case) for the new path to take effect – user1256923 Apr 30 '14 at 14:43
15

Have you started a new login shell since adding the new file for ImageMagick? The setting of the path from paths.d entries is done in /etc/profile and /etc/csh.login, so you need to start a new shell for the new entries to take effect.

OS X uses path_helper to set the path based on the files in /etc/paths.d - you can always call it manually (assuming a Bourne-like shell here):

$ eval `/usr/libexec/path_helper -s`
  • Of course I have started a new shell.I even restarted my mac. – skiabox Apr 27 '14 at 17:10
  • new login shell worked for me – incandescentman Sep 9 '16 at 20:23
3

Running

echo /opt/ImageMagick/bin|sudo tee /etc/paths.d/ImageMagick;bash -l;echo $PATH

adds /opt/ImageMagick/bin to PATH on my installation.

Are you overriding PATH in some other place like ~/.bash_profile?

The paths in /etc/paths.d/ are added to the path by /usr/libexec/path_helper, which is run from /etc/profile, /etc/zsh.env, and /etc/csh.login. path_helper is not run by graphical applications or when bash is invoked as a non-login shell.

You can also set a default PATH in /etc/launchd.conf:

  1. Run for example setenv PATH /Users/Administrator/.rbenv/shims:/Users/Administrator/.rbenv/bin:/Users/Administrator/bin:/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/local/mysql/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/opt/ImageMagick/bin|sudo tee -a /etc/launchd.conf.
  2. Either restart, or run launchctl</etc/launchd.conf;sudo launchctl</etc/launchd.conf and relaunch processes.

I prefer changing the path in /etc/launchd.conf, because it also affects programs that are not started from shells, like text editors and programs started by launchd jobs.

0

Awesome, I was just playing around with adding ImageMagic to my Mac. Not only do you need ImageMagick/bin in your PATH, you also need an environment variable set, or added to:

To test you can create it manually with:

export DYLD_LIBRARY=".:/opt/ImageMagic/lib"

Information for setting an environment variable for Mac OS can be found here, Setting environment variables in OS X?

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .