Emacs在运行编译命令时忽略了我的路径 [英] Emacs is ignoring my path when it runs a compile command

查看:112
本文介绍了Emacs在运行编译命令时忽略了我的路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试获得一个编译命令(耙子黄瓜)在Mac OS X系统上运行特定的ruby版本,我使用rvm目前在终端中执行此操作。我的〜/ .MacOSX / environment.plist里面有正确的路径,但emacs坚持在这个路径前面,因此使它无用。我也尝试过:

 (when(equal system-type'darwin)
(setenvPATH 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 / binexec-path)
(push/Users/fearoffish/.rvm/rubies/ruby-1.8.7-p249/binexec-path)
(push/ Users / fearoffish / exec-path)
(推/Users/fearoffish/.rvm/gems/ruby-1.8.7-p249%global/binexec-路径)
(推/Users/fearoffish/.rvm/binexec-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



任何想法? p>

解决方案

sanityinc解决方案的一个小的修改(在上面的评论中找不到一个方法来输入)我使用 -l <​​/ code>选项到shell来强制登录shell(它读取 .profile .bash_profile ),而不是一个交互式shell(只读 .bashrc )。

  • 我在返回的路径上做一些字符串修剪(视检查显示换行)潜行。



  • 修改后的代码:

     (defun set-exec-path-from-shell-PATH()
    let((path-from-shell
    (replace-regexp-in-string[[:space:] \\\
    ] * $
    (shell-command-to-string$ SHELL -l -c'echo $ PATH'))))
    (setenvPATHfrom-shell)
    (setq exec-path(split-string path-from-shell path-分隔符))))
    (等于系统类型'darwin)(set-exec-path-from-shell-PATH))


    I'm trying to get a compile command (rake cucumber) to run with a specific ruby version on my Mac OS X system, I use rvm to do this currently in the terminal. My ~/.MacOSX/environment.plist has the correct path in it, but emacs insists on prepending to this path and therefore making it useless. I've also tried:

    (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))
    

    It was the desperate attempt of an emacs beginner to get what I wanted. It still prepends in front of it, so my path ends up being:

    /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
    

    I don't want /usr/bin and others prepending, I want my path first and the emacs prepended path to be at the end, I reckon this would fix my problem.

    I test this by simply opening Aquamacs and running meta-x compile and then echo $PATH.

    Any ideas?

    解决方案

    A small modification to the solution by sanityinc (couldn't find a way to enter it in the comments above -- is that just me?)

    • I use -l option to the shell to force a login shell (which reads .profile or .bash_profile), rather than an interactive shell (which only reads .bashrc).
    • I do some string trimming on the returned path (as inspection shows a newline sneaking in).

    Modified code:

    (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))
    

    这篇关于Emacs在运行编译命令时忽略了我的路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