2014-01-10 25 views
0

我有一個在Ubuntu上創建的Rails應用程序。我想在Mac上運行它,但安裝包和運行rails s後,我收到以下錯誤:JRuby無法運行的Rails應用程序

LoadError: load error: sqlite3/sqlite3_native -- java.lang.UnsatisfiedLinkError: failed to load shim library, error: dlopen(/Users/home/.rvm/rubies/jruby-1.7.4/lib/native/Darwin/libjruby-cext.dylib, 10): image not found require at org/jruby/RubyKernel.java:1054
(root) at /Users/home/.rvm/gems/jruby-1.7.4/gems/sqlite3-1.3.8/lib/sqlite3.rb:6 require at org/jruby/RubyKernel.java:1054 (root) at /Users/home/.rvm/gems/[email protected]/gems/bundler-1.3.5/lib/bundler/runtime.rb:1 each at org/jruby/RubyArray.java:1617 require at /Users/home/.rvm/gems/[email protected]/gems/bundler-1.3.5/lib/bundler/runtime.rb:72 each at org/jruby/RubyArray.java:1617 require at /Users/home/.rvm/gems/[email protected]/gems/bundler-1.3.5/lib/bundler/runtime.rb:70 require at /Users/home/.rvm/gems/[email protected]/gems/bundler-1.3.5/lib/bundler/runtime.rb:59 require at /Users/home/.rvm/gems/[email protected]/gems/bundler-1.3.5/lib/bundler.rb:132 require at org/jruby/RubyKernel.java:1054 (root) at /Users/home/workSpace/RubyOnRails/sample_app/config/application.rb:13 tap at org/jruby/RubyKernel.java:1860 (root) at /Users/home/.rvm/gems/jruby-1.7.4/gems/railties-3.2.8/lib/rails/commands.rb:1 require at org/jruby/RubyKernel.java:1054 (root) at script/rails:6

的Gemfile

source ' https://rubygems.org '

gem 'rails', '3.2.8'

gem 'sqlite3'

group :assets do gem 'sass-rails', '~> 3.2.3' gem 'coffee-rails', '~> 3.2.1'

gem 'uglifier', '>= 1.0.3' end

gem 'jquery-rails'

gem 'execjs'

group :test, :development do gem "rspec-rails", "~> 2.0" end

gem 'spork'

gem 'webrat'

gem 'heroku'

我使用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]的Rails 3.2 .8

+0

你是否也在Ubuntu上使用JRuby? – Shepmaster

+0

不,我沒有使用它! – aakpro

回答

1

問題源於您嘗試使用依賴C擴展名的Ruby gem的事實。從JRuby wiki

JRuby versions prior to 1.6 did not support Ruby C extensions, and even in 1.6 the support is still "in development" and considered experimental. As of 1.7, it has been disabled and will likely be removed.

具體而言,錯誤消息指出:dlopen(/Users/home/.rvm/rubies/jruby-1.7.4/lib/native/Darwin/libjruby-cext.dylib, 10): image not found。這是試圖加載未找到的JRuby C擴展包裝。我不確定這裏的確切原因,但也許沒有安裝。

在我看來,你有兩個主要選擇:

  1. 安裝常規MRI,而不是JRuby的,因爲你對Ubuntu的。然後,您可以隨意使用C擴展名的寶石。
  2. same wiki:使用activerecord-jdbc-adapter而不是jdbc-sqlite3。這將允許您使用JRuby,如果您需要它用於您的應用程序。
0

JRuby 1.7.x不再支持ruby C擴展。看到這個Jira ticket