我试图得到一个编译命令(耙子黄瓜)运行与我的Mac OS X系统上的一个特定的
ruby版本,我使用rvm这样做目前在终端.我的〜/ .MacOSX / environment.plist里面有正确的路径,但emacs坚持在这个路径前面,因此使它无用.我也试过:
(when (equal system-type 'darwin) (setenv "PATH" (concat "/Users/fearoffish/.rvm/bin:/Users/fearoffish/.rvm/rubies/ruby-1.8.7-p249/bin:/Users/fearoffish/.rvm/gems/ruby-1.8.7-p249/bin:/Users/fearoffish/.rvm/gems/ruby-1.8.7-p249%global/bin:/Users/fearoffish/.rvm/bin")) (push "/Users/fearoffish/.rvm/bin" exec-path) (push "/Users/fearoffish/.rvm/rubies/ruby-1.8.7-p249/bin" exec-path) (push "/Users/fearoffish/.rvm/gems/ruby-1.8.7-p249/bin" exec-path) (push "/Users/fearoffish/.rvm/gems/ruby-1.8.7-p249%global/bin" exec-path) (push "/Users/fearoffish/.rvm/bin" exec-path))
这是emacs初学者绝望的尝试得到我想要的.它仍然在它的前面,所以我的路径最终是:
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/Users/fearoffish/.rvm/bin:/Users/fearoffish/.rvm/rubies/ruby-1.8.7-p249/bin:/Users/fearoffish/.rvm/gems/ruby-1.8.7-p249/bin:/Users/fearoffish/.rvm/gems/ruby-1.8.7-p249%global/bin
我不想/usr/bin和其他人在前面,我想要我的路径,并且emacs前置路径到底,我认为这将解决我的问题.
我通过简单地打开Aquamacs并运行Meta-x编译,然后echo $PATH来测试.
有任何想法吗?
解决方法
sanityinc的解决方案的一个小小的修改(在上面的评论中找不到一个方法来输入 – 只是我吗?)
>我使用-l选项来强制登录shell(它读取.profile或.bash_profile),而不是一个交互式shell(仅读取.bashrc).
>我在返回的路径上做一些字符串修剪(检查显示换行符).
(defun set-exec-path-from-shell-PATH () (let ((path-from-shell (replace-regexp-in-string "[[:space:]\n]*$" "" (shell-command-to-string "$SHELL -l -c 'echo $PATH'")))) (setenv "PATH" path-from-shell) (setq exec-path (split-string path-from-shell path-separator)))) (when (equal system-type 'darwin) (set-exec-path-from-shell-PATH))