2014年6月23日月曜日

railsをサーバーに載せたらエラー出たときの対応

Macでrailsのアプリケーションを書いてて、一通りできたのでCentOSに載せたらエラー出たので、そのときの対応です。

環境
MacOS 10.9
rails4.1.0
CentOS6.5

まずはgithubからcheckoutしてきてbundle installを実施
# bundle install --path vendor/bundle
Fetching gem metadata from https://rubygems.org/..........
Fetching additional metadata from https://rubygems.org/..
Installing rake (10.3.2)
Installing i18n (0.6.9)
Using json (1.8.1)
Installing minitest (5.3.4)
Installing thread_safe (0.3.4)
Installing tzinfo (1.2.1)
Installing activesupport (4.1.0)
Installing builder (3.2.2)
Installing erubis (2.7.0)
Installing actionview (4.1.0)
Installing rack (1.5.2)
Installing rack-test (0.6.2)
Installing actionpack (4.1.0)
Installing mime-types (1.25.1)
Installing polyglot (0.3.5)
Installing treetop (1.4.15)
Installing mail (2.5.4)
Installing actionmailer (4.1.0)
Installing activemodel (4.1.0)
Installing arel (5.0.1.20140414130214)
Installing activerecord (4.1.0)
Installing coffee-script-source (1.7.0)
Installing execjs (2.2.0)
Installing coffee-script (2.2.0)
Installing thor (0.19.1)
Installing railties (4.1.0)
Installing coffee-rails (4.0.1)
Installing hike (1.2.3)
Installing multi_json (1.10.1)
Installing jbuilder (2.1.1)
Installing jquery-rails (3.1.0)
Using bundler (1.5.3)
Installing tilt (1.4.1)
Installing sprockets (2.11.0)
Installing sprockets-rails (2.1.3)
Installing rails (4.1.0)
Installing rdoc (4.1.1)
Installing sass (3.2.19)
Installing sass-rails (4.0.3)
Installing sdoc (0.4.0)
Installing spring (1.1.3)
Installing turbolinks (2.2.2)
Installing uglifier (2.5.1)
Your bundle is complete!
It was installed into ./vendor/bundle
Post-install message from rdoc:
Depending on your version of ruby, you may need to install ruby rdoc/ri data:

 
<= 1.8.6 : unsupported
 = 1.8.7 : gem install rdoc-data; rdoc-data --install
 = 1.9.1 : gem install rdoc-data; rdoc-data --install
>= 1.9.2 : nothing to do! Yay!

