6
votes

I have a problem with Rails 4.1.7, Phusion Passenger version 4.0.53, nginx/1.6.2 in ubuntu server 14.04 AWS Instance, but With rails server works well.

error.log

App 2029 stdout: App 2029 stderr: sh: 1: App 2029 stderr: env: not found App 2029 stderr: App 2029 stdout: [ 2014-11-12 16:12:26.1580 1979/7feff83f9700 Pool2/Implementation.cpp:287 ]: Could not spawn process for application /home/ubuntu/apps/doger: An error occured while starting up the preloader. Error ID: b7381860 Error details saved to: /tmp/passenger-error-SUjzpL.html Message from application: Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable)
/var/lib/gems/1.9.1/gems/execjs-2.2.2/lib/execjs/runtimes.rb:51:in autodetect'
/var/lib/gems/1.9.1/gems/execjs-2.2.2/lib/execjs.rb:5:in
'
/var/lib/gems/1.9.1/gems/execjs-2.2.2/lib/execjs.rb:4:in <top (required)>'
/var/lib/gems/1.9.1/gems/uglifier-2.5.3/lib/uglifier.rb:3:in
require' /var/lib/gems/1.9.1/gems/uglifier-2.5.3/lib/uglifier.rb:3:in <top (required)>'
/var/lib/gems/1.9.1/gems/bundler-1.7.6/lib/bundler/runtime.rb:76:in
require'
/var/lib/gems/1.9.1/gems/bundler-1.7.6/lib/bundler/runtime.rb:76:in block (2 levels) in require'
/var/lib/gems/1.9.1/gems/bundler-1.7.6/lib/bundler/runtime.rb:72:in
each'
/var/lib/gems/1.9.1/gems/bundler-1.7.6/lib/bundler/runtime.rb:72:in block in require'
/var/lib/gems/1.9.1/gems/bundler-1.7.6/lib/bundler/runtime.rb:61:in
each'
/var/lib/gems/1.9.1/gems/bundler-1.7.6/lib/bundler/runtime.rb:61:in require'
/var/lib/gems/1.9.1/gems/bundler-1.7.6/lib/bundler.rb:133:in
require' /home/ubuntu/apps/doger/config/application.rb:7:in <top (required)>' /home/ubuntu/apps/doger/config/environment.rb:2:inrequire'
/home/ubuntu/apps/doger/config/environment.rb:2:in <top (required)>' config.ru:3:inrequire' config.ru:3:in block in <main>'
/usr/lib/ruby/vendor_ruby/rack/builder.rb:55:in
instance_eval'
/usr/lib/ruby/vendor_ruby/rack/builder.rb:55:in initialize'
config.ru:1:in
new' config.ru:1:in <main>'
/usr/share/passenger/helper-scripts/rack-preloader.rb:112:in
eval'
/usr/share/passenger/helper-scripts/rack-preloader.rb:112:in preload_app'
/usr/share/passenger/helper-scripts/rack-preloader.rb:158:in
'
/usr/share/passenger/helper-scripts/rack-preloader.rb:29:in <module:PhusionPassenger>'
/usr/share/passenger/helper-scripts/rack-preloader.rb:28:in
'

[ 2014-11-12 16:12:26.1691 1979/7feff60bf700 agents/HelperAgent/RequestHandler.h:2306 ]: [Client 20] Cannot checkout session because a spawning error occurred. The identifier of the error is b7381860. Please see earlier logs for details about the error.

GemFile

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.1.7'
# Use postgresql as the database for Active Record
gem 'pg'
# 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 'therubyracer',  platforms: :ruby

# 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

# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring',        group: :development

I have already installed nodejs (v0.10.25)

3

3 Answers

15
votes

I get this problem every time I setup a new ubuntu/nginx/passenger/rails server. Try this

First install node:

sudo apt-get install nodejs

then add your path env to your /etc/nginx/nginx.conf like so:

env PATH;

or to be more specific (if node is located at /usr/bin/nodejs):

env PATH=/bin:/usr/bin;

4
votes

Uncomment line with 'therubyracer' gem, like this:

gem 'therubyracer',  platforms: :ruby

and run bundle install. I hope this will help you.

0
votes

I had run into a similar problem and I had nodejs already running on my machine. It was after all the looking had I came to realize I need to include execjs gem in my Gemfile:

gem "execjs", "~> 2.8.1"

And run bundle install