RHEL安装rails后启动报错
Posted jason_bo
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了RHEL安装rails后启动报错相关的知识,希望对你有一定的参考价值。
[root@redhat7 demo]# rails server
/usr/local/rvm/gems/ruby-2.4.1/gems/bundler-1.16.0.pre.2/lib/bundler/runtime.rb:86:in `rescue in block (2 levels) in require\': There was an error while trying to load the gem \'uglifier\'. (Bundler::GemRequireError)
Gem Load Error is: Could not find a javascript runtime. See https://github.com/rails/execjs for a list of available runtimes.
Backtrace for gem load error is:
/usr/local/rvm/gems/ruby-2.4.1/gems/execjs-2.7.0/lib/execjs/runtimes.rb:58:in `autodetect\'
/usr/local/rvm/gems/ruby-2.4.1/gems/execjs-2.7.0/lib/execjs.rb:5:in `<module:ExecJS>\'
/usr/local/rvm/gems/ruby-2.4.1/gems/execjs-2.7.0/lib/execjs.rb:4:in `<top (required)>\'
/usr/local/rvm/gems/ruby-2.4.1/gems/uglifier-3.2.0/lib/uglifier.rb:5:in `require\'
/usr/local/rvm/gems/ruby-2.4.1/gems/uglifier-3.2.0/lib/uglifier.rb:5:in `<top (required)>\'
/usr/local/rvm/gems/ruby-2.4.1/gems/bundler-1.16.0.pre.2/lib/bundler/runtime.rb:83:in `require\'
/usr/local/rvm/gems/ruby-2.4.1/gems/bundler-1.16.0.pre.2/lib/bundler/runtime.rb:83:in `block (2 levels) in require\'
/usr/local/rvm/gems/ruby-2.4.1/gems/bundler-1.16.0.pre.2/lib/bundler/runtime.rb:78:in `each\'
/usr/local/rvm/gems/ruby-2.4.1/gems/bundler-1.16.0.pre.2/lib/bundler/runtime.rb:78:in `block in require\'
/usr/local/rvm/gems/ruby-2.4.1/gems/bundler-1.16.0.pre.2/lib/bundler/runtime.rb:67:in `each\'
/usr/local/rvm/gems/ruby-2.4.1/gems/bundler-1.16.0.pre.2/lib/bundler/runtime.rb:67:in `require\'
/usr/local/rvm/gems/ruby-2.4.1/gems/bundler-1.16.0.pre.2/lib/bundler.rb:114:in `require\'
/usr/local/jianbo/demo/config/application.rb:7:in `<top (required)>\'
/usr/local/rvm/gems/ruby-2.4.1/gems/railties-5.1.4/lib/rails/commands/server/server_command.rb:133:in `require\'
/usr/local/rvm/gems/ruby-2.4.1/gems/railties-5.1.4/lib/rails/commands/server/server_command.rb:133:in `block in perform\'
/usr/local/rvm/gems/ruby-2.4.1/gems/railties-5.1.4/lib/rails/commands/server/server_command.rb:130:in `tap\'
/usr/local/rvm/gems/ruby-2.4.1/gems/railties-5.1.4/lib/rails/commands/server/server_command.rb:130:in `perform\'
/usr/local/rvm/gems/ruby-2.4.1/gems/thor-0.20.0/lib/thor/command.rb:27:in `run\'
/usr/local/rvm/gems/ruby-2.4.1/gems/thor-0.20.0/lib/thor/invocation.rb:126:in `invoke_command\'
/usr/local/rvm/gems/ruby-2.4.1/gems/thor-0.20.0/lib/thor.rb:387:in `dispatch\'
/usr/local/rvm/gems/ruby-2.4.1/gems/railties-5.1.4/lib/rails/command/base.rb:63:in `perform\'
/usr/local/rvm/gems/ruby-2.4.1/gems/railties-5.1.4/lib/rails/command.rb:44:in `invoke\'
/usr/local/rvm/gems/ruby-2.4.1/gems/railties-5.1.4/lib/rails/commands.rb:16:in `<top (required)>\'
/usr/local/jianbo/demo/bin/rails:9:in `require\'
/usr/local/jianbo/demo/bin/rails:9:in `<top (required)>\'
/usr/local/rvm/gems/ruby-2.4.1/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `load\'
/usr/local/rvm/gems/ruby-2.4.1/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `call\'
/usr/local/rvm/gems/ruby-2.4.1/gems/spring-2.0.2/lib/spring/client/command.rb:7:in `call\'
/usr/local/rvm/gems/ruby-2.4.1/gems/spring-2.0.2/lib/spring/client.rb:30:in `run\'
/usr/local/rvm/gems/ruby-2.4.1/gems/spring-2.0.2/bin/spring:49:in `<top (required)>\'
/usr/local/rvm/gems/ruby-2.4.1/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `load\'
/usr/local/rvm/gems/ruby-2.4.1/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `<top (required)>\'
/usr/local/jianbo/demo/bin/spring:15:in `require\'
/usr/local/jianbo/demo/bin/spring:15:in `<top (required)>\'
bin/rails:3:in `load\'
bin/rails:3:in `<main>\'
Bundler Error Backtrace:
from /usr/local/rvm/gems/ruby-2.4.1/gems/bundler-1.16.0.pre.2/lib/bundler/runtime.rb:82:in `block (2 levels) in require\'
from /usr/local/rvm/gems/ruby-2.4.1/gems/bundler-1.16.0.pre.2/lib/bundler/runtime.rb:78:in `each\'
from /usr/local/rvm/gems/ruby-2.4.1/gems/bundler-1.16.0.pre.2/lib/bundler/runtime.rb:78:in `block in require\'
from /usr/local/rvm/gems/ruby-2.4.1/gems/bundler-1.16.0.pre.2/lib/bundler/runtime.rb:67:in `each\'
from /usr/local/rvm/gems/ruby-2.4.1/gems/bundler-1.16.0.pre.2/lib/bundler/runtime.rb:67:in `require\'
from /usr/local/rvm/gems/ruby-2.4.1/gems/bundler-1.16.0.pre.2/lib/bundler.rb:114:in `require\'
from /usr/local/jianbo/demo/config/application.rb:7:in `<top (required)>\'
from /usr/local/rvm/gems/ruby-2.4.1/gems/railties-5.1.4/lib/rails/commands/server/server_command.rb:133:in `require\'
from /usr/local/rvm/gems/ruby-2.4.1/gems/railties-5.1.4/lib/rails/commands/server/server_command.rb:133:in `block in perform\'
from /usr/local/rvm/gems/ruby-2.4.1/gems/railties-5.1.4/lib/rails/commands/server/server_command.rb:130:in `tap\'
from /usr/local/rvm/gems/ruby-2.4.1/gems/railties-5.1.4/lib/rails/commands/server/server_command.rb:130:in `perform\'
from /usr/local/rvm/gems/ruby-2.4.1/gems/thor-0.20.0/lib/thor/command.rb:27:in `run\'
from /usr/local/rvm/gems/ruby-2.4.1/gems/thor-0.20.0/lib/thor/invocation.rb:126:in `invoke_command\'
from /usr/local/rvm/gems/ruby-2.4.1/gems/thor-0.20.0/lib/thor.rb:387:in `dispatch\'
from /usr/local/rvm/gems/ruby-2.4.1/gems/railties-5.1.4/lib/rails/command/base.rb:63:in `perform\'
from /usr/local/rvm/gems/ruby-2.4.1/gems/railties-5.1.4/lib/rails/command.rb:44:in `invoke\'
from /usr/local/rvm/gems/ruby-2.4.1/gems/railties-5.1.4/lib/rails/commands.rb:16:in `<top (required)>\'
from /usr/local/jianbo/demo/bin/rails:9:in `require\'
from /usr/local/jianbo/demo/bin/rails:9:in `<top (required)>\'
from /usr/local/rvm/gems/ruby-2.4.1/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `load\'
from /usr/local/rvm/gems/ruby-2.4.1/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `call\'
from /usr/local/rvm/gems/ruby-2.4.1/gems/spring-2.0.2/lib/spring/client/command.rb:7:in `call\'
from /usr/local/rvm/gems/ruby-2.4.1/gems/spring-2.0.2/lib/spring/client.rb:30:in `run\'
from /usr/local/rvm/gems/ruby-2.4.1/gems/spring-2.0.2/bin/spring:49:in `<top (required)>\'
from /usr/local/rvm/gems/ruby-2.4.1/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `load\'
from /usr/local/rvm/gems/ruby-2.4.1/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `<top (required)>\'
from /usr/local/jianbo/demo/bin/spring:15:in `require\'
from /usr/local/jianbo/demo/bin/spring:15:in `<top (required)>\'
from bin/rails:3:in `load\'
from bin/rails:3:in `<main>\'
解决办法
1.安装execjs、therubyracer
gem install execjs
gem install therubyracer
2.安装nodejs
由于RHEL中没有这个包,其他安装方式太麻烦,找了半天决定使用
EPEL(什么是EPEL,参考我另一篇http://www.cnblogs.com/jasonboboblog/p/7535223.html)
首先要安装epel,直接用yum install epel
安装完后再用 yum install nodejs 就完成了,之后再用rails server
大功造成
以上是关于RHEL安装rails后启动报错的主要内容,如果未能解决你的问题,请参考以下文章