6

Per http://docs.drush.org/en/master/install/

# Download latest stable release using the code below or browse to github.com/drush-ops/drush/releases.
php -r "readfile('http://files.drush.org/drush.phar');" > drush
# Or use our upcoming release: php -r "readfile('http://files.drush.org/drush-unstable.phar');" > drush

# Test your install.
php drush core-status

# Make `drush` executable as a command from anywhere. Destination can be anywhere on $PATH.
chmod +x drush
sudo mv drush /usr/local/bin

# Optional. Enrich the bash startup file with completion and aliases.
drush init

So I try it but get the following error:

[Michael@devserver ~]$ php -r "readfile('http://files.drush.org/drush.phar');" > drush
[Michael@devserver ~]$ php drush core-status
PHP Warning:  pcntl_exec(): Error has occurred: (errno 13) Permission denied in phar:///home/Michael/drush/includes/startup.inc on line 359

Warning: pcntl_exec(): Error has occurred: (errno 13) Permission denied in phar:///home/Michael/drush/includes/startup.inc on line 359
Error has occurred executing the Drush script found at /home/Michael/drush
(errno 13) Permission denied
[Michael@devserver ~]

So then I try running it as root.

[Michael@devserver ~]$ su -
Password:
[root@devserver ~]# php /home/Michael/drush core-status
 PHP configuration      :  /etc/php.ini
 PHP OS                 :  Linux
 Drush script           :  /home/Michael/drush
 Drush version          :  8.1.2
 Drush temp directory   :  /tmp
 Drush configuration    :
 Drush alias files      :

[root@devserver ~]#

So, all is good, and I just need to install it as root? Any way I can install it as a normal user? Thanks

  • The cause could be the location where drush was downloaded requires sudo. Similar to sudo mv drush /usr/local/bin, /usr/local/bin requires sudo to mv something into it. – Vishal Kumar May 15 '16 at 5:02
  • To Pierre.Vriens, No Sssweat, Clive, different question. I am asking whether I need to install as root, not run as root. – user1032531 May 15 '16 at 12:27
  • yes !! u need 2 install it as root or sudoer as its files get installed in the bin directory as said above and that's d normal way since r,w,x, privileges are only with d sudoer but if the user has been granted permissions he can run drush ..as ur last query says [Any way I can run it as a normal user?] refer to this link drupal.stackexchange.com/a/20497/60708 .. to sum it up u need 2 install it as root but can run as root or user(if d user has the required privileges)@user1032531..i am bound 2 answer this becoz i was d one who referred 2 them as an duplicate...Do rectify me @Thanks – make-me-alive May 15 '16 at 13:09
  • @make-me-alive You are rectified! I think I got it now. Thank you for your help. – user1032531 May 15 '16 at 16:04
  • vlcme :) @user1032531 – make-me-alive May 15 '16 at 16:18
7

Not sure exactly what's going on there but I can reproduce it using the installation instructions.

The problem is related to the execution path (haven't looked any deeper). If you move out of the folder you downloaded drush into and execute, it'll work. (cd ~/..; Michael/drush core-status).

That's probably why it works when you su - your working directoy changes to /root. An unfortunate red herring, the problem doesn't appear to be related to permissions at all. Had you run sudo php drush core-status, it still wouldn't have worked.

  • 1
    Your exact code didn't work for me, but [Michael@devserver home]$ php ~/drush core-status did. Odd, but at least I can go forward as a regular user! Thanks. PS. If you or anyone figures out why, please comment. – user1032531 May 15 '16 at 21:09
  • 3
    Oddly enough, executing the commands outside of the dir as you suggested worked for me. Thanks! – ymdahi May 19 '16 at 15:34
  • 3
    Agreed! cd ~ php ~/drush core-status worked for me as well :) – Hemangi Gokhale May 28 '16 at 14:05
  • That should be related to file permission make sure drush is executable! – Mehdi Karamosly Jul 12 '16 at 17:00
  • It's not @Mehdi, it's a bug in drush. See Christopher's answer for more details – Clive Jul 12 '16 at 17:07
15

NOTE The issue described in the Question has now be fixed in the latest Drush version.

No, Drush does not need to be installed as root.

I've submitted Drush pull #2246 to update the current Drush install instructions.

This install method fixes the issue as per Drush pull #2246:

# Download latest stable release using the code below or browse to github.com/drush-ops/drush/releases.
php -r "readfile('http://files.drush.org/drush.phar');" > /tmp/drush
# Or use our upcoming release: php -r "readfile('http://files.drush.org/drush-unstable.phar');" > /tmp/drush

# Test your install.
php /tmp/drush core-status

# Make `drush` executable as a command from anywhere. Destination can be anywhere on $PATH.
chmod +x /tmp/drush
sudo mv /tmp/drush /usr/local/bin

# Optional. Enrich the bash startup file with completion and aliases.
drush init
0

I was getting this error as well. For my case it did turn out to be a permission issue on the given account. I needed to make sure the ~/.drush directory (and its sub directories) where owned by the proper account:

chown -R <account_name>:<account_group> /home/<account_name>/.drush
0

If you change the order of the commands so that you make drush executable before you test the install, it works. (At least it did for me):

# Download latest stable release using the code below or browse to github.com/drush-ops/drush/releases.
php -r "readfile('http://files.drush.org/drush.phar');" > drush
# Or use our upcoming release: php -r "readfile('http://files.drush.org/drush-unstable.phar');" > drush

# Make `drush` executable as a command from anywhere. Destination can be anywhere on $PATH.
chmod +x drush
sudo mv drush /usr/local/bin

# Test your install.
php drush core-status

# Optional. Enrich the bash startup file with completion and aliases.
drush init
  • 1
    Worked for me, with the following change: php /usr/local/bin/drush core-status – Cheeso Aug 20 '16 at 6:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.