我的电脑系统及Rails版本:CentOS 7,Rails4.1.6,Ruby2.0.0
1启动服务器后报错
#rails server
刚建的新项目,启动服务报错:
/home/oss/.gem/ruby/gems/execjs-2.2.1/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 /home/oss/.gem/ruby/gems/execjs-2.2.1/lib/execjs.rb:5:in `<module:ExecJS>’
from /home/oss/.gem/ruby/gems/execjs-2.2.1/lib/execjs.rb:4:in `<top (required)等等
解决方法:
方法一:
1实际报错信息都已经给出来了解决链接https://github.com/sstephenson/execjs,在上边的报错信息中
看过后直接安装这个就行了therubyracer
参考该插件的说明:https://github.com/sstephenson/execjs#readme
安装命令
#gem install therubyracer
过程的成功的信息如下:
[oss@localhost t9]$ gem install therubyracer
Fetching: ref-1.0.5.gem (100%)
Successfully installed ref-1.0.5
Fetching: libv8-3.16.14.7-x86_64-linux.gem (100%)
Successfully installed libv8-3.16.14.7-x86_64-linux
Fetching: therubyracer-0.12.1.gem (100%)
Building native extensions. This could take a while…
Successfully installed therubyracer-0.12.1
Parsing documentation for ref-1.0.5
Installing ri documentation for ref-1.0.5
Parsing documentation for libv8-3.16.14.7-x86_64-linux
Installing ri documentation for libv8-3.16.14.7-x86_64-linux
Parsing documentation for therubyracer-0.12.1
Installing ri documentation for therubyracer-0.12.1
Done installing documentation for ref, libv8, therubyracer after 1 seconds
3 gems installed
说明没有问题,安张了三个gem都成功了
方法二:
(1)修改你新建的项目的根目录下的Gemfile
# vi Gemfile
找到下面这行,把注释去掉,
# gem ‘therubyracer’, platforms: :ruby
修改为
gem ‘therubyracer’, platforms: :ruby
保存退出 #wq
(2)用bundle安装即可
#bundle install
参考rails4 Guides:http://guides.ruby-china.org/getting_started.html
方法三:
(3)把execjs和therubyracer都不要了,卸载掉然后安装nodejs即可
官网http://nodejs.org/
下载后安装就行了
#tar -xzvf node-v0.10.31.tar.gz
#cd node-v0.10.31
# ./configure
#make
#make install
Rails 的详细介绍:请点这里
Rails 的下载地址:请点这里
Ubuntu下Apache服务器安装以及使用Passenger插件部署Rails应用 http://www.linuxidc.com/Linux/2012-12/75230.htm
Ubuntu下搭建Ruby On Rails http://www.linuxidc.com/Linux/2012-06/61981.htm
本文永久更新链接地址:http://www.linuxidc.com/Linux/2014-09/106771.htm