Skip to content

Commit

Permalink
Fix annoying PATH loading issue introduced in some random OSX update
Browse files Browse the repository at this point in the history
  • Loading branch information
rdj committed Jun 27, 2012
1 parent d5fe54c commit 0362c6e
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
4 changes: 4 additions & 0 deletions init.el
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
;; defaults write $HOME/.MacOSX/environment PATH "$HOME/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11/bin"
;;
;; You will have to log out and back in for this to take effect.
;;
;; NOTE: At some point a Lion update broke this behavior. I now
;; manually load this file in rdj-fix-path.

(require 'cl)
(require 'assoc)
Expand All @@ -32,6 +35,7 @@
(load custom-file)

(require 'rdj-utils)
(require 'rdj-fix-path)

(require 'rdj-early-off)
(require 'rdj-package)
Expand Down
24 changes: 24 additions & 0 deletions rdj/rdj-fix-path.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
;; At some point a Lion update broke loading PATH from
;; environment.plist. Thanks to jwiegley for this little elisp gem to
;; load the file manually.
;;
;; Source: https://github.com/jwiegley/dot-emacs/blob/master/init.el

(when rdj-is-mac
(let ((plist (expand-file-name "~/.MacOSX/environment.plist")))
(when (file-readable-p plist)
(let ((dict (cdr (assq 'dict (cdar (xml-parse-file plist))))))
(while dict
(if (and (listp (car dict))
(eq 'key (caar dict)))
(setenv (car (cddr (car dict)))
(car (cddr (car (cddr dict))))))
(setq dict (cdr dict))))

;; Configure exec-path based on the new PATH
(setq exec-path nil)
(mapc (apply-partially #'add-to-list 'exec-path)
(nreverse (split-string (getenv "PATH") ":"))))))

(provide 'rdj-fix-path)

0 comments on commit 0362c6e

Please sign in to comment.