【问题标题】:RVM and Bundler, byebug gem: C extensions are not supportedRVM 和 Bundler,byebug gem:不支持 C 扩展
【发布时间】:2016-09-27 21:45:30
【问题描述】:

我一直在将 Ruby on Rails 与 postgresql 一起使用,并且有人建议我应该安装 RVM,我这样做了(我认为这是利用 Phonegap)。自从我安装了 RVM 以来,我一直无法执行 bundle install,这反过来意味着我无法再运行其他 rails 命令。

大量阅读并没有真正给我答案,但我有很多想法。也许有人可以帮助将这些想法集中到解决方案中?

当我运行bundle install 时,似乎有 3 个 gem 会导致问题,但我认为它们是相互关联的。它们是byebug 8.2.2pg 0.18.4binding_of caller 0.7.2

byebug-8.2.2/gem_make_out的内容如下:

/home/damo/.rvm/rubies/jruby-9.0.5.0/bin/jruby -r ./siteconf20160927-16151-j7mhkf.rb extconf.rb
NotImplementedError: C extensions are not supported
<top> at /home/damo/.rvm/rubies/jruby-9.0.5.0/lib/ruby/stdlib/mkmf.rb:1
require at org/jruby/RubyKernel.java:937
(root) at /home/damo/.rvm/rubies/jruby-9.0.5.0/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:1
<top> at extconf.rb:6
extconf failed, exit code 1

当我查看byebug issues 时,它只是说 byebug 不支持 jruby。

我在安装 RVM 之前没有遇到任何问题,而且我确定我读到 byebug 已硬连线到 Rails 4。我想告诉你我的 Rails 版本,但rails -v 给了我一个回应

Could not find proper version of railties (4.2.5) in any of the sources
Run `bundle install` to install missing gems.

这似乎是我的 Catch 22!

【问题讨论】:

  • 好的,现在一切正常。根据下面的回复,我假设安装 RVM 将我切换到默认的 jRuby。在我设置rvm use ruby-2.3.0 并重新安装bundler 之后,我就能够bundle install 并修复东西。为了确保我不会遇到类似的问题,我运行了rvm default runy-2.3.0。顺便说一句,我不得不 chmod 一些目录授予我安装 gems 的读/写访问权限。
  • 要更改默认 ruby​​,正确的指令是 rvm --default use &lt;NUMBER&gt;。重新启动后,gem install pg -v '0.18.4 仍然存在一些问题。我不知道为什么,但我需要sudo yum install postgresql-devel,我预计现在需要使用它。无论如何,现在似乎一切正常。

标签: ruby-on-rails postgresql rvm bundler


【解决方案1】:

这听起来像是您没有在登录 shell 中使用 RVM。在 Bash 中,您可以运行 bash -l,然后运行 ​​source ~/.bashrc(或包含您的 rvm 调用行的任何内容)。之后,尝试rvm use ruby-2.2(或其他),如果您没有收到“RVM 不是函数”错误,那么您应该可以开始了。

请注意,在 RVM 下,您可能必须为每个不同的 ruby​​ 版本(和 gemset)手动执行 gem install bundler,因为 RVM 下的 ruby​​(和 gemset)存在于它们自己的世界中,而系统 bundler 往往是老的。如果您正在重复使用 ruby​​ 安装并且不使用或共享 gemset,bundler 可能已经是最新的。

所以:使用登录 shell,执行rvm use &lt;your_favorite_ruby_version&gt;,必要时安装bundler,然后安装bundle install

最后但同样重要的是,我喜欢使用 .ruby-version 文件,这样我就不必手动切换 rubies 和 gemsets,而且我可以从 rvm info 的输出判断一切是否正常。

【讨论】:

  • 我记得设置 RVM 时遇到的问题,在继续之前我确实通过了 RVM is a function 测试。根据@Doon 的回答,我还有一些进一步的工作要做,但我认为你们俩之间我可能会得到一些快乐。但我之前也想过 ;-)
【解决方案2】:

在安装 rvm 之前你在哪里使用 jruby?似乎您的默认 ruby​​ 更改为 jruby,而不是您之前使用的任何东西(系统 ruby​​?)。

尝试运行

 rvm use system 

在您的 rails 项目的根目录中,然后尝试捆绑安装并查看是否可以修复它。如果是,那么可以使用 setup .ruby-version 文件来控制每个项目使用的 ruby​​ 版本。

否则输入

  rvm use system --default 

将您的默认红宝石设置回系统一并继续像您一样宝贵。

【讨论】:

  • 感谢您的回复。我没有使用 jruby,至少据我所知没有。当我运行rvm use system 时,bash 告诉我Warning: PATH is not properly set up, '/home/damo/.rvm/gems/jruby-9.0.5.0/bin' is not at first place, usually this is caused by shell initialization files - check them for 'PATH=...' 这似乎可能与上面的@eric 答案有关。我会玩一玩,看看我能做些什么。
  • 我敢打赌你的 rvm 设置行是在错误的地方(例如.bashrc vs .bash_profile)。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-06-21
  • 2023-04-02
  • 1970-01-01
相关资源
最近更新 更多