Deploying Ruby on rails on Deamhost fails
Asked Answered
H

2

8

I'm trying to deploy a simple Ruby on Rails app to dreamhost but I'm getting an error related to the bundle command. Here is the error:

    servers: ["bullseye.dreamhost.com"]
    [bullseye.dreamhost.com] executing command
    command finished
  * executing "find /home/USER-NAME/MY-DOMAIN/releases/20110123014150/public/images /home/USER-NAME/MY-DOMAIN/releases/20110123014150/public/stylesheets /home/USER-NAME/MY-DOMAIN/releases/20110123014150/public/javascripts -exec touch -t 201101230141.52 {} ';'; true"
    servers: ["bullseye.dreamhost.com"]
    [bullseye.dreamhost.com] executing command
    command finished
    triggering after callbacks for `deploy:update_code'
  * executing `bundle:install'
  * executing "ls -xt /home/USER-NAME/MY-DOMAIN/releases"
    servers: ["bullseye.dreamhost.com"]
    [bullseye.dreamhost.com] executing command
    command finished
  * executing "bundle install --gemfile /home/USER-NAME/MY-DOMAIN/releases/20110123014150/Gemfile --path /home/USER-NAME/MY-DOMAIN/shared/bundle --deployment --quiet --without development test"
    servers: ["bullseye.dreamhost.com"]
    [bullseye.dreamhost.com] executing command
*** [err :: bullseye.dreamhost.com] sh: bundle: command not found
    command finished
*** [deploy:update_code] rolling back
  * executing "rm -rf /home/USER-NAME/MY-DOMAIN/releases/20110123014150; true"
    servers: ["bullseye.dreamhost.com"]
    [bullseye.dreamhost.com] executing command
    command finished
failed: "sh -c 'bundle install --gemfile /home/USER-NAME/MY-DOMAIN/releases/20110123014150/Gemfile --path /home/USER-NAME/MY-DOMAIN/shared/bundle --deployment --quiet --without development test'" on bullseye.dreamhost.com

Here is my deploy.rb file.

require 'bundler/capistrano'

set :user, "MY-USERNAME"
set :password, "MY-PASSWORD"
set :domain, 'bullseye.dreamhost.com'  # Dreamhost servername where your account is located 
set :project, 'blog'  # Your application as its called in the repository
set :application, 'MY-DOMAIN'  # Your app's location (domain or sub-domain name as setup in panel)
set :applicationdir, "/home/#{user}/#{application}"  # The standard Dreamhost setup

# version control config
set :scm_username, 'MY-SVN-USERNAME'
set :scm_password, 'MY-SVN-PWD'
set :repository, "http://MY-SVN-URL/01/blog/"

# roles (servers)
role :web, domain
role :app, domain
role :db,  domain, :primary => true

# deploy config
set :deploy_to, applicationdir
set :deploy_via, :export

# additional settings
default_run_options[:pty] = false  # Forgo errors when deploying from windows

namespace :deploy do
  task :start do ; end
  task :stop do ; end
  task :restart, :roles => :app, :except => { :no_release => true } do
    run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
  end
end

I found a similar question at Bundle install failing when deploying a Rails 3 app to Dreamhost with Capistrano but the solution didn't work. Anybody have any ideas as to what might be happening in my case?

Hate answered 23/1, 2011 at 1:47 Comment(2)
Perhaps 'bundler' isn't in the PATH you get when you're running these commands? As a first start, does which bundler return anything when you just ssh in? If bundler is in your PATH in an interactive login shell, perhaps you need to move the commands to set the PATH to a different bash startup file, as described in the INVOCATION section of the bash(1) manpage. (It's a beast of a section, but try ~/.bashrc, ~/.bash_profile, ~/.profile.)Karlise
@sarnold, thanks for the hints but I couldn't get that to work. But I did figure it out otherwise, see my answer below.Hate
H
7

I got this figured out eventually. What I did was

  • ssh into the dreamhost server and execute which bundle command
  • from ssh session execute echo $PATH command
  • edit config/deploy.rb and combine both strings with a : between and place inside default_environment PATH value, see below

    set :default_environment, { 'PATH' => "'/usr/lib/ruby/gems/1.8/bin//bundle:/home/sayed3/.gems/bin:/usr/lib/ruby/gems/1.8/bin/:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games'" }

Once I did this it was able to execute the bundle command successfully, but then I started running into some other issues. I eventually decided to use a VPS that I have hosted elsewhere, but I'm sure if I spent a bit more time I could have figured it out.

Hate answered 23/1, 2011 at 19:32 Comment(1)
default_environment["PATH"] = "$PATH:/usr/lib/ruby/gems/1.8/bin/" was what I addedUribe
T
1

Besides adding the path to bundle, as specified above, I also had to add the following line to my config/deploy.rb in order to force capistrano to use bash, instead of the default shell, which, on dreamhost, is dash:

set :shell, '/bin/bash'
Tentmaker answered 17/8, 2012 at 7:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.