简体   繁体   中英

Ruby(2.1.5p273) on Rails (4.18) deploying on Heroku Application error inflections.rb:1:in `require': cannot load such file — thread _safe

I am a complete noob on RoR, this is the first time I using Ruby for website development, It turned out to be quite challenging... The number of variables to learn for the first time is...a bit to much. I have tried for 4 days only to figure out the correct setting for RoR however, it seems I always hit a roadblock.

Anyway, this is the problem that I currently encounter.. I am using windows 7 with ruby version 2.1.5p273 and rails version 4.18 I intend on deploying my app to Heroku, so I first create the rails application with command:

rails new myapp --database=postgresql

after that I check the 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'

after that I store the app with git

git init
git add .
git commit -m "initial commit"

then going to localhost:3000 and the page display the ruby default page, indicating that the local is working just find, Problem arise however when I try to push the app to heroku.

I follow this command :

heroku create
git push heroku master
heroku open

It turned out something is wrong and the page shows "Application error" Page After browsing a while i found out about heroku logs function and trying to find out the problem, I cant understand the logs quite clearly, here are the logs:

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

I tried to solve this problem by learning to read the log file and found out that the problem is actually in

  ←[36m2015-07-16T06:28:44.016688+00:00 app[web.1]:←[0m /usr/bin/env: jruby.exe: No such file or directory

So I open the bundle,rails,rake in my bin folder and change the "jruby.exe" to "ruby" , I am not sure why the files acually using jruby.exe but it seems to work and the problem gone, however, opening the webpage on heroku still show "Application error", another look at the log file shows:

←[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

After browsing a while i found out that I can look for the problem more clearly by using the command:

heroku run rails console

and here are the results:

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>'

now It says something about the inflections.rb:1:in 'require cannot load such file -- thread_safe(Load Error)

Not sure what this means but after that I try to do some of this stuff : 1. install thread_safe gems -> nothing changed 2. install activesuport gems -> nothing changed 3. I tried changing the ruby version back to 2.0.0 but it said that 'activerecord-jdbcpostgresql-adapter' require jruby .

please bare that At this point I am still have so little clue about ruby,jruby, and postgresql. and with this limited knowledge of mine, I am devastated by the number of possible reasons that might be the reasons of this problem. So please if anyone can point me to the right directions I will be very grateful!

After some discussion in the comment with @elithrar i began looking for the answer of why jruby is involved, It turned out somehere a long the initial installation of ruby, the system file path(which can be accessed here edit syst path for windows ) turned out to be pointing to jruby\\bin, thus I changed the syst path to another ruby version(which I download from rail website). Only after checking that ruby -v is correct I run bundle install .

This turned solving all the problems mentioned above, The gemfile \\bin no longer pointing to jruby.exe , and the gemfile for postgresql no longer shows activerecord-jdbcpostgresql-adapter instead it show gem "pg"

there is a bit problem however when trying to do bundle install , it tells me that Your Ruby version is 2.1.5, but your Gemfile specified 2.0.0 simply edit the gemfile where ruby "2.0.0" to ruby "2.1.5" fixed it

afterwards, installing ruby and pushing it to heroku by following tutorials runs smoothly

My advice:

For those having the same issues, try to look at the version of ruby in your system path. Has it point to the right destination?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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