Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel - "artisan tinker" -> mkdir(): Permission denied

I have been searching for hours now but cannot find a solution even though there are similar problems out there.

I am trying to run php artisan tinker on a fresh laravel installation with user webmaster (who is owner of the project directory demo) but I am getting the following error:

In Configuration.php line 352:
mkdir(): Permission denied

Running with verbose flag:

Exception trace: Illuminate\Foundation\Bootstrap\HandleExceptions->handleError() at n/a:n/a mkdir() at /media/usb/drive1/websites/demo/vendor/psy/psysh/src/Psy/Configuration.php:352 Psy\Configuration->getRuntimeDir() at /media/usb/drive1/websites/demo/vendor/psy/psysh/src/Psy/Shell.php:185 Psy\Shell->getDefaultCommands() at /media/usb/drive1/websites/demo/vendor/symfony/console/Application.php:1211 Symfony\Component\Console\Application->init() at /media/usb/drive1/websites/demo/vendor/symfony/console/Application.php:435 Symfony\Component\Console\Application->add() at /media/usb/drive1/websites/demo/vendor/psy/psysh/src/Psy/Shell.php:134 Psy\Shell->add() at /media/usb/drive1/websites/demo/vendor/symfony/console/Application.php:421 Symfony\Component\Console\Application->addCommands() at /media/usb/drive1/websites/demo/vendor/laravel/tinker/src/Console/TinkerCommand.php:54 Laravel\Tinker\Console\TinkerCommand->handle() at n/a:n/a call_user_func_array() at /media/usb/drive1/websites/demo/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:29 Illuminate\Container\BoundMethod::Illuminate\Container{closure}() at /media/usb/drive1/websites/demo/vendor/laravel/framework/src/Illuminate/Container/ BoundMethod.php:87 Illuminate\Container\BoundMethod::callBoundMethod() at /media/usb/drive1/websites/demo/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:31 Illuminate\Container\BoundMethod::call() at /media/usb/drive1/websites/demo/vendor/laravel/framework/src/Illuminate/Container/Container.php:549 Illuminate\Container\Container->call() at /media/usb/drive1/websites/demo/vendor/laravel/framework/src/Illuminate/Console/Command.php:183 Illuminate\Console\Command->execute() at /media/usb/drive1/websites/demo/vendor/symfony/console/Command/Command.php:252 Symfony\Component\Console\Command\Command->run() at /media/usb/drive1/websites/demo/vendor/laravel/framework/src/Illuminate/Console/Command.php:170 Illuminate\Console\Command->run() at /media/usb/drive1/websites/demo/vendor/symfony/console/Application.php:938 Symfony\Component\Console\Application->doRunCommand() at /media/usb/drive1/websites/demo/vendor/symfony/console/Application.php:240 Symfony\Component\Console\Application->doRun() at /media/usb/drive1/websites/demo/vendor/symfony/console/Application.php:148 Symfony\Component\Console\Application->run() at /media/usb/drive1/websites/demo/vendor/laravel/framework/src/Illuminate/Console/Application.php:88 Illuminate\Console\Application->run() at /media/usb/drive1/websites/demo/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:121 Illuminate\Foundation\Console\Kernel->handle() at /media/usb/drive1/websites/demo/artisan:37

Hope anyone has a hint for me. Thanks!

Relevant information

  • Distribution: Raspbian GNU/Linux 8 (jessie)
  • Webserver: Apache/2.4.25
  • Laravel version: 5.5 (latest)
  • DocumentRoot: /var/www/websites -> /media/usb/drive1/websites/
  • Apache user: www-data (has permissions in project directory)

Similar reported issues

  • https://github.com/laravel/tinker/issues/34
  • artisan tinker: mkdir() permission denied
like image 640
pixelmusic Avatar asked Jan 17 '18 14:01

pixelmusic


1 Answers

It has been a year since I asked the question. I simply ignored the lack of use of tinker and went on. But today I finally found a solution and thought it might be a good idea to share.

The shared server environment might causing this error. Dumping the variable $this->runtimeDir on line 352 from file vendor/psy/psysh/src/Configuration.php tells me about missing permissions to create a folder in /run/user/1000/psysh, where 1000 is the uid.

A workaround is to tell psysh to use a directory where the operating user has write access. This can be done with the runtimeDir config option. All you need to do is to create a config file in ~/.config/psysh/config.php or locally as .psysh.php in the project root of Laravel. Add the following content and you are ready to go.

<?php
return [
    'runtimeDir' => './.psysh',
];
like image 169
pixelmusic Avatar answered Oct 17 '22 15:10

pixelmusic