Drush does not seem to be able to move files to the tmp folder on my local machine. Changing the tmp folder location to for instance "sites/default/files" works, but I would like to know why it doesn't work with /tmp.

I am using this script from the fontawesome module:

$this->fileSystem->move($path . '/fontawesome-free-' . $fontawesome_library['version'] . '-web', $this->fileSystem->getTempDirectory() . '/temp_fontawesome', FileSystemInterface::EXISTS_REPLACE);

and I get the error

The specified file '/home/username/websites/frilaering_newest/web/libraries/fontawesome/fontawesome-free-6.1.0-web' could not be moved to '/tmp/temp_fontawesome'.

The weird thing is that everything else seems to work - including file uploads, which uses the tmp folder - so can this be related to Drush somehow? I'm using Drush installed on the local website with composer. Everything looks fine in Drush status.

  • www-data can write to /tmp
  • /tmp is chmodded to 777
  • .htaccess file is present in /tmp folder
  • settings.local.php has "$settings["file_temp_path"] = '/tmp';"

I have tried anything - even fiddling with PrivateTmp, but the only thing that works is changing the tmp folder, which I would rather avoid.

I am using Drupal 9 with php7.3-fpm/apache2/mariaDB on latest Ubuntu

Any ideas?

  • 1
    You say that www-data can write to /tmp. This does matter for the web server, but not for Drush. The question is whether the user who has logged into the command line can write to /tmp.
    – 4uk4
    Apr 17, 2022 at 16:17
  • 1
    What is the ownership and permissions on /tmp/temp_fontawesome? Which user is executing Drush?
    – mona lisa
    Apr 17, 2022 at 16:18
  • Yes, also the sub directories.
    – 4uk4
    Apr 17, 2022 at 16:19
  • the user who is using drush is my local user. I have permissions to write to /tmp as far as I can see. the folder "temp_fontawesome" is never created because drush can't write to /tmp
    – Morten
    Apr 17, 2022 at 16:45
  • could be typo related. Have you tried ../tmp instead of /tmp? As an example I refer to my tmp folder like this $settings['file_temp_path'] = '../tmp';
    – Joehoe
    Apr 19, 2022 at 9:04

1 Answer 1



Probably the /tmp/temp_fontawesome directory has already been created by the web server user www-data.

The permissions for /tmp/temp_fontawesome are probably:

ls -lash /tmp/temp_fontawesome
4,0K drwxrwxr-x  3 www-data www-data 4,0K sep 21 13:55

...which means that your user, which is running drush, is not permitted to write to /tmp/temp_fontawesome because other has no write permision r-x, indicated by - instead of w.

Solution A

Change the Linux group permissions, so that your user (called for example drupaladmin) running drush, is allowed to write to the directory:

sudo chgrp -R drupaladmin /tmp/temp_fontawesome
sudo chmod g+w -R /tmp/temp_fontawesome

ls -lash /tmp/temp_fontawesome
4,0K drwxrwxr-x  3 www-data drupaladmin  4,0K sep 21 13:56

Solution A (could sometimes be the other way around)

If the directory is created by drush through your user first, then www-data cannot write to it. In that case the commands would be:

sudo chgrp -R www-data /tmp/temp_fontawesome
sudo chmod g+w -R /tmp/temp_fontawesome

Solution B

Remove the directory (drush can then create the directory with your user as the owner):

sudo rm -r /tmp/temp_fontawesome

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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