Biok
Biok

Reputation: 55

Why Drupal can not create a temporary file?

I cloned a repository from my drupal site to a local environment running MAMP PRO in a windows machine. all the files and data base are setup correctly. when I try to run Drupal 8 I get this error. I know its a permissions problem but I'm not sure where to change the permissions or what to do. I tried many settings and I get same results.

Drupal\Core\File\Exception\FileWriteException: Temporary file 'temporary://filF92B.tmp' could not be created. in Drupal\Core\File\FileSystem->saveData() (line 521 of core\lib\Drupal\Core\File\FileSystem.php). 


Drupal\google_tag\Entity\ContainerManager->saveSnippets(Object) (Line: 77)
Drupal\google_tag\Entity\ContainerManager->createAssets(Object) (Line: 160)
Drupal\google_tag\Entity\ContainerManager->getScriptAttachments(Array) (Line: 70)
google_tag_page_attachments(Array) (Line: 297)
Drupal\Core\Render\MainContent\HtmlRenderer->invokePageAttachmentHooks(Array) (Line: 273)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object, Object) (Line: 117)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object)
call_user_func(Array, Object, 'kernel.view', Object) (Line: 111)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('kernel.view', Object) (Line: 156)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 708)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Upvotes: 1

Views: 5339

Answers (4)

Matoeil
Matoeil

Reputation: 7289

In my case the $settings['file_temp_path'] was overrided in the local.settings

Upvotes: 0

Eloy Ruiz
Eloy Ruiz

Reputation: 767

I was having this problem while working with the copy of a site in production in local with XAMPP. I solved it adding this to settings.php:

$settings["file_temp_path"] = sys_get_temp_dir();

Upvotes: 2

Biok
Biok

Reputation: 55

Ok, It looks like is not necessary to access the admin panel to change the temporary directory. In settings.php I was able to modify the below line to set it up. After clearing Drupal cache and adding an .htaccess file it worked.

$settings['file_temp_path'] = '/tmp'; 

Upvotes: 1

Kien Nguyen
Kien Nguyen

Reputation: 2701

Go to Administrator -> Configuration -> Media -> File System (/admin/config/media/file-system) to get your temporary path. Make sure it have the right privileges for the Apache user.

enter image description here

Upvotes: 0

Related Questions