Rails应用与JRuby无法正常工作

编程入门 行业动态 更新时间:2024-10-28 08:26:55
本文介绍了Rails应用与JRuby无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个在Ubuntu上创建的Rails应用程序。我想在Mac上运行它,但安装捆绑软件并运行 rails s 后,出现以下错误:

LoadError:加载错误:sqlite3 / sqlite3_native - java.lang.UnsatisfiedLinkError:加载填充库失败,错误: dlopen(/Users/home/.rvm/ rubies / jruby-1.7.4 / lib / native / Darwin / libjruby-cext.dylib, 10):图片未找到需要在org / jruby / RubyKernel.java:1054 (root )at /Users/home/.rvm/gems/jruby-1.7.4/gems/sqlite3-1.3.8/lib/sqlite3.rb:6 需要在org / jruby / RubyKernel.java :1054美元(根) /Users/home/.rvm/gems/jruby-1.7.4@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:1 在org / jruby / RubyArray.java:1617需要在/Users/home/.rvm/gems/jruby-1.7.4@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:72 每个都在org / jruby / RubyArray.java:1617需要在/Users/home/.rvm/gems/jruby-1.7.4@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:70 req uire at /Users/home/.rvm/gems/jruby-1.7.4@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:59 要求在 /Users/home/.rvm/gems/jruby-1.7.4@global/gems/bundler-1.3.5/lib/bundler.rb:132 需要在org / jruby / RubyKernel.java:1054( root)在 /Users/home/workSpace/RubyOnRails/sample_app/config/application.rb:13 在/ Users / home /下点击org / jruby / RubyKernel.java:1860(root)。 rvm / gems / jruby-1.7.4 / gems / railties-3.2.8 / lib / rails / commands.rb:1 在org / jruby / RubyKernel.java中需要:1054(root)在脚本/ 6

我的 Gemfile :

来源' rubygems '

gem'rails','3.2.8'

gem'sqlite3'

group:资产做宝石'sass-rails','〜> 3.2.3'宝石'咖啡栏','〜> 3.2.1'

宝石U glifier','> = 1.0.3'end

gem'jquery-rails'

gem'execjs '

group:test,:开发do gemrspec-rails,〜> 2.0end

gem'spork'

gem'webrat'

gem'heroku'

我在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的事实。来自 JRuby wiki :

1.6之前的JRuby版本不支持Ruby C扩展,即使在1.6版本中也支持,支持仍处于开发中并且被视为实验。

具体而言,错误消息指出: 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扩展名的宝石。
  • 从同一个Wiki :使用 activerecord-jdbc-adapter 取而代之的是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:

    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/jruby-1.7.4@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:1 each at org/jruby/RubyArray.java:1617 require at /Users/home/.rvm/gems/jruby-1.7.4@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:72 each at org/jruby/RubyArray.java:1617 require at /Users/home/.rvm/gems/jruby-1.7.4@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:70 require at /Users/home/.rvm/gems/jruby-1.7.4@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:59 require at /Users/home/.rvm/gems/jruby-1.7.4@global/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

    My Gemfile:

    source 'rubygems'

    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'

    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:

    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.

    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无法正常工作

    本文发布于:2023-10-21 17:43:18,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1514921.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:无法正常   工作   Rails   JRuby

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!