# Bedrock & Roots: Copying Production Assets with Capistrano

**URL:** https://discourse.roots.io/t/bedrock-roots-copying-production-assets-with-capistrano/2187
**Category:** bedrock
**Created:** 2014-08-28T18:25:07Z
**Posts:** 11

## Post 1 by @nateroling — 2014-08-28T18:25:07Z

Just finished my [final post](http://nateroling.com/2014/08/28/roots-bedrock-production-assets-part-3/) on handling production assets with Bedrock and the Roots base theme.

All the details are in [this Gist](https://gist.github.com/nateroling/22b51c0cfbe210b00698), inspired by [this Gist](https://gist.github.com/christhesoul/3c38053971a7b786eff2) by christhesoul.

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

---

## Post 2 by @bigsweater — 2014-10-02T04:42:20Z

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?

---

## Post 3 by @bigsweater — 2014-10-02T16:47:26Z

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 rm`ed them and the directory is now empty.

---

## Post 4 by @swalkinshaw — 2014-10-02T17:06:04Z

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

---

## Post 5 by @bigsweater — 2014-10-02T19:33:01Z

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

---

## Post 6 by @swalkinshaw — 2014-10-04T18:31:03Z

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.

---

## Post 7 by @thiago — 2014-10-04T23:14:02Z

Hi @nateroling, I am getting a database error when trying to access your [final post](http://nateroling.com/2014/08/28/roots-bedrock-production-assets-part-3/) link!!

---

## Post 8 by @bigsweater — 2014-10-07T03:08:38Z

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

---

## Post 9 by @dave-k — 2018-11-23T00:18:37Z

@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](mailto:me@site.com): scp: ~/public\_html/app/releases/20181122233252/.env: No such file or directory

---

## Post 10 by @ben — 2018-11-23T14:52:03Z

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

---

## Post 11 by @ben — 2018-11-23T14:52:07Z


