Ruby(2.1.5p273) Rails (4.18) 在 Heroku 应用程序上部署错误 inflections.rb:1:in `require': cannot load such file -- thread _safe
Ruby(2.1.5p273) on Rails (4.18) deploying on Heroku Application error inflections.rb:1:in `require': cannot load such file -- thread _safe
我是RoR的完全菜鸟,这是我第一次使用Ruby做网站开发,结果证明是相当具有挑战性的...第一次学习的变量数量是……有点过分。我试了 4 天才弄清楚 RoR 的正确设置,但是,似乎我总是遇到障碍。
无论如何,这是我目前遇到的问题..我正在使用 windows 7 with ruby version 2.1.5p273 and rails version 4.18
我打算将我的应用程序部署到 Heroku,所以我首先使用命令创建 rails 应用程序:
rails new myapp --database=postgresql
之后我检查了 gemfile
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.1.8'
# Use jdbcpostgresql as the database for Active Record
gem 'activerecord-jdbcpostgresql-adapter'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.3'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
gem 'therubyrhino'
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
# to solve tzinfo-data problem
gem 'tzinfo-data'
之后我用 git
存储应用程序
git init
git add .
git commit -m "initial commit"
然后进入localhost:3000,页面显示ruby默认页面,说明本地正在工作只是发现,
但是,当我尝试将应用程序推送到 heroku 时出现问题。
我遵循这个命令:
heroku create
git push heroku master
heroku open
原来是出了点问题,页面显示"Application error"页
浏览了一段时间后,我发现了 heroku 日志功能并试图找出问题所在,我无法清楚地理解日志,
这是日志:
Your version of git is 1.8.4.. Which has serious security vulnerabilities.
More information here: https://blog.heroku.com/archives/2014/12/23/update_your_git_clients_on_windows_and_os_x
←[36m2015-07-16T06:28:44.016688+00:00 app[web.1]:←[0m /usr/bin/env: jruby.exe: No such file or directory
←[36m2015-07-16T06:28:44.779818+00:00 heroku[web.1]:←[0m Process exited with status 127
←[36m2015-07-16T06:28:44.798095+00:00 heroku[web.1]:←[0m State changed from starting to crashed
←[36m2015-07-16T06:28:44.799323+00:00 heroku[web.1]:←[0m State changed from crashed to starting
←[36m2015-07-16T06:28:48.416335+00:00 heroku[web.1]:←[0m Starting process with command `bin/rails server -p 12996 -e production`
←[36m2015-07-16T06:28:49.546664+00:00 app[web.1]:←[0m /usr/bin/env: jruby.exe: No such file or directory
←[36m2015-07-16T06:28:50.321059+00:00 heroku[web.1]:←[0m Process exited with status 127
←[36m2015-07-16T06:28:50.343084+00:00 heroku[web.1]:←[0m State changed from starting to crashed
←[33m2015-07-16T06:28:59.717663+00:00 heroku[router]:←[0m at=error code=H10 desc="App crashed" method=GET path="/" host=shinfithecraf
tcom.herokuapp.com request_id=38466811-0df1-418a-9e71-d8db0fb2787a fwd="36.82.86.169" dyno= connect= service= status=503 bytes=
←[33m2015-07-16T06:29:00.337303+00:00 heroku[router]:←[0m at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=sh
infithecraftcom.herokuapp.com request_id=5d15f883-9873-451e-aa2f-f23957f8f532 fwd="36.82.86.169" dyno= connect= service= status=503 b
ytes=
←[32m2015-07-16T06:35:50.725201+00:00 heroku[api]:←[0m Starting process with command `rails console` by myemail@gmail.com
←[35m2015-07-16T06:35:54.225700+00:00 heroku[run.4903]:←[0m Awaiting client
←[35m2015-07-16T06:35:54.257165+00:00 heroku[run.4903]:←[0m Starting process with command `rails console`
←[35m2015-07-16T06:35:54.635356+00:00 heroku[run.4903]:←[0m State changed from starting to up
←[35m2015-07-16T06:35:56.469745+00:00 heroku[run.4903]:←[0m Process exited with status 127
←[35m2015-07-16T06:35:56.507341+00:00 heroku[run.4903]:←[0m State changed from up to complete
←[36m2015-07-16T06:54:37.484647+00:00 heroku[web.1]:←[0m State changed from crashed to starting
←[36m2015-07-16T06:54:41.906605+00:00 heroku[web.1]:←[0m Starting process with command `bin/rails server -p 20328 -e production`
←[36m2015-07-16T06:54:44.137100+00:00 app[web.1]:←[0m /usr/bin/env: jruby.exe: No such file or directory
←[36m2015-07-16T06:54:45.035554+00:00 heroku[web.1]:←[0m Process exited with status 127
←[36m2015-07-16T06:54:45.047325+00:00 heroku[web.1]:←[0m State changed from starting to crashed
←[32m2015-07-16T07:18:35.619583+00:00 heroku[api]:←[0m Starting process with command `rails console` by myemail@gmail.com
←[35m2015-07-16T07:18:41.441770+00:00 heroku[run.9530]:←[0m Awaiting client
←[35m2015-07-16T07:18:41.482683+00:00 heroku[run.9530]:←[0m Starting process with command `rails console`
←[35m2015-07-16T07:18:44.122593+00:00 heroku[run.9530]:←[0m Process exited with status 127
←[35m2015-07-16T07:18:44.138803+00:00 heroku[run.9530]:←[0m State changed from up to complete
←[35m2015-07-16T07:18:41.633345+00:00 heroku[run.9530]:←[0m State changed from starting to up
我试图通过学习阅读日志文件来解决这个问题,发现问题其实在
←[36m2015-07-16T06:28:44.016688+00:00 app[web.1]:←[0m /usr/bin/env: jruby.exe: No such file or directory
所以我打开包,rails,在我的 bin 文件夹中搜索并将 "jruby.exe" 更改为 "ruby" ,我不确定为什么文件实际上使用 jruby.exe 但它似乎有效并且问题消失了,但是,在 heroku 上打开网页仍然显示 "Application error",再查看日志文件显示:
←[36m2015-07-16T07:21:14.512070+00:00 heroku[web.1]:←[0m Starting process with command `bin/rails server -p 19013 -e production`
←[36m2015-07-16T07:21:01.692937+00:00 heroku[web.1]:←[0m State changed from crashed to starting
←[36m2015-07-16T07:21:17.990817+00:00 app[web.1]:←[0m /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/infle
ctor/inflections.rb:1:in `require': cannot load such file -- thread_safe (LoadError)
←[36m2015-07-16T07:21:17.990839+00:00 app[web.1]:←[0m from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_suppor
t/inflector/inflections.rb:1:in `<top (required)>'
←[36m2015-07-16T07:21:17.990847+00:00 app[web.1]:←[0m from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_suppor
t/inflections.rb:1:in `<top (required)>'
←[36m2015-07-16T07:21:17.990849+00:00 app[web.1]:←[0m from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_suppor
t/inflector/methods.rb:3:in `require'
←[36m2015-07-16T07:21:17.990850+00:00 app[web.1]:←[0m from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_suppor
t/inflector/methods.rb:3:in `<top (required)>'
←[36m2015-07-16T07:21:17.990846+00:00 app[web.1]:←[0m from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_suppor
t/inflections.rb:1:in `require'
←[36m2015-07-16T07:21:17.990855+00:00 app[web.1]:←[0m from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_suppor
t.rb:25:in `require'
←[36m2015-07-16T07:21:17.990852+00:00 app[web.1]:←[0m from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_suppor
t/dependencies/autoload.rb:1:in `require'
←[36m2015-07-16T07:21:17.990858+00:00 app[web.1]:←[0m from /app/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.8/lib/action_dispatch.
rb:24:in `require'
←[36m2015-07-16T07:21:17.990862+00:00 app[web.1]:←[0m from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.1.8/lib/rails/commands/ser
ver.rb:3:in `require'
←[36m2015-07-16T07:21:17.990853+00:00 app[web.1]:←[0m from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_suppor
t/dependencies/autoload.rb:1:in `<top (required)>'
←[36m2015-07-16T07:21:17.990856+00:00 app[web.1]:←[0m from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_suppor
t.rb:25:in `<top (required)>'
←[36m2015-07-16T07:21:17.990863+00:00 app[web.1]:←[0m from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.1.8/lib/rails/commands/ser
ver.rb:3:in `<top (required)>'
←[36m2015-07-16T07:21:17.990859+00:00 app[web.1]:←[0m from /app/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.8/lib/action_dispatch.
rb:24:in `<top (required)>'
←[36m2015-07-16T07:21:17.990865+00:00 app[web.1]:←[0m from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.1.8/lib/rails/commands/com
mands_tasks.rb:128:in `require'
←[36m2015-07-16T07:21:17.990869+00:00 app[web.1]:←[0m from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.1.8/lib/rails/commands/com
mands_tasks.rb:40:in `run_command!'
←[36m2015-07-16T07:21:17.990867+00:00 app[web.1]:←[0m from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.1.8/lib/rails/commands/com
mands_tasks.rb:74:in `server'
←[36m2015-07-16T07:21:17.990875+00:00 app[web.1]:←[0m from bin/rails:4:in `<main>'
←[36m2015-07-16T07:21:17.990866+00:00 app[web.1]:←[0m from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.1.8/lib/rails/commands/com
mands_tasks.rb:128:in `require_command!'
←[36m2015-07-16T07:21:17.990870+00:00 app[web.1]:←[0m from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.1.8/lib/rails/commands.rb:
17:in `<top (required)>'
←[36m2015-07-16T07:21:17.990873+00:00 app[web.1]:←[0m from bin/rails:4:in `require'
←[36m2015-07-16T07:21:18.817510+00:00 heroku[web.1]:←[0m Process exited with status 1
←[36m2015-07-16T07:21:18.834033+00:00 heroku[web.1]:←[0m State changed from starting to crashed
←[32m2015-07-16T07:21:50.556289+00:00 heroku[api]:←[0m Starting process with command `rails console` by hansin.ciputra@gmail.com
←[35m2015-07-16T07:21:54.774130+00:00 heroku[run.3007]:←[0m Awaiting client
←[35m2015-07-16T07:21:55.080890+00:00 heroku[run.3007]:←[0m State changed from starting to up
←[35m2015-07-16T07:21:55.047872+00:00 heroku[run.3007]:←[0m Starting process with command `rails console`
←[35m2015-07-16T07:21:57.836920+00:00 heroku[run.3007]:←[0m State changed from up to complete
←[35m2015-07-16T07:21:57.818989+00:00 heroku[run.3007]:←[0m Process exited with status 1
←[32m2015-07-16T07:37:13.247117+00:00 heroku[api]:←[0m Starting process with command `rails console` by hansin.ciputra@gmail.com
←[35m2015-07-16T07:37:17.172613+00:00 heroku[run.5048]:←[0m Awaiting client
←[35m2015-07-16T07:37:17.245003+00:00 heroku[run.5048]:←[0m Starting process with command `rails console`
←[35m2015-07-16T07:37:17.513511+00:00 heroku[run.5048]:←[0m State changed from starting to up
←[35m2015-07-16T07:37:20.511063+00:00 heroku[run.5048]:←[0m Process exited with status 1
←[35m2015-07-16T07:37:20.526444+00:00 heroku[run.5048]:←[0m State changed from up to complete
←[32m2015-07-16T07:53:39.298710+00:00 heroku[api]:←[0m Starting process with command `rails console` by hansin.ciputra@gmail.com
←[35m2015-07-16T07:53:43.115988+00:00 heroku[run.2827]:←[0m Awaiting client
←[35m2015-07-16T07:53:43.154089+00:00 heroku[run.2827]:←[0m Starting process with command `rails console`
←[35m2015-07-16T07:53:43.359493+00:00 heroku[run.2827]:←[0m State changed from starting to up
←[35m2015-07-16T07:53:45.772926+00:00 heroku[run.2827]:←[0m State changed from up to complete
←[35m2015-07-16T07:53:45.762212+00:00 heroku[run.2827]:←[0m Process exited with status 1
浏览了一段时间后,我发现使用以下命令可以更清楚地查找问题:
heroku run rails console
结果如下:
Your version of git is 1.8.4.. Which has serious security vulnerabilities.
More information here: https://blog.heroku.com/archives/2014/12/23/update_your_git_clients_on_windows_and_os_x
Running `rails console` attached to terminal... up, run.9621
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/inflector/inflections.rb:1:in `require': cannot load such f
ile -- thread_safe (LoadError)
from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/inflector/inflections.rb:1:in `<top (required)
>'
from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/inflections.rb:1:in `require'
from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/inflections.rb:1:in `<top (required)>'
from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/inflector/methods.rb:3:in `require'
from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/inflector/methods.rb:3:in `<top (required)>'
from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/dependencies/autoload.rb:1:in `require'
from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/dependencies/autoload.rb:1:in `<top (required)
>'
from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support.rb:25:in `require'
from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support.rb:25:in `<top (required)>'
from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.1.8/lib/rails.rb:5:in `require'
from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.1.8/lib/rails.rb:5:in `<top (required)>'
from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.1.8/lib/rails/all.rb:1:in `require'
from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.1.8/lib/rails/all.rb:1:in `<top (required)>'
from /app/config/application.rb:3:in `require'
from /app/config/application.rb:3:in `<top (required)>'
from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.1.8/lib/rails/commands/commands_tasks.rb:146:in `require'
from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.1.8/lib/rails/commands/commands_tasks.rb:146:in `require_application_and_e
nvironment!'
from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.1.8/lib/rails/commands/commands_tasks.rb:68:in `console'
from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.1.8/lib/rails/commands/commands_tasks.rb:40:in `run_command!'
from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.1.8/lib/rails/commands.rb:17:in `<top (required)>'
from /app/bin/rails:4:in `require'
from /app/bin/rails:4:in `<main>'
现在它说了一些关于 inflections.rb:1:in 'require cannot load such file -- thread_safe(Load Error)
不确定这意味着什么,但在那之后我尝试做一些这样的事情:
1. 安装 thread_safe gems -> 没有改变
2. 安装 activesuport gems -> 没有改变
3. 我尝试将 ruby 版本更改回 2.0.0,但它说 'activerecord-jdbcpostgresql-adapter' 需要 jruby .
请直言 在这一点上,我对 ruby、jruby 和 postgresql 仍然知之甚少。由于我的知识有限,我对可能导致这个问题的可能原因的数量感到震惊。
所以,如果有人能指出正确的方向,我将不胜感激!
在与@elithrar 的评论中进行了一些讨论后,我开始寻找为什么涉及 jruby 的答案,
原来这里有一个很长的初始安装ruby,系统文件路径(可以在这里访问edit syst path for windows)
结果指向 jruby\bin,因此我将系统路径更改为另一个 ruby 版本(我从铁路网站下载)。只有在检查 ruby -v
是否正确后,我才 运行 bundle install
.
这就解决了上面提到的所有问题,
gemfile \bin 不再指向 jruby.exe ,postgresql 的 gemfile 不再显示 activerecord-jdbcpostgresql-adapter
而是显示 gem "pg"
有一点问题但是当尝试做 bundle install
时,它告诉我 Your Ruby version is 2.1.5, but your Gemfile specified 2.0.0
只需编辑 gemfile,其中 ruby "2.0.0"
到 ruby "2.1.5"
修复了它
之后,按照教程 运行 顺利安装 ruby 并推送到 heroku
我的建议:
遇到同样问题的,请尝试查看系统路径中ruby的版本。它是否指向正确的目的地?
我是RoR的完全菜鸟,这是我第一次使用Ruby做网站开发,结果证明是相当具有挑战性的...第一次学习的变量数量是……有点过分。我试了 4 天才弄清楚 RoR 的正确设置,但是,似乎我总是遇到障碍。
无论如何,这是我目前遇到的问题..我正在使用 windows 7 with ruby version 2.1.5p273 and rails version 4.18 我打算将我的应用程序部署到 Heroku,所以我首先使用命令创建 rails 应用程序:
rails new myapp --database=postgresql
之后我检查了 gemfile
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.1.8'
# Use jdbcpostgresql as the database for Active Record
gem 'activerecord-jdbcpostgresql-adapter'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.3'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
gem 'therubyrhino'
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
# to solve tzinfo-data problem
gem 'tzinfo-data'
之后我用 git
存储应用程序git init
git add .
git commit -m "initial commit"
然后进入localhost:3000,页面显示ruby默认页面,说明本地正在工作只是发现, 但是,当我尝试将应用程序推送到 heroku 时出现问题。
我遵循这个命令:
heroku create
git push heroku master
heroku open
原来是出了点问题,页面显示"Application error"页 浏览了一段时间后,我发现了 heroku 日志功能并试图找出问题所在,我无法清楚地理解日志, 这是日志:
Your version of git is 1.8.4.. Which has serious security vulnerabilities.
More information here: https://blog.heroku.com/archives/2014/12/23/update_your_git_clients_on_windows_and_os_x
←[36m2015-07-16T06:28:44.016688+00:00 app[web.1]:←[0m /usr/bin/env: jruby.exe: No such file or directory
←[36m2015-07-16T06:28:44.779818+00:00 heroku[web.1]:←[0m Process exited with status 127
←[36m2015-07-16T06:28:44.798095+00:00 heroku[web.1]:←[0m State changed from starting to crashed
←[36m2015-07-16T06:28:44.799323+00:00 heroku[web.1]:←[0m State changed from crashed to starting
←[36m2015-07-16T06:28:48.416335+00:00 heroku[web.1]:←[0m Starting process with command `bin/rails server -p 12996 -e production`
←[36m2015-07-16T06:28:49.546664+00:00 app[web.1]:←[0m /usr/bin/env: jruby.exe: No such file or directory
←[36m2015-07-16T06:28:50.321059+00:00 heroku[web.1]:←[0m Process exited with status 127
←[36m2015-07-16T06:28:50.343084+00:00 heroku[web.1]:←[0m State changed from starting to crashed
←[33m2015-07-16T06:28:59.717663+00:00 heroku[router]:←[0m at=error code=H10 desc="App crashed" method=GET path="/" host=shinfithecraf
tcom.herokuapp.com request_id=38466811-0df1-418a-9e71-d8db0fb2787a fwd="36.82.86.169" dyno= connect= service= status=503 bytes=
←[33m2015-07-16T06:29:00.337303+00:00 heroku[router]:←[0m at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=sh
infithecraftcom.herokuapp.com request_id=5d15f883-9873-451e-aa2f-f23957f8f532 fwd="36.82.86.169" dyno= connect= service= status=503 b
ytes=
←[32m2015-07-16T06:35:50.725201+00:00 heroku[api]:←[0m Starting process with command `rails console` by myemail@gmail.com
←[35m2015-07-16T06:35:54.225700+00:00 heroku[run.4903]:←[0m Awaiting client
←[35m2015-07-16T06:35:54.257165+00:00 heroku[run.4903]:←[0m Starting process with command `rails console`
←[35m2015-07-16T06:35:54.635356+00:00 heroku[run.4903]:←[0m State changed from starting to up
←[35m2015-07-16T06:35:56.469745+00:00 heroku[run.4903]:←[0m Process exited with status 127
←[35m2015-07-16T06:35:56.507341+00:00 heroku[run.4903]:←[0m State changed from up to complete
←[36m2015-07-16T06:54:37.484647+00:00 heroku[web.1]:←[0m State changed from crashed to starting
←[36m2015-07-16T06:54:41.906605+00:00 heroku[web.1]:←[0m Starting process with command `bin/rails server -p 20328 -e production`
←[36m2015-07-16T06:54:44.137100+00:00 app[web.1]:←[0m /usr/bin/env: jruby.exe: No such file or directory
←[36m2015-07-16T06:54:45.035554+00:00 heroku[web.1]:←[0m Process exited with status 127
←[36m2015-07-16T06:54:45.047325+00:00 heroku[web.1]:←[0m State changed from starting to crashed
←[32m2015-07-16T07:18:35.619583+00:00 heroku[api]:←[0m Starting process with command `rails console` by myemail@gmail.com
←[35m2015-07-16T07:18:41.441770+00:00 heroku[run.9530]:←[0m Awaiting client
←[35m2015-07-16T07:18:41.482683+00:00 heroku[run.9530]:←[0m Starting process with command `rails console`
←[35m2015-07-16T07:18:44.122593+00:00 heroku[run.9530]:←[0m Process exited with status 127
←[35m2015-07-16T07:18:44.138803+00:00 heroku[run.9530]:←[0m State changed from up to complete
←[35m2015-07-16T07:18:41.633345+00:00 heroku[run.9530]:←[0m State changed from starting to up
我试图通过学习阅读日志文件来解决这个问题,发现问题其实在
←[36m2015-07-16T06:28:44.016688+00:00 app[web.1]:←[0m /usr/bin/env: jruby.exe: No such file or directory
所以我打开包,rails,在我的 bin 文件夹中搜索并将 "jruby.exe" 更改为 "ruby" ,我不确定为什么文件实际上使用 jruby.exe 但它似乎有效并且问题消失了,但是,在 heroku 上打开网页仍然显示 "Application error",再查看日志文件显示:
←[36m2015-07-16T07:21:14.512070+00:00 heroku[web.1]:←[0m Starting process with command `bin/rails server -p 19013 -e production`
←[36m2015-07-16T07:21:01.692937+00:00 heroku[web.1]:←[0m State changed from crashed to starting
←[36m2015-07-16T07:21:17.990817+00:00 app[web.1]:←[0m /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/infle
ctor/inflections.rb:1:in `require': cannot load such file -- thread_safe (LoadError)
←[36m2015-07-16T07:21:17.990839+00:00 app[web.1]:←[0m from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_suppor
t/inflector/inflections.rb:1:in `<top (required)>'
←[36m2015-07-16T07:21:17.990847+00:00 app[web.1]:←[0m from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_suppor
t/inflections.rb:1:in `<top (required)>'
←[36m2015-07-16T07:21:17.990849+00:00 app[web.1]:←[0m from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_suppor
t/inflector/methods.rb:3:in `require'
←[36m2015-07-16T07:21:17.990850+00:00 app[web.1]:←[0m from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_suppor
t/inflector/methods.rb:3:in `<top (required)>'
←[36m2015-07-16T07:21:17.990846+00:00 app[web.1]:←[0m from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_suppor
t/inflections.rb:1:in `require'
←[36m2015-07-16T07:21:17.990855+00:00 app[web.1]:←[0m from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_suppor
t.rb:25:in `require'
←[36m2015-07-16T07:21:17.990852+00:00 app[web.1]:←[0m from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_suppor
t/dependencies/autoload.rb:1:in `require'
←[36m2015-07-16T07:21:17.990858+00:00 app[web.1]:←[0m from /app/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.8/lib/action_dispatch.
rb:24:in `require'
←[36m2015-07-16T07:21:17.990862+00:00 app[web.1]:←[0m from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.1.8/lib/rails/commands/ser
ver.rb:3:in `require'
←[36m2015-07-16T07:21:17.990853+00:00 app[web.1]:←[0m from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_suppor
t/dependencies/autoload.rb:1:in `<top (required)>'
←[36m2015-07-16T07:21:17.990856+00:00 app[web.1]:←[0m from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_suppor
t.rb:25:in `<top (required)>'
←[36m2015-07-16T07:21:17.990863+00:00 app[web.1]:←[0m from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.1.8/lib/rails/commands/ser
ver.rb:3:in `<top (required)>'
←[36m2015-07-16T07:21:17.990859+00:00 app[web.1]:←[0m from /app/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.8/lib/action_dispatch.
rb:24:in `<top (required)>'
←[36m2015-07-16T07:21:17.990865+00:00 app[web.1]:←[0m from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.1.8/lib/rails/commands/com
mands_tasks.rb:128:in `require'
←[36m2015-07-16T07:21:17.990869+00:00 app[web.1]:←[0m from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.1.8/lib/rails/commands/com
mands_tasks.rb:40:in `run_command!'
←[36m2015-07-16T07:21:17.990867+00:00 app[web.1]:←[0m from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.1.8/lib/rails/commands/com
mands_tasks.rb:74:in `server'
←[36m2015-07-16T07:21:17.990875+00:00 app[web.1]:←[0m from bin/rails:4:in `<main>'
←[36m2015-07-16T07:21:17.990866+00:00 app[web.1]:←[0m from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.1.8/lib/rails/commands/com
mands_tasks.rb:128:in `require_command!'
←[36m2015-07-16T07:21:17.990870+00:00 app[web.1]:←[0m from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.1.8/lib/rails/commands.rb:
17:in `<top (required)>'
←[36m2015-07-16T07:21:17.990873+00:00 app[web.1]:←[0m from bin/rails:4:in `require'
←[36m2015-07-16T07:21:18.817510+00:00 heroku[web.1]:←[0m Process exited with status 1
←[36m2015-07-16T07:21:18.834033+00:00 heroku[web.1]:←[0m State changed from starting to crashed
←[32m2015-07-16T07:21:50.556289+00:00 heroku[api]:←[0m Starting process with command `rails console` by hansin.ciputra@gmail.com
←[35m2015-07-16T07:21:54.774130+00:00 heroku[run.3007]:←[0m Awaiting client
←[35m2015-07-16T07:21:55.080890+00:00 heroku[run.3007]:←[0m State changed from starting to up
←[35m2015-07-16T07:21:55.047872+00:00 heroku[run.3007]:←[0m Starting process with command `rails console`
←[35m2015-07-16T07:21:57.836920+00:00 heroku[run.3007]:←[0m State changed from up to complete
←[35m2015-07-16T07:21:57.818989+00:00 heroku[run.3007]:←[0m Process exited with status 1
←[32m2015-07-16T07:37:13.247117+00:00 heroku[api]:←[0m Starting process with command `rails console` by hansin.ciputra@gmail.com
←[35m2015-07-16T07:37:17.172613+00:00 heroku[run.5048]:←[0m Awaiting client
←[35m2015-07-16T07:37:17.245003+00:00 heroku[run.5048]:←[0m Starting process with command `rails console`
←[35m2015-07-16T07:37:17.513511+00:00 heroku[run.5048]:←[0m State changed from starting to up
←[35m2015-07-16T07:37:20.511063+00:00 heroku[run.5048]:←[0m Process exited with status 1
←[35m2015-07-16T07:37:20.526444+00:00 heroku[run.5048]:←[0m State changed from up to complete
←[32m2015-07-16T07:53:39.298710+00:00 heroku[api]:←[0m Starting process with command `rails console` by hansin.ciputra@gmail.com
←[35m2015-07-16T07:53:43.115988+00:00 heroku[run.2827]:←[0m Awaiting client
←[35m2015-07-16T07:53:43.154089+00:00 heroku[run.2827]:←[0m Starting process with command `rails console`
←[35m2015-07-16T07:53:43.359493+00:00 heroku[run.2827]:←[0m State changed from starting to up
←[35m2015-07-16T07:53:45.772926+00:00 heroku[run.2827]:←[0m State changed from up to complete
←[35m2015-07-16T07:53:45.762212+00:00 heroku[run.2827]:←[0m Process exited with status 1
浏览了一段时间后,我发现使用以下命令可以更清楚地查找问题:
heroku run rails console
结果如下:
Your version of git is 1.8.4.. Which has serious security vulnerabilities.
More information here: https://blog.heroku.com/archives/2014/12/23/update_your_git_clients_on_windows_and_os_x
Running `rails console` attached to terminal... up, run.9621
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/inflector/inflections.rb:1:in `require': cannot load such f
ile -- thread_safe (LoadError)
from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/inflector/inflections.rb:1:in `<top (required)
>'
from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/inflections.rb:1:in `require'
from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/inflections.rb:1:in `<top (required)>'
from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/inflector/methods.rb:3:in `require'
from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/inflector/methods.rb:3:in `<top (required)>'
from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/dependencies/autoload.rb:1:in `require'
from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/dependencies/autoload.rb:1:in `<top (required)
>'
from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support.rb:25:in `require'
from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support.rb:25:in `<top (required)>'
from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.1.8/lib/rails.rb:5:in `require'
from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.1.8/lib/rails.rb:5:in `<top (required)>'
from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.1.8/lib/rails/all.rb:1:in `require'
from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.1.8/lib/rails/all.rb:1:in `<top (required)>'
from /app/config/application.rb:3:in `require'
from /app/config/application.rb:3:in `<top (required)>'
from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.1.8/lib/rails/commands/commands_tasks.rb:146:in `require'
from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.1.8/lib/rails/commands/commands_tasks.rb:146:in `require_application_and_e
nvironment!'
from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.1.8/lib/rails/commands/commands_tasks.rb:68:in `console'
from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.1.8/lib/rails/commands/commands_tasks.rb:40:in `run_command!'
from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.1.8/lib/rails/commands.rb:17:in `<top (required)>'
from /app/bin/rails:4:in `require'
from /app/bin/rails:4:in `<main>'
现在它说了一些关于 inflections.rb:1:in 'require cannot load such file -- thread_safe(Load Error)
不确定这意味着什么,但在那之后我尝试做一些这样的事情: 1. 安装 thread_safe gems -> 没有改变 2. 安装 activesuport gems -> 没有改变 3. 我尝试将 ruby 版本更改回 2.0.0,但它说 'activerecord-jdbcpostgresql-adapter' 需要 jruby .
请直言 在这一点上,我对 ruby、jruby 和 postgresql 仍然知之甚少。由于我的知识有限,我对可能导致这个问题的可能原因的数量感到震惊。 所以,如果有人能指出正确的方向,我将不胜感激!
在与@elithrar 的评论中进行了一些讨论后,我开始寻找为什么涉及 jruby 的答案,
原来这里有一个很长的初始安装ruby,系统文件路径(可以在这里访问edit syst path for windows)
结果指向 jruby\bin,因此我将系统路径更改为另一个 ruby 版本(我从铁路网站下载)。只有在检查 ruby -v
是否正确后,我才 运行 bundle install
.
这就解决了上面提到的所有问题,
gemfile \bin 不再指向 jruby.exe ,postgresql 的 gemfile 不再显示 activerecord-jdbcpostgresql-adapter
而是显示 gem "pg"
有一点问题但是当尝试做 bundle install
时,它告诉我 Your Ruby version is 2.1.5, but your Gemfile specified 2.0.0
只需编辑 gemfile,其中 ruby "2.0.0"
到 ruby "2.1.5"
修复了它
之后,按照教程 运行 顺利安装 ruby 并推送到 heroku
我的建议:
遇到同样问题的,请尝试查看系统路径中ruby的版本。它是否指向正确的目的地?