Drush: permission denied on remote server
Asked Answered
A

6

5

I am trying to set drush up on a remote server. (a webserver by a provider)

I installed drush with composer via SSH, but when I try to run it, I get

-bash: /data/web/myusername/.composer/vendor/drush/drush/drush: Permission denied

drush has -rwxr-xr-x permissions

How would I verify if it is just the provider not allowing me to execute drush or simply a bug?

Edit: I found that i could run drush with bash drush, it seems to be a permission problem after all.

now the drush on my local machine would call the remote drush without the bash, so how could I change that/workaround?

Avaavadavat answered 5/9, 2015 at 18:34 Comment(8)
when you ssh to the remote machine, what shell is used? echo $SHELL should tell you that. It could be that bash is not the shell when you login so you may need to see if you can set your default shell on your own, or do something like alias drush='bash drush' on the remote server.Kassi
hi, bash is used. If i switch to sh with sh I still cant run drush with ./drush but sh drush works. I can reproduce that error on my local machine: If I create a script and i don't give it execution permission, i can run it with bash script but not with ./script. Using alises doesn't seem to work, because my local drush as a script wont load the aliases. But yeah, I looking for something in that direction.Avaavadavat
I suppose I'd expect a different error, but are the ~/.drush/cache permissions set correctly?Kassi
got rwxr-xr-x thereAvaavadavat
Hmmm... interesting. OK the only time I've seen this is when drush is not set to be executable, I know you've verified above but you might just want to check which drush and ls -l ~/.composer/vendor/drush/drush/drush. Sorry for redundancy but it really is the only time I've seen this error. You should also verify these permissions are set on the remote server to be executable as well.Kassi
which gives me no output on the remote server, for ls i get -rwxr-xr-x . thanks for your time btw.Avaavadavat
now I'm stretching but do you have the following in your .bashrc file on both the local and remote machines? export PATH="$HOME/.composer/vendor/bin:$PATH"Kassi
Yes. To be clear: the drush on my local machine is working fine, its just the one on the webserver which gives me trouble. Maybe its an issue with the permissions on the lower dirs which I cannot change. Do you maybe know a workaround just like aliases?Avaavadavat
T
7

If still someone is facing permission issue while running drush command then run below commands sudo chmod -R 777 /vendor/drush

Note Drupal 8 Drush Commandline Tool 9.5.2

Timothea answered 20/12, 2018 at 6:14 Comment(0)
S
4

I installed drush 8 using composer and out of the box, trying even drush version I got "permission denied" until I did chmod + x on :

/vendor/bin/drush
/vendor/drush/drush
/vendor/drush/drush.launcher

Next, I had to override php.ini using local drush.ini with :

disable_functions = 

Having any disabled funcs in the list caused drush to issue an error every time. This was on Krystal shared hosting.

Schade answered 3/5, 2017 at 15:11 Comment(1)
This fixed my issue, adding a drush.ini and disable_functions = , for some reason when I upgraded to drush 10.3.4 from 9.7.4 I had to do this, add a drush.ini to the ~ folder (home folder in Linux/MacOSX)Illusionary
A
1

Make drush an executable:

chmod +x /data/web/myusername/.composer/vendor/drush/drush/drush
Autocrat answered 25/12, 2020 at 18:28 Comment(0)
D
0

If you are centos or ubuntu user do it your default /vendor/drush permission is 755 but drush need a permission 777

cd /var/www/html

to see the permission of vendor folder

ll

here is default permission is 755

chmod -R 777 /vendor/drush 
Denouement answered 1/2, 2019 at 11:42 Comment(1)
Whatever you are trying to accomplish, chmod 777 is wrong and dangerous. You should revert to sane permissions immediately, and not touch them again until you actually understand how they work.Butadiene
T
0

I got the same error output, but the problem was with the remote drush path, so also make sure you double check our script path in the alias definition:

'path-aliases' => array(
        '%drush-script' => 'your-server-path-here/.composer/vendor/drush/drush/drush'
      ),
Timothy answered 8/1, 2020 at 9:39 Comment(0)
D
0

It seems that drush will try to use the vendor installation if it exists. In ProcessManager.php, method drushScript:

    // If the target is a local Drupal site that has a vendor/bin/drush,
    // then use that.

And it looks for drush in ../vendor/bin/drush.

Code here: https://github.com/drush-ops/drush/blob/11.x/src/SiteAlias/ProcessManager.php#L68

This can be very misleading because we think we're running the global drush but actually it ends up being the local drush that is being run, which can have different permissions or blocked by server security policies.

Decapitate answered 24/6, 2022 at 16:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.