rails crontab rake javascript运行时找不到

时间:2013-07-15 08:38:58

标签: javascript ruby-on-rails runtime rake crontab

第一,

gem 'libv8', '~> 3.11.8'===libv8 (~> 3.11.8.12)
gem 'execjs'==========execjs (>= 0.3.0)
gem 'therubyracer'====therubyracer (0.11.4)

存在于Gemfile

Gemfile.lock show (libv8 (~> 3.11.8.12),execjs (>= 0.3.0),therubyracer (0.11.4))

centos5.7已经有了nodejs 当我使用rake但是crontab错误时,Myproject没问题。

我的运行.sh类型文件

#!/bin/bash
export PATH=$PATH:/usr/local/bin
cd /abc && bundle exec rake RAILS_ENV=production sync:abc

错误

Warning: NLS_LANG is not set. fallback to US7ASCII.
rake aborted!
Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes.
/opt/app/ruby/lib/ruby/gems/1.9.1/gems/execjs-1.4.0/lib/execjs/runtimes.rb:51:in autodetect'
/opt/app/ruby/lib/ruby/gems/1.9.1/gems/execjs-1.4.0/lib/execjs.rb:5:inmodule:ExecJS'
/opt/app/ruby/lib/ruby/gems/1.9.1/gems/execjs-1.4.0/lib/execjs.rbin '
/opt/app/ruby/lib/ruby/gems/1.9.1/gems/activesupport-3.1.12/lib/active_support/dependencies.rb:240:inrequire'
/opt/app/ruby/lib/ruby/gems/1.9.1/gems/activesupport-3.1.12/lib/active_support/dependencies.rb:240:in block in require'
/opt/app/ruby/lib/ruby/gems/1.9.1/gems/activesupport-3.1.12/lib/active_support/dependencies.rb:223:inblock in load_dependency'

2 个答案:

答案 0 :(得分:0)

你需要安装nodejs,因为gem具有它的依赖性。您将在此处获取安装库链接列表 https://github.com/sstephenson/execjs

但正如您提到的那样已经安装了nodjs。您可以在将gem安装到系统中时给出lib和include路径。

如果您是unbuntu用户,可以通过命令

进行安装

apt-get install nodejs

答案 1 :(得分:0)

找出使用which node安装节点的位置,并将该文件夹添加到bash脚本中的路径中(通常为/ usr / local / bin)。

export PATH=$PATH:/usr/local/bin

如果您直接使用节点,只需拨打/usr/local/bin/node foo而不是node foo即可。

相关问题