serversideup / docker-php

🐳 Production-ready Docker images for PHP. Optimized for Laravel, WordPress, and more!
https://serversideup.net/open-source/docker-php/
GNU General Public License v3.0
1.74k stars 119 forks source link

php artisan tinker: Writing to directory /var/www/.config/psysh is not allowed #326

Closed jaydrogers closed 6 months ago

jaydrogers commented 6 months ago

Originally posted by @JanickOtten

Originally posted by @JanickOtten in https://github.com/serversideup/spin/issues/76#issuecomment-2076492476

Thanks for the fix! Just came across a minor issue when trying to run a Tinker session in development (using docker exec -it <container> php artisan tinker), where I'm receiving a permission error, causing the Tinker session to abort:

Writing to directory /var/www/.config/psysh is not allowed.

  at vendor/psy/psysh/src/ConfigPaths.php:327
    323▕             @\mkdir($dir, 0700, true);
    324▕         }
    325▕ 
    326▕         if (!\is_dir($dir) || !\is_writable($dir)) {
  ➜ 327▕             \trigger_error(\sprintf('Writing to directory %s is not allowed.', $dir), \E_USER_NOTICE);
    328▕ 
    329▕             return false;
    330▕         }
    331▕ 

I fixed this by chowning the /var/www/ directory to www-data as well.

RUN chown www-data:www-data /var/www

In this https://github.com/serversideup/spin/issues/76#issuecomment-2074143365 I noticed ps-20x ran this as well.

jaydrogers commented 6 months ago

@janickotten & @ps-20x:

Thanks so much for the proposed fix for the php artisan tinker support. I just pushed this commit (https://github.com/serversideup/docker-php/commit/4bfcb0821e00935ac01b3cb81d84acf9a0b2ef78) to serversideup/php and it's building right now:

This takes about an hour to build, but these images will be made available on our serversideup/php-dev repo for initial testing.

If you want to remove your workarounds in your Dockerfiles, then quickly try these images -- it should work without your extra lines of code. It worked on my end for my tests.

Be sure to switch the image back (don't use serversideup/php-dev forever) and subscribe to the repo updates because if this fix works, it will be made available in the next beta release 👍

We're getting to the point were these images will be stable, so hopefully the release after that will be the v3.0 stable 🥳

JanickOtten commented 6 months ago

Thanks @jaydrogers, I can confirm this is fixed in serversideup/php-dev. Looking forward to the v3.0 stable release!