serverを起動するとエラーになった。
# bundle exec rails s
/usr/local/app/app/script/simulator/vendor/bundle/ruby/2.1.0/gems/execjs-2.2.0/lib/execjs/runtimes.rb:51:in `autodetect': Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable)
 from /usr/local/app/app/script/simulator/vendor/bundle/ruby/2.1.0/gems/execjs-2.2.0/lib/execjs.rb:5:in `'
 from /usr/local/app/app/script/simulator/vendor/bundle/ruby/2.1.0/gems/execjs-2.2.0/lib/execjs.rb:4:in `'
 from /usr/local/app/app/script/simulator/vendor/bundle/ruby/2.1.0/gems/uglifier-2.5.1/lib/uglifier.rb:3:in `require'
 from /usr/local/app/app/script/simulator/vendor/bundle/ruby/2.1.0/gems/uglifier-2.5.1/lib/uglifier.rb:3:in `'
 from /opt/infra/ruby/lib64/ruby/gems/2.1.0/gems/bundler-1.5.3/lib/bundler/runtime.rb:76:in `require'
 from /opt/infra/ruby/lib64/ruby/gems/2.1.0/gems/bundler-1.5.3/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
 from /opt/infra/ruby/lib64/ruby/gems/2.1.0/gems/bundler-1.5.3/lib/bundler/runtime.rb:72:in `each'
 from /opt/infra/ruby/lib64/ruby/gems/2.1.0/gems/bundler-1.5.3/lib/bundler/runtime.rb:72:in `block in require'
 from /opt/infra/ruby/lib64/ruby/gems/2.1.0/gems/bundler-1.5.3/lib/bundler/runtime.rb:61:in `each'
 from /opt/infra/ruby/lib64/ruby/gems/2.1.0/gems/bundler-1.5.3/lib/bundler/runtime.rb:61:in `require'
 from /opt/infra/ruby/lib64/ruby/gems/2.1.0/gems/bundler-1.5.3/lib/bundler.rb:131:in `require'
 from /usr/local/app/app/script/simulator/config/application.rb:14:in `'
 from /usr/local/app/app/script/simulator/vendor/bundle/ruby/2.1.0/gems/railties-4.1.0/lib/rails/commands/commands_tasks.rb:79:in `require'
 from /usr/local/app/app/script/simulator/vendor/bundle/ruby/2.1.0/gems/railties-4.1.0/lib/rails/commands/commands_tasks.rb:79:in `block in server'
 from /usr/local/app/app/script/simulator/vendor/bundle/ruby/2.1.0/gems/railties-4.1.0/lib/rails/commands/commands_tasks.rb:76:in `tap'
 from /usr/local/app/app/script/simulator/vendor/bundle/ruby/2.1.0/gems/railties-4.1.0/lib/rails/commands/commands_tasks.rb:76:in `server'
 from /usr/local/app/app/script/simulator/vendor/bundle/ruby/2.1.0/gems/railties-4.1.0/lib/rails/commands/commands_tasks.rb:40:in `run_command!'
 from /usr/local/app/app/script/simulator/vendor/bundle/ruby/2.1.0/gems/railties-4.1.0/lib/rails/commands.rb:17:in `'
 from /usr/local/app/app/script/simulator/bin/rails:8:in `require'
 from /usr/local/app/app/script/simulator/bin/rails:8:in `'
 from /usr/local/app/app/script/simulator/vendor/bundle/ruby/2.1.0/gems/spring-1.1.3/lib/spring/client/rails.rb:27:in `load'
 from /usr/local/app/app/script/simulator/vendor/bundle/ruby/2.1.0/gems/spring-1.1.3/lib/spring/client/rails.rb:27:in `call'
 from /usr/local/app/app/script/simulator/vendor/bundle/ruby/2.1.0/gems/spring-1.1.3/lib/spring/client/command.rb:7:in `call'
 from /usr/local/app/app/script/simulator/vendor/bundle/ruby/2.1.0/gems/spring-1.1.3/lib/spring/client.rb:26:in `run'
 from /usr/local/app/app/script/simulator/vendor/bundle/ruby/2.1.0/gems/spring-1.1.3/bin/spring:48:in `'
 from /usr/local/app/app/script/simulator/vendor/bundle/ruby/2.1.0/gems/spring-1.1.3/lib/spring/binstub.rb:11:in `load'
 from /usr/local/app/app/script/simulator/vendor/bundle/ruby/2.1.0/gems/spring-1.1.3/lib/spring/binstub.rb:11:in `'
 from /usr/local/app/app/script/simulator/bin/spring:16:in `require'
 from /usr/local/app/app/script/simulator/bin/spring:16:in `'
 from bin/rails:3:in `load'
 from bin/rails:3:in `
'

Could not find a JavaScript runtimeのエラーが出てるようなのでJSのモジュールがあるか確認したところなさそう。
ls vendor/bundle/ruby/2.1.0/gems/
actionmailer-4.1.0   arel-5.0.1.20140414130214   execjs-2.2.0        mime-types-1.25.1  rails-4.1.0       sdoc-0.4.0             tilt-1.4.1
actionpack-4.1.0     builder-3.2.2               hike-1.2.3          minitest-5.3.4     railties-4.1.0    spring-1.1.3           treetop-1.4.15
actionview-4.1.0     coffee-rails-4.0.1          i18n-0.6.9          multi_json-1.10.1  rake-10.3.2       sprockets-2.11.0       turbolinks-2.2.2
activemodel-4.1.0    coffee-script-2.2.0         jbuilder-2.1.1      polyglot-0.3.5     rdoc-4.1.1        sprockets-rails-2.1.3  tzinfo-1.2.1
activerecord-4.1.0   coffee-script-source-1.7.0  jquery-rails-3.1.0  rack-1.5.2         sass-3.2.19       thor-0.19.1            uglifier-2.5.1
activesupport-4.1.0  erubis-2.7.0                mail-2.5.4          rack-test-0.6.2    sass-rails-4.0.3 

Gemfileに以下を追加
gem 'therubyracer'
再度インストールを実施。無事に入ったげ。
# bundle install --path vendor/bundle
Fetching gem metadata from https://rubygems.org/...........
Fetching additional metadata from https://rubygems.org/..
Resolving dependencies...
Using rake (10.3.2)
Using i18n (0.6.9)
Using json (1.8.1)
Using minitest (5.3.4)
Using thread_safe (0.3.4)
Using tzinfo (1.2.1)
Using activesupport (4.1.0)
Using builder (3.2.2)
Using erubis (2.7.0)
Using actionview (4.1.0)
Using rack (1.5.2)
Using rack-test (0.6.2)
Using actionpack (4.1.0)
Using mime-types (1.25.1)
Using polyglot (0.3.5)
Using treetop (1.4.15)
Using mail (2.5.4)
Using actionmailer (4.1.0)
Using activemodel (4.1.0)
Using arel (5.0.1.20140414130214)
Using activerecord (4.1.0)
Using bundler (1.5.3)
Using coffee-script-source (1.7.0)
Using execjs (2.2.0)
Using coffee-script (2.2.0)
Using thor (0.19.1)
Using railties (4.1.0)
Using coffee-rails (4.0.1)
Using hike (1.2.3)
Using multi_json (1.10.1)
Using jbuilder (2.1.1)
Using jquery-rails (3.1.0)
Installing libv8 (3.16.14.3)
Using tilt (1.4.1)
Using sprockets (2.11.0)
Using sprockets-rails (2.1.3)
Using rails (4.1.0)
Using rdoc (4.1.1)
Installing ref (1.0.5)
Using sass (3.2.19)
Using sass-rails (4.0.3)
Using sdoc (0.4.0)
Using spring (1.1.3)
Installing therubyracer (0.12.1)
Using turbolinks (2.2.2)
Using uglifier (2.5.1)
Your bundle is complete!
It was installed into ./vendor/bundle

再度サーバーを起動。無事に起動した。
# bundle exec rails s
=> Booting WEBrick
=> Rails 4.1.0 application starting in development on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Notice: server is listening on all interfaces (0.0.0.0). Consider using 127.0.0.1 (--binding option)
=> Ctrl-C to shutdown server
[2014-06-19 10:27:39] INFO  WEBrick 1.3.1
[2014-06-19 10:27:39] INFO  ruby 2.1.0 (2013-12-25) [x86_64-linux-gnu]
[2014-06-19 10:27:39] INFO  WEBrick::HTTPServer#start: pid=29686 port=3000


参考URL
http://mymemo.weby117.com/develop/ruby-geminstall-error_3.html

0 件のコメント:

コメントを投稿