【问题标题】:Sinatra Jruby Heroku - jruby: No such file or directory -- trinidad (LoadError)Sinatra Jruby Heroku - jruby:没有这样的文件或目录——特立尼达(LoadError)
【发布时间】:2012-01-31 11:37:40
【问题描述】:

我正在尝试运行此应用程序:github.com/Soliah/sinatra-jruby-heroku.git

根据 Heroku 的此发行说明,需要进行一次更新:

http://devcenter.heroku.com/articles/release-note-java-2011-09-29

构建顺利,没有任何错误。下面列出一些日志部分:

   [INFO] --- jruby-rake-plugin:1.6.3:jruby (install-bundler) @ jruby-heroku ---
   [INFO] Successfully installed bundler-1.0.21
   [INFO] 1 gem installed
   [INFO] 
   [INFO] --- jruby-rake-plugin:1.6.3:jruby (bundle-install) @ jruby-heroku ---
   [INFO] Fetching source index for http://rubygems.org/
   [INFO] Installing jruby-rack (1.0.10) 
   [INFO] Installing rack (1.3.2) 
   [INFO] Installing tilt (1.3.3) 
   [INFO] Installing sinatra (1.2.6) 
   [INFO] Installing trinidad_jars (1.0.1) 
   [INFO] Installing trinidad (1.2.3) 
   [INFO] Using bundler (1.0.21) 
   [INFO] Your bundle is complete! It was installed into ./vendor/bundle

   (...)

   [INFO] BUILD SUCCESS
   [INFO] ------------------------------------------------------------------------
   [INFO] Total time: 33.408s
   [INFO] Finished at: Tue Jan 31 10:58:03 UTC 2012
   [INFO] Final Memory: 9M/490M
   [INFO] ------------------------------------------------------------------------
  -----> Discovering process types
         Procfile declares types -> jruby, web
  -----> Compiled slug size is 18.6MB
  -----> Launching... done, v5
         http://jrubyandjava.herokuapp.com deployed to Heroku

但是当我访问已部署的应用程序时。出现应用程序错误。

这是日志,有错误:

  $ heroku logs
  2012-01-31T10:57:21+00:00 heroku[slugc]: Slug compilation started
  2012-01-31T10:58:13+00:00 heroku[web.1]: State changed from created to starting
  2012-01-31T10:58:19+00:00 heroku[web.1]: Starting process with command `sh script/jruby -S trinidad -p 52233`
  2012-01-31T10:58:20+00:00 app[web.1]: Classpath is: :/app/etc:/app/target/dependency/jruby-complete.jar
  2012-01-31T10:58:21+00:00 app[web.1]: jruby: No such file or directory -- trinidad (LoadError)
  2012-01-31T10:58:23+00:00 heroku[web.1]: State changed from starting to crashed
  2012-01-31T10:58:23+00:00 heroku[web.1]: State changed from crashed to created
  2012-01-31T10:58:23+00:00 heroku[web.1]: State changed from created to starting
  2012-01-31T10:58:23+00:00 heroku[web.1]: Process exited
  2012-01-31T10:58:28+00:00 heroku[web.1]: Starting process with command `sh script/jruby -S trinidad -p 26224`
  2012-01-31T10:58:28+00:00 app[web.1]: Classpath is: :/app/etc:/app/target/dependency/jruby-complete.jar
  2012-01-31T10:58:31+00:00 app[web.1]: jruby: No such file or directory -- trinidad (LoadError)
  2012-01-31T10:58:32+00:00 heroku[web.1]: State changed from starting to crashed
  2012-01-31T10:58:33+00:00 heroku[web.1]: Process exited
  2012-01-31T10:58:33+00:00 heroku[router]: Error H10 (App crashed) -> GET jrubyandjava.herokuapp.com/ dyno= queue= wait= service= status=503 bytes=

JRuby 似乎没有找到宝石。 但是我尝试了各种配置(在 script/jruby、heroku config:add、Procfile 等),但没有一个成功。

还有一件事:这是实际的 heroku 配置输出(stack cedar)。

  $ heroku config
  DATABASE_URL        => postgres://kfgubrhars:mYBlJ2YKewqG7LwmPqVI@ec2-50-17-200-129.compute-1.amazonaws.com/kfgubrhars
  JAVA_OPTS           => -Xmx384m -Xss512k -XX:+UseCompressedOops
  MAVEN_OPTS          => -Xmx384m -Xss512k -XX:+UseCompressedOops
  PATH                => /usr/local/bin:/usr/bin:/bin
  SHARED_DATABASE_URL => postgres://kfgubrhars:mYBlJ2YKewqG7LwmPqVI@ec2-50-17-200-129.compute-1.amazonaws.com/kfgubrhars

这里是更新的存储库:https://github.com/tomasmuller/sinatra-jruby-heroku

提前致谢!

【问题讨论】:

  • 这篇文章和更新的库...太棒了

标签: java maven heroku gem jruby


【解决方案1】:

好的!我找到了解决方案。步骤如下:

  • 将 script/jruby 中的 GEM_HOME 调整为:

    GEM_HOME="$APPDIR"/vendor/bundle
    
  • 创建了脚本/bundle,其中 ENV['GEM_HOME'] 和 ENV['GEM_PATH'] 指向 'vendor/bundle' 目录。

  • 调整了 jruby-rake-plugin 在 pom.xml 中的执行:

    install-bundler: <args>-S gem install bundler --no-ri --no-rdoc --install-dir vendor/bundle</args>
    
    bundle-install: <args>script/bundle install --without development:test</args>
    

【讨论】:

    【解决方案2】:

    最近对 gem 的安装位置进行了更改。启动器script/jruby 预计宝石位于.gems,但现在看起来已更改为vender/bundle

    尝试将https://github.com/tomasmuller/sinatra-jruby-heroku/blob/master/script/jruby#L94 改为export GEM_HOME="$APPDIR"/vender/bundle

    我一直想用这些更改来更新我的博客文章,但还没有开始。

    【讨论】:

    • 还没有。我使用您的建议进行了更改,但得到了相同的错误:jruby: No such file or directory -- trinidad (LoadError) 我开始查看 heroku-buildpack-ruby link 以检查 Bundler 的使用方式以及 gem 的安装位置。你是对的。也许我们需要改变 gem 的安装方式(在 POM.xml 中)?只是来自 heroku-buildpack-ruby 的一条线索:bundle install --without development:test --path vendor/bundle --binstubs bin/ --deployment 谢谢!
    【解决方案3】:

    从 Bundler 1.2 开始,您现在可以在您的 Gemfile 中使用 specify the Ruby implementation and version。这样做的好处是 Heroku 将了解这些设置并为您的环境准备 Heroku 应用程序。

    Gemfile 为例:

    source "https://rubygems.org"
    
    ruby "1.9.3"
    
    gem "rails"
    gem "puma"
    

    这很酷的是 Celadon Cedar 默认使用 Ruby 1.9.2。但是,当您在 Gemfile 中指定 ruby "1.9.3" 时,它实际上会为您的 Heroku 环境编译 Ruby 1.9.3。

    现在,如果您想在 Heroku 环境中添加不同的 Ruby 实现,您可以这样做:

    source "https://rubygems.org"
    
    ruby "1.9.3", :engine => "jruby", :engine_version => "1.7.0.preview1"
    
    gem "rails"
    gem "puma"
    

    现在它将在部署时为您的 Heroku 应用程序安装并使用 Ruby 1.9 模式下的 JRuby 1.7.0.preview1。它甚至还会在 Heroku 环境变量中定义正确的 JVM 选项。

    最棒的是它附带官方Heroku buildpack,因此无需切换到第 3 方构建包即可让 JRuby/JVM 在 Heroku 上运行。虽然我还没有让它工作,这个should also work with Rubinius,但我相信它目前有问题。要么这样,要么我做错了。

    在我看来,这是一个很棒且可扩展的功能。只需定义您在 Gemfile 中使用的 Ruby 实现/版本/模式以及其他依赖项,Heroku 就会确保环境已准备好。


    不再需要使用解决方法或使用此方法使用第 3 方构建包。也不再需要创建一个 hacky Jemfile。相反,只需像通常使用 MRI 那样做所有事情,保留 Gemfile,不要使用 3rd 方构建包,只需通过 ruby 方法在 Gemfile 中定义 Ruby 实现/运行时,Heroku 应该会处理这些事情。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-11-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-07-28
      • 2012-12-13
      • 1970-01-01
      相关资源
      最近更新 更多