问题描述
我有一个在Ubuntu上创建的Rails应用程序。我想在Mac上运行它,但安装捆绑软件并运行 rails s
后,出现以下错误:
我的 Gemfile :
我在Java HotSpot(TM)64位服务器上使用 jruby 1.7.4(1.9.3p392)2013-05-16 2390d3b VM 1.7.0_15-b03 [darwin-x86_64]
和 Rails 3.2.8
这个问题源于您试图使用依赖于C扩展的Ruby gem的事实。来自:
具体而言,错误消息指出: dlopen(/Users/home/.rvm/rubies/jruby-1.7.4/lib/native/Darwin/libjruby-cext.dylib,10):image not found
。这是试图加载未找到的JRuby C扩展包装。我不确定这里的确切原因,但可能它没有安装。
正如我看到的那样,您有两个主要选择:
- 像在Ubuntu上安装常规MRI一样,而不是JRuby。然后,您可以根据需要使用带有C扩展名的宝石。
- 从:使用取而代之的是jdbc-sqlite3。如果您需要它,您可以使用JRuby。
I have an Rails app which was created on Ubuntu. I wanted to run it on a Mac, but after installing bundles and running rails s
, I get following errors:
My Gemfile:
I am using jruby 1.7.4 (1.9.3p392) 2013-05-16 2390d3b on Java HotSpot(TM) 64-Bit Server VM 1.7.0_15-b03 [darwin-x86_64]
and Rails 3.2.8
The problem stems from the fact that you are trying to use a Ruby gem that relies on a C extension. From the JRuby wiki:
Specifically, the error message states: dlopen(/Users/home/.rvm/rubies/jruby-1.7.4/lib/native/Darwin/libjruby-cext.dylib, 10): image not found
. This is attempting to load the JRuby C extension wrapper, which is not found. I'm not sure of the exact cause here, but perhaps it didn't get installed.
As I see it, you have two main options:
- Install regular MRI instead of JRuby, as you had on Ubuntu. Then you can use gems with C extensions as you wish.
- From the same wiki: Use activerecord-jdbc-adapter instead along with jdbc-sqlite3. This will allow you to use JRuby, if you need it for your application.
这篇关于Rails应用与JRuby无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!