WebFaction
Community site: login faq
0
1

Hi all!

I am working to deploy my first rails app to my WebFaction account and I am running into problems in the deployment process. After a day or two of futile Googling, I thought it would be helpful to turn to the WebFaction community to see if anyone has encountered the problems I'm having.

In short, I am attempting to deploy an app built with Rails 3.1.1 using Capistrano 2.8. Version control for the app is being handled using Git. Using a combination of WebFaction's own tutorial, the Capistrano getting started guide and a blog post for using Capistrano and WordPress 2.3, I managed to install Capistrano and create my deploy.rb file using a syntax which does not store my database password in Git (pasted below). I've seen that half of the deployment working because I've seen all the files copied to my server and I have seen the database schema properly created.

The issue arises, I believe, when I try to use Ruby's asset pipeline to precompile assets. When I run cap deploy, the deployment process starts, rolls along for a bit and then spits back the following error message:

triggering after callbacks for deploy:update_code'
  * executingdeploy:assets:precompile'
  * executing "cd /home/graznar/webapps/timeline_builder/releases/20111215034811 && bundle exec rake RAILS_ENV=production RAILS_GROUPS=assets assets:precompile"
    servers: ["web114.webfaction.com"]
    [web114.webfaction.com] executing command
  [out :: web114.webfaction.com] rake aborted!
  [out :: web114.webfaction.com] Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes.
  [out :: web114.webfaction.com] 
  [out :: web114.webfaction.com] (See full trace by running task with --trace)
    command finished in 4990ms
*** [deploy:update_code] rolling back
  * executing "rm -rf /home/graznar/webapps/timeline_builder/releases/20111215034811; true"
    servers: ["web114.webfaction.com"]
    [web114.webfaction.com] executing command
    command finished in 2534ms
failed: "env RUBYLIB=/home/graznar/webapps/timeline_builder/lib GEM_HOME=/home/graznar/webapps/timeline_builder/gems PATH=/home/graznar/webapps/timeline_builder/bin:$PATH sh -c 'cd /home/graznar/webapps/timeline_builder/releases/20111215034811 && bundle exec rake RAILS_ENV=production RAILS_GROUPS=assets assets:precompile'" on web114.webfaction.com

I've attempted to solve this by installing a JavaScript runtime (node.js) and by including the therubyracer gem in my Gemfile, to no avail. I've tried a few different variations of my deploy.rb file (including a few lines of code based on this post about using Rails 3.1 with WebFaction), but nothing seems to work.

Has anyone seen this issue (or one like it) in the past? Does anyone have any recommendations for moving past this impasse? To help, I've included my deploy.rb file below.

Thanks!

deploy.rb

require 'bundler/capistrano'

set :application, "timeline-builder" set :repository, "https://sguzik@github.com/sguzik/timeline-builder.git"

set :webfaction_username, "graznar" set :webfaction_db_type, "mysql" set :webfaction_db, "graznar_timeline" set :webfaction_db_username, "graznar_timeline" set :webfaction_port, "15380" set :database_yml_template, "database.example.yml"

set :scm, :git

set :deploy_to, "/home/graznar/webapps/timeline_builder"

set :default_environment, { 'PATH' => "#{deploy_to}/bin:$PATH", 'GEM_HOME' => "#{deploy_to}/gems", 'RUBYLIB' => "#{deploy_to}/lib" }

role :web, "web114.webfaction.com" # Your HTTP server, Apache/etc role :app, "web114.webfaction.com" # This may be the same as your Web server role :db, "web114.webfaction.com", :primary => true # This is where Rails migrations will run

set :user, "graznar" # Webfaction Username set :scm_username, "sguzik" # VCS username set :use_sudo, false default_run_options[:pty] = true

namespace :deploy do desc "Creates the database configuration on the fly" task :create_database_configuration, :roles => :app do require "yaml" set :production_db_password, proc { Capistrano::CLI.password_prompt("Remote production database password: ") }

db_config = YAML::load_file("config/#{database_yml_template}")
db_config.delete('test')
db_config.delete('development')

db_config['production']['adapter'] = "#{webfaction_db_type}"
db_config['production']['database'] = "#{webfaction_db}"
db_config['production']['username'] = "#{webfaction_db_username}"
db_config['production']['password'] = "#{production_db_password}"
db_config['production']['host'] = "localhost"

put YAML::dump(db_config), "#{release_path}/config/database.yml", :mode => 0664

end

desc "deploy the precompiled assets" task :deploy_assets, :except => { :no_release => true } do run_locally("rake assets:clean && rake assets:precompile") upload("public/assets", "#{release_path}/public/assets", :via => :scp, :recursive => true) end

after "deploy:update_code", "deploy:create_database_configuration", 'deploy_assets'

desc "Restart nginx" task :restart do run "#{deploy_to}/bin/restart" end end

asked 15 Dec '11, 07:31

Sam%20Guzik's gravatar image

Sam Guzik
2538
accept rate: 0%

edited 15 Dec '11, 07:32


A couple of other customers were able to solve the Javascript runtime error by adding the following line to their Gemfile:

gem "therubyracer"

Can you try that and let us know if you still have a problem?

permanent link

answered 15 Dec '11, 14:05

seanf's gravatar image

seanf ♦♦
11.9k21333
accept rate: 37%

That did it! Thanks for the suggestion.

(15 Dec '11, 18:35) Sam Guzik Sam%20Guzik's gravatar image

When I add that to my bundle and try to run rake db:migrate, I get a long list of warning: already initialized constant [CONSTANT_NAME], followed by rake aborted! stack level too deep. Any idea what I can do?

(03 Jul '12, 11:12) TwitTheKnife TwitTheKnife's gravatar image

TwitTheKnife: submit a support ticket so we can take a look.

(03 Jul '12, 20:22) johns ♦♦ johns's gravatar image
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×28
×19
×1
×1

question asked: 15 Dec '11, 07:31

question was seen: 4,745 times

last updated: 03 Jul '12, 20:22

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2017 PARAGON INTERNET GROUP LIMITED
WEBFACTION IS A SERVICE OF PARAGON INTERNET GROUP LIMITED
REGISTERED IN ENGLAND AND WALES 7573953 - VAT REGISTRATION NUMBER 182147021
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM