I’m having trouble setting up a new server using Moonshine and Capistrano. It seems to get started pretty well, installs a bunch of Ubuntu packages, compiles REE, installs some gems, but then it fails to upload a file via SFTP with this output:
* executing `moonshine:setup_directories'
* executing "mkdir /tmp/moonshine"
servers: ["myserver.tld"]
[myserver.tld] executing command
command finished
servers: ["myserver.tld"]
** sftp upload /Users/arussell/Sites/mysite/config/moonshine/production.yml -> /tmp/moonshine/production.yml
/Users/arussell/.rvm/gems/ree-1.8.7-2011.03/gems/capistrano-2.5.19/lib/capistrano/transfer.rb:196:in `normalize': undefined method `pos' for #<Pathname:0x10f3a6988> (NoMethodError)
from /Users/arussell/.rvm/gems/ree-1.8.7-2011.03/gems/capistrano-2.5.19/lib/capistrano/transfer.rb:104:in `prepare_transfers'
Googling that error isn’t really turning much up, all I can figure out is that capistrano/transfer.rb is expecting something other than a PathName object on line 196, but I’m not sure what it’s expecting, nor am I sure why it’s being fed a PathName object.
Edit: Here is my deploy.rb:
set :stages, %w(staging production dev)
set :default_stage, "staging"
require 'capistrano/ext/multistage' rescue "YOU NEED TO INSTALL THE capistrano-ext GEM"
require 'fileutils'
if ENV['branch']
set :branch, ENV['branch']
end
set :deploy_via, :remote_cache
before "deploy:restart", "deploy:delete_cache"
namespace(:deploy) do
desc "delete cache"
task :delete_cache do
run "rm -rf /usr/local/shared/cache/"
end
task :null, :roles => :app do
run "date"
end
end
require './config/boot'
… and my deploy/production.rb:
server "myserver.tld", :app, :web, :db, :primary => true
set :rails_env, 'production'
Edit 2: I tried using SCP instead of SFTP, but that didn’t go any better. I added this to my deploy/production.rb:
upload "local", "remote", :via => :scp
download "remote", "local", :via => :scp
and got this error instead while trying to deploy:
upload via scp failed on myserver.tld: SCP did not finish successfully () (SCP did not finish successfully ())
Turns out that this was due to Moonshine not being able to handle the presence of deploy-stage-specific files (eg
config/moonshine/production.yml) duringcap production deploy:setup.Here’s how I got around it:
config/moonshine/production.yml(replaceproductionwith whatever your deploy stage is called)cap production deploy:setupconfig/moonshine/production.ymlbackcap production deploy