Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Macos 如何将正确的rbenv Ruby版本与Emacs';shell命令?_Macos_Emacs_Zsh - Fatal编程技术网

Macos 如何将正确的rbenv Ruby版本与Emacs';shell命令?

Macos 如何将正确的rbenv Ruby版本与Emacs';shell命令?,macos,emacs,zsh,Macos,Emacs,Zsh,以下是我当前的设置: 带山狮的MacBook Emacs是 rbenv与全球1.9.3-p374 登录shell是zsh 我的~/.zprofile(我确信该文件已执行): 我想将全局定义的ruby版本与M-xshell命令一起使用(或M-!)。我希望M-!ruby-v返回ruby 1.9.3p374(2013-01-15修订版38858)[x86_64-darwin12.3.0]但我得到ruby 1.8.7(2012-02-08补丁级别358)[universal-darwin12.0]

以下是我当前的设置:

  • 带山狮的MacBook
  • Emacs是
  • rbenv与全球1.9.3-p374
  • 登录shell是zsh
我的~/.zprofile(我确信该文件已执行):

我想将全局定义的ruby版本与
M-xshell命令一起使用(或
M-!
)。我希望
M-!ruby-v
返回
ruby 1.9.3p374(2013-01-15修订版38858)[x86_64-darwin12.3.0]
但我得到
ruby 1.8.7(2012-02-08补丁级别358)[universal-darwin12.0]

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


除了运行类似于:
M-!评估“$(rbenv init-”&&ruby-v
?这是可行的,但我不想在我执行的所有操作之前插入
eval“$(rbenv init-”&&&

Emacs需要查看您从shell的路径,为了更方便,请使用以下elisp包

您可以通过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文件将处理其余部分

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