简体   繁体   English

Sinatra Jruby Heroku - jruby:没有这样的文件或目录 - trinidad(LoadError)

[英]Sinatra Jruby Heroku - jruby: No such file or directory — trinidad (LoadError)

I'm trying to get this application running: github.com/Soliah/sinatra-jruby-heroku.git 我正在尝试运行此应用程序:github.com/Soliah/sinatra-jruby-heroku.git

One update was necessary according to this release note from Heroku: 根据Heroku的这个发行说明,有必要进行一次更新:

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

The build goes fine, without any errors. 构建顺利,没有任何错误。 Bellow some log parts: Bellow一些日志部分:

   [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

But when I access the deployed application. 但是当我访问已部署的应用程序时。 An application error occurs. 发生应用程序错误。

Here is the log, with the error: 这是日志,错误如下:

  $ 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=

It seems that JRuby is not finding the gems. 似乎JRuby没有找到宝石。 But I've tried all kinds of configurations (in script/jruby, heroku config:add, Procfile, etc.) and no one worked. 但我已经尝试了各种配置(在脚本/ jruby,heroku配置:添加,Procfile等),没有人工作。

One more thing: this is the actual heroku config output (stack cedar). 还有一件事:这是实际的heroku配置输出(堆栈雪松)。

  $ 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

Here is the updated repository: https://github.com/tomasmuller/sinatra-jruby-heroku 这是更新的存储库: https//github.com/tomasmuller/sinatra-jruby-heroku

Thank's in advance! 提前致谢!

Ok! 好! I found the solution. 我找到了解决方案。 Here are the steps: 以下是步骤:

  • Adjust the GEM_HOME, in script/jruby to: 调整GEM_HOME,在script / jruby中:

     GEM_HOME="$APPDIR"/vendor/bundle 
  • Created the script/bundle, with ENV['GEM_HOME'] and ENV['GEM_PATH'] pointing to 'vendor/bundle' dir. 创建脚本/包,ENV ['GEM_HOME']和ENV ['GEM_PATH']指向'vendor / bundle'目录。

  • Adjusted the executions of jruby-rake-plugin, in pom.xml: 在pom.xml中调整了jruby-rake-plugin的执行:

     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> 

As of Bundler 1.2 you are now able to specify the Ruby implementation and version in your Gemfile . 从Bundler 1.2开始,您现在可以在Gemfile 指定Ruby实现和版本 The nice thing about this is that Heroku will understand these settings and prepare the your Heroku application for your environment. 关于这一点的好处是Heroku将了解这些设置并为您的环境准备您的Heroku应用程序。

Take this Gemfile for example: 以这个Gemfile为例:

source "https://rubygems.org"

ruby "1.9.3"

gem "rails"
gem "puma"

What's cool about this is that by default Celadon Cedar uses Ruby 1.9.2. 这有什么好处,默认情况下,Celadon Cedar使用Ruby 1.9.2。 However, when you specify ruby "1.9.3" in the Gemfile it'll actually compile Ruby 1.9.3 for your Heroku environment. 但是,当您在Gemfile指定ruby "1.9.3"时,它实际上将为您的Heroku环境编译Ruby 1.9.3。

Now, if you want to add a different Ruby implementation to your Heroku environment, you can do so like this: 现在,如果要在Heroku环境中添加不同的Ruby实现,可以这样做:

source "https://rubygems.org"

ruby "1.9.3", :engine => "jruby", :engine_version => "1.7.0.preview1"

gem "rails"
gem "puma"

Now it'll install and use JRuby 1.7.0.preview1 in Ruby 1.9 mode for your Heroku application upon deployment. 现在,它将在部署时为您的Heroku应用程序在Ruby 1.9模式下安装和使用JRuby 1.7.0.preview1。 It'll also even define the proper JVM options in the Heroku environment variables. 它甚至还会在Heroku环境变量中定义正确的JVM选项。

Best of all is that this comes with the official Heroku buildpack , so there is no need to switch to a 3rd party buildpack to get the JRuby/JVM going on Heroku. 最重要的是,这是官方的Heroku buildpack ,所以没有必要切换到第三方buildpack来让Herub上的JRuby / JVM运行。 Although I haven't gotten it to work yet, this should also work with Rubinius , but I believe it's currently bugged. 虽然我还没有开始工作,但这也应该与Rubinius一起使用 ,但我相信它目前还有问题。 Either that, or I'm doing it wrong. 不管怎样,或者我做错了。

This is in my opinion an awesome and scalable feature. 在我看来,这是一个非常棒且可扩展的功能。 Just define the Ruby implementation/version/mode you're using in your Gemfile along with your other dependencies and Heroku will ensure the environment is prepared. 只需定义您在Gemfile中使用的Ruby实现/版本/模式以及其他依赖项,Heroku将确保准备好环境。


It is no longer necessary to use a workaround or use 3rd party buildpacks using this method. 不再需要使用变通方法或使用此方法使用第三方构建包。 It is also no longer necessary to create a hacky Jemfile . 也不再需要创建一个hacky Jemfile Instead, just do everything as you would normally do with MRI, keep the Gemfile, don't use 3rd party buildpacks, just define the Ruby implementation/runtime in the Gemfile via the ruby method and Heroku should take care of things. 相反,只需像通常使用MRI那样做一切,保留Gemfile,不要使用第三方构建包,只需通过ruby方法在Gemfile中定义Ruby实现/运行时,Heroku应该处理好事情。

There's been a recent change to where the gems get installed. 宝石的安装位置最近发生了变化。 The launcher script/jruby expects the gems to be in .gems but it looks like that has now changed to vender/bundle . 启动程序script/jruby希望宝石在.gems但看起来现在已经改为vender/bundle

Try changing the line https://github.com/tomasmuller/sinatra-jruby-heroku/blob/master/script/jruby#L94 to export GEM_HOME="$APPDIR"/vender/bundle instead. 尝试更改https://github.com/tomasmuller/sinatra-jruby-heroku/blob/master/script/jruby#L94这一行来export GEM_HOME="$APPDIR"/vender/bundle

I've been meaning to update my blog post with these changes but just haven't got around to it. 我一直想用这些更改来更新我的博客帖子,但还没有解决它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM