Roots Discourse

I'm stuck: Bower permissions


#1

Hi team.

I’m setting up a new staging/prod server.

For some reason, my deploy script is getting stuck, but the same commands run from the server shell work fine, with the same user account!

So…

When the script runs I get this error:

DEBUG[64fadb25] Command: cd /srv/users/clear/apps/www-prod/releases/20161027231950/web/app/themes/clear2016 && ( WP_ENV=production /usr/bin/env bower install --quiet --config.interactive=false )
DEBUG[64fadb25] 	/usr/bin/env: ‘bower’
DEBUG[64fadb25] 	: No such file or directory
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing on host XXX.XXX.XXX.XXX: bower exit status: 127
bower stdout: Nothing written
bower stderr: /usr/bin/env: ‘bower’: No such file or directory

However, when I login, using the same user, and run the same commands, they work fine, with no perms error. What gives?

I’ve tried symlinking, local node/bower installs, etc. Just don’t know enough to fix this :frowning:

A


#2

(I’m using Capistrano, not Trellis, if that matters.)


#3

SOLVED!

This, after many hours of fiddling, solved it for me:

n=$(which node);n=${n%/bin/node}; chmod -R 755 $n/bin/*; sudo cp -r $n/{bin,lib,share} /usr/local

It moves/copies the node (and dependency) executables to the /usr/local/bin directory, as required.

I can’t believe that wasn’t a lot easier to find, but never mind!

A


#4

A potentially easier/better solution is setting the command map for bower:

SSHKit.config.command_map[:bower] = "/path/to/bower" # example /usr/bin/node/bower`

This just let’s you provide an override for the location of a command.


#5

Yep. I tried that. It didn’t work. Very strangely, I might add.

Thanks Scott.

A