1

I’m running Ubuntu 14.04.5 with Drush v 8.1.8 and I can’t seem to execute Drush without using sudo. For example if I try to execute ‘drush cc all’ without sudo, I get:

‘Directory /home/myuser/.drush/cache/default exists, but is not writable. Please check directory permissions. ‘ ‘Directory /home/myuser/.drush/cache/complete exists, but is not writable. Please check directory permissions. ’

If I then manually modify the permissions on .drush and everything under it to 777, the next Drush command will work but the one after that will fail with the same error. I also tried ‘chown -R myuser:myuser ~/.drush’. Same result.

I thought perhaps I installed Drush incorrectly, so I tried removing and then re-installing it three different ways:

  1. Using this approach: https://www.drupal.org/node/1248790 (sudu apt-get install drush).
  2. This way: http://docs.drush.org/en/master/install/ (executing php to load Drush from a remote file)
  3. Finally by installing Drush using method (2) and then moving Drush into my home/bin folder and chown -R to me.

All of them have the same result — drush doesn’t work without sudo. There’s no reason I can think of why this should be. What’s even weirder is if I chown of .drush (and everything under it) to me, then execute drush without sudo, it will change ownership of directories under .drush/cache to root. I don’t even know how that’s possible since I’m not root!

Please let me know how I can get Drush to work without root privileges. Thanks.

  • 2
    I chown of .drush (and everything under it) and to me, then execute drush without sudo, it will change ownership of directories under .drush/cache to root. That's a mis-configuration or bug in your OS. Drush is like any bit of software, it can't escalate the privileges of the executing user unless the OS lets it. I can't imagine drush would try to do that either, it wouldn't serve its purpose in any way. Just for the record, been using drush for 6+ years in D6/7/8, I've never needed to use sudo on any platform even once to run a command. Try installing in an empty VM to sanity check – Clive Jan 9 '17 at 21:33
  • 1
    Maybe you have installed drush using sudo or root? – Andrew Nim Jan 10 '17 at 11:47
  • Andrew, I had to install Drush as root because it installs in /usr/bin. And /usr/bin requires root privileges to install in. Isn't that how it should work? – North Krimsly Jan 11 '17 at 16:55
2

I'd suggest you follow the official install instructions here after removing your current install - http://docs.drush.org/en/master/install/

When you have it installed then navigate to your home folder:

cd ~/
ls -lash

At this point your .drush folder should have your user as owner (not root)

If it doesn't then run

sudo chown myusergoeshere:myusergoeshere .drush -R

You can run ls -lash again and confirm the right user and group.

You should now be able to run drush without using sudo.


The reason you get that error is because when you installed it the system created the folder using the root user in your home directory so as your user you don't have permission to modify the folder.

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.