加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

macos – 如何在Emacs的shell-command中使用正确的rbenv Ruby版

发布时间:2020-12-15 20:59:26 所属栏目:安全 来源:网络整理
导读:这是我目前的设置: 山猫MacBook Emacs是http://emacsformacosx.com/ rbenv全球1.9.3-p374 登录shell是zsh 我的?/ .zprofile(我确定该文件被执行): # Customize to your needs...export PATH=/Users/username/.rbenv/shims:/Users/username/.nvm/v0.9.8/bin
这是我目前的设置:

>山猫MacBook
> Emacs是http://emacsformacosx.com/
> rbenv全球1.9.3-p374
>登录shell是zsh

我的?/ .zprofile(我确定该文件被执行):

# Customize to your needs...
export PATH=/Users/username/.rbenv/shims:/Users/username/.nvm/v0.9.8/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/sbin

eval "$(rbenv init -)"

我想使用我的全局定义的ruby版本和M-x shell-command(或M-!).我期待M-! ruby -v返回ruby 1.9.3p374(2013-01-15修订版38858)[x86_64-darwin12.3.0]但是我得到ruby 1.8.7(2012-02-08 patchlevel 358)[universal-darwin12.0].

如果我在M-x shell中运行ruby -v,则加载正确的版本.我怀疑M-!因为它作为非交互式shell运行而无法按预期工作.

有没有办法解决这个问题,除了运行类似的东西:M-!评估“$(rbenv init – )”&&ruby-v?这有效,但我不想插入eval“$(rbenv init – )”&&面对我执行的一切.

解决方法

您需要通过Emacs查看来自shell的路径,并且为了更容易,请使用以下elisp包.

https://github.com/purcell/exec-path-from-shell

您可以通过el-get或手动将其放入?/ .emacs.d / lisp目录并将其添加到?/ .emacs或?/ .emacs.d / init.el文件中来安装.

(add-to-list 'load-path "~/.emacs.d/lisp")
(unless (require 'exec-path-from-shell nil 'noerror)
  (exec-path-from-shell-initialize))

lisp文件将处理剩下的事情.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读