【问题标题】:Vim inside rails console - Your Ruby version is 2.0.0, but your Gemfile specified 2.1.2Rails 控制台中的 Vim - 您的 Ruby 版本是 2.0.0,但您的 Gemfile 指定的是 2.1.2
【发布时间】:2015-01-03 07:23:08
【问题描述】:

当我运行常规 irb 会话时,从 REPL 内部运行 vim 没有问题。

但是,在 rails c 内部,我收到以下错误:

>> vim
Your Ruby version is 2.0.0, but your Gemfile specified 2.1.2
Vim: Caught deadly signal SEGV
Vim: Finished.
=> nil

现在,这是正确的。我的 Gemfile 确实指定了 2.1.2,而 Vim 是用 Ruby 2.0.0 编译的。

不过,我真正不想做的是为我正在处理的每个使用不同版本 Ruby 的不同 Ruby 项目重新编译 Vim。

我几乎从不使用 Vim 中的 Ruby 功能。为什么我在rails c 中运行的 Vim 版本必须使用与我的 Rails 应用程序完全相同的 Ruby 版本进行编译?

如果版本不匹配,我可以在 IRB 中暂时禁用 Ruby for Vim 吗?

我只是希望能够用 vim 进行简单的编辑...

【问题讨论】:

  • 最简单的方法是使用bundler bundle exec rails c
  • @МалъСкрылевъ 这不起作用,请参阅下面我对您的回答的回复

标签: ruby-on-rails ruby vim irb


【解决方案1】:

set shell=/bin/sh 添加到你的.vimrc

请记住在更新 vimrc 后重新启动 ViM。

【讨论】:

    【解决方案2】:

    最简单的方法是使用bundler,如下:

    $ bundle exec rails c
    

    或者你用正确版本的rails来修复你的PATH变量:

    $ bundle show rails
    /path/to/rails/in/bundle/environment
    
    $ export PATH=/path/to/rails/in/bundle/environment:$PATH
    $ rails c
    

    【讨论】:

    • 这不会影响任何事情...rails 已经在 bundler 环境中运行。使用 bundle exec 运行 rails c 仍然会导致相同的问题。
    • @MikeC8 如果您认为我会通过 downvote 更好地给出答案,那您就错了。对我来说,让你一个人处理你的问题更简单。然而。根据答案,为项目文件夹内的which rails 提供输出
    • /Users/me/.rvm/gems/ruby-2.1.2/bin/rails
    • @MikeC8 好的,然后是cat $(which rails) |head -1
    • #!/usr/bin/env ruby​​_executable_hooks
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-03-04
    • 2014-05-27
    • 1970-01-01
    • 2016-08-17
    • 1970-01-01
    • 2013-10-20
    相关资源
    最近更新 更多