Roots Discourse

Bedrock & Roots: Copying Production Assets with Capistrano


#1

Just finished my final post on handling production assets with Bedrock and the Roots base theme.

All the details are in this Gist, inspired by this Gist by christhesoul.

For me, this is the simplest approach to the issue of deploying generated assets, and what I’ll be using moving forward.


Envars, capistrano, and ansible
#2

I’m getting an SSHKit error.

FYI, I’m using this to deploy to shared hosting (MediaTemple’s GridServer), and I’m using Gulp instead. Here’s the error in full:

INFO[e2ba3ad4] Running /usr/bin/env mkdir -p ~/domains/{projectname}/releases/20141002043116/web/app/themes/ext/assets/css on {hostname}
DEBUG[e2ba3ad4] Command: ( WP_ENV=staging /usr/bin/env mkdir -p ~/domains/{projectname}/releases/20141002043116/web/app/themes/ext/assets/css )
INFO[e2ba3ad4] Finished in 0.166 seconds with exit status 0 (successful).
DEBUGUploading web/app/themes/ext/assets/css/main.min.css 0.0%
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing on host {hostname}: scp: ~/domains/{projectname}/releases/20141002043116/web/app/themes/ext/assets/css/main.min.css: No such file or directory
/Library/Ruby/Gems/2.0.0/gems/net-scp-1.2.1/lib/net/scp.rb:398:in `await_response_state'
/Library/Ruby/Gems/2.0.0/gems/net-scp-1.2.1/lib/net/scp.rb:369:in `block (3 levels) in start_command'
/Library/Ruby/Gems/2.0.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/channel.rb:311:in `call'
/Library/Ruby/Gems/2.0.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/channel.rb:311:in `process'
/Library/Ruby/Gems/2.0.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:222:in `block in preprocess'
/Library/Ruby/Gems/2.0.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:222:in `each'
/Library/Ruby/Gems/2.0.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:222:in `preprocess'
/Library/Ruby/Gems/2.0.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:205:in `process'
/Library/Ruby/Gems/2.0.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:169:in `block in loop'
/Library/Ruby/Gems/2.0.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:169:in `loop'
/Library/Ruby/Gems/2.0.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:169:in `loop'
/Library/Ruby/Gems/2.0.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/channel.rb:269:in `wait'
/Library/Ruby/Gems/2.0.0/gems/net-scp-1.2.1/lib/net/scp.rb:284:in `upload!'
/Library/Ruby/Gems/2.0.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:83:in `block in upload!'
/Library/Ruby/Gems/2.0.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:186:in `with_ssh'
/Library/Ruby/Gems/2.0.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:82:in `upload!'
config/deploy.rb:88:in `block (4 levels) in <top (required)>'
config/deploy.rb:86:in `each'
config/deploy.rb:86:in `block (3 levels) in <top (required)>'
/Library/Ruby/Gems/2.0.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:54:in `instance_exec'
/Library/Ruby/Gems/2.0.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:54:in `run'
/Library/Ruby/Gems/2.0.0/gems/sshkit-1.5.1/lib/sshkit/runners/parallel.rb:13:in `block (2 levels) in execute'
scp: ~/domains/{projectname}/releases/20141002043116/web/app/themes/ext/assets/css/main.min.css: No such file or directory
/Library/Ruby/Gems/2.0.0/gems/net-scp-1.2.1/lib/net/scp.rb:398:in `await_response_state'
/Library/Ruby/Gems/2.0.0/gems/net-scp-1.2.1/lib/net/scp.rb:369:in `block (3 levels) in start_command'
/Library/Ruby/Gems/2.0.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/channel.rb:311:in `call'
/Library/Ruby/Gems/2.0.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/channel.rb:311:in `process'
/Library/Ruby/Gems/2.0.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:222:in `block in preprocess'
/Library/Ruby/Gems/2.0.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:222:in `each'
/Library/Ruby/Gems/2.0.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:222:in `preprocess'
/Library/Ruby/Gems/2.0.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:205:in `process'
/Library/Ruby/Gems/2.0.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:169:in `block in loop'
/Library/Ruby/Gems/2.0.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:169:in `loop'
/Library/Ruby/Gems/2.0.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:169:in `loop'
/Library/Ruby/Gems/2.0.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/channel.rb:269:in `wait'
/Library/Ruby/Gems/2.0.0/gems/net-scp-1.2.1/lib/net/scp.rb:284:in `upload!'
/Library/Ruby/Gems/2.0.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:83:in `block in upload!'
/Library/Ruby/Gems/2.0.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:186:in `with_ssh'
/Library/Ruby/Gems/2.0.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:82:in `upload!'
config/deploy.rb:88:in `block (4 levels) in <top (required)>'
config/deploy.rb:86:in `each'
config/deploy.rb:86:in `block (3 levels) in <top (required)>'
/Library/Ruby/Gems/2.0.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:54:in `instance_exec'
/Library/Ruby/Gems/2.0.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:54:in `run'
/Library/Ruby/Gems/2.0.0/gems/sshkit-1.5.1/lib/sshkit/runners/parallel.rb:13:in `block (2 levels) in execute'
Tasks: TOP => deploy:updated => deploy:copy_assets
(See full trace by running task with --trace)
The deploy has failed with an error: #<SSHKit::Runner::ExecuteError: Exception while executing on host {hostname}: scp: ~/domains/{projectname}/releases/20141002043116/web/app/themes/ext/assets/css/main.min.css: No such file or directory

Oddly, when I cd into the release directory, the files do exist, albeit with restrictive permissions.

It seems like a permissions issue to me, but I wouldn’t know how to begin telling Capistrano to chmod directories on the server. Also, Cap is running these commands as the account owner, which is about as close as I’ll get to root on that service; it should have write access to those files.

Thoughts?


Using Bedrock + Sage to deploy with Capistrano (theme Gulp dist files?)
#3

As it turns out, capistrano is not copying the files up. They just happened to be checked into the repository, so they were being put in. I git rmed them and the directory is now empty.


#4

So is the problem fixed? Not exactly sure where it stands now.


#5

Sorry–no, it’s still busted. The files aren’t being copied up at all, but it looks like the directory is there.


#6

My hunch is that the No such file or directory error is referring to the source file (local). I’d make sure those are all correct.


#7

Hi @nateroling, I am getting a database error when trying to access your final post link!!


#8

Figured it out. Using the ~ homedir shortcut doesn’t work in Capistrano, at least for the upload! method, because SCP don’t play that. ~ is a Bash shortcut, not SCP, so SCP wasn’t finding the directory, naturally.

I’ve manually typed the full path to my homedir on the GridServer, but that doesn’t seem ideal…I’ll have to figure out how to grab the full path from the system another time.

Meanwhile, this is fixed! Thanks for your help! @nateroling @swalkinshaw


#9

@bigsweater Did you resolve the ~ homedir issue with SCP?
I am also getting this error:
SSHKit::runner::ExecuteError: Exception while executing as me@site.com: scp: ~/public_html/app/releases/20181122233252/.env: No such file or directory


#10

Locking since this is a 4 year old thread. Please create a new one with all the details of your setup if you’d like support


#11