MicroSymfony icon indicating copy to clipboard operation
MicroSymfony copied to clipboard

Permission denied for phpunit result cache file

Open florentdestremau opened this issue 11 months ago • 4 comments

MicroSymfony version(s) affected

latest (today)

Description

I used the docker on-liner to install the project.

~/dev/microsymfony🔒
❯ make test
PHPUnit 11.5.2 by Sebastian Bergmann and contributors.

Runtime:       PHP 8.3.8
Configuration: /home/florent/dev/microsymfony/phpunit.xml.dist

...................                                               19 / 19 (100%)PHP Warning:  file_put_contents(/home/florent/dev/microsymfony/.phpunit.result.cache): Failed to open stream: Permission denied in /home/florent/dev/microsymfony/vendor/phpunit/phpunit/sr
c/Runner/ResultCache/DefaultResultCache.php on line 160

Warning: file_put_contents(/home/florent/dev/microsymfony/.phpunit.result.cache): Failed to open stream: Permission denied in /home/florent/dev/microsymfony/vendor/phpunit/phpunit/src/Runner/ResultCache/DefaultResultCache.php on line 160


Time: 00:00.278, Memory: 34.00 MB

OK (19 tests, 26 assertions)

It's probably an issue with the fact that it's installed as root:

~/dev/microsymfony🔒
❯ ls -a
Permissions Size User Date Modified  Name
drwxr-xr-x     - root  1 janv. 19:30  .github
drwxr-xr-x     - root  1 janv. 19:30  assets
drwxr-xr-x     - root  1 janv. 19:30  bin
drwxr-xr-x     - root  1 janv. 19:30  config
drwxr-xr-x     - root  1 janv. 19:30  public
drwxr-xr-x     - root  1 janv. 19:30  src
drwxr-xr-x     - root  1 janv. 19:30  templates
drwxr-xr-x     - root  1 janv. 19:30  tests
drwxrwxrwx     - root 28 janv. 09:31  var
drwxr-xr-x     - root 28 janv. 09:31  vendor
drwxr-xr-x     - root  1 janv. 19:30  vendor-bin
.rw-r--r--  1,1k root  1 janv. 19:30  .env
.rw-r--r--    25 root  1 janv. 19:30  .env.local.dist
.rw-r--r--   215 root  1 janv. 19:30  .env.test
.rw-r--r--   643 root  1 janv. 19:30  .gitignore
.rw-r--r--  2,0k root  1 janv. 19:30  .php-cs-fixer.dist.php
.rw-r--r--  9,1k root  1 janv. 19:30  castor.php
.rw-r--r--  5,3k root  1 janv. 19:30  CODE_OF_CONDUCT.md
.rw-r--r--  3,7k root 28 janv. 09:31  composer.json
.rw-r--r--  340k root 28 janv. 09:31  composer.lock
.rw-r--r--  3,0k root  1 janv. 19:30  CONTRIBUTING.md
.rw-r--r--   884 root  1 janv. 19:30  importmap.php
.rw-r--r--  6,5k root  1 janv. 19:30  Makefile
.rw-r--r--   969 root  1 janv. 19:30  phpstan.neon
.rw-r--r--  1,3k root  1 janv. 19:30  phpunit.xml.dist
.rw-r--r--   18k root  1 janv. 19:30  README.md
.rw-r--r--  3,0k root  1 janv. 19:30  scc
.rw-r--r--  1,1k root  1 janv. 19:30  scrutinizer-ci.yaml
.rw-r--r--  1,7k root  1 janv. 19:30  SECURITY.md
.rw-r--r--  5,6k root  1 janv. 19:30  symfony.lock

How to reproduce

Normal install using docker:

docker run --rm -it -v $PWD:/app composer:latest create-project strangebuzz/microsymfony && cd microsymfony
make test

Possible Solution

Use a chown command after docker install such as

chown -R $USER .

This fixes the issue.

Additional Context

No response

florentdestremau avatar Jan 28 '25 09:01 florentdestremau

You are using Linux, I guess? I can't reproduce on macOS. Maybe a note about this potential problem should be added in the doc.

I remember with Linux, Docker rights are a little more tricky than on macOS. Because in this case, the project is created as root while with mac it is installed with the current user rights.

COil avatar Jan 29 '25 14:01 COil

Yes ubuntu, and the files are created as root

florentdestremau avatar Jan 30 '25 09:01 florentdestremau

Branch rebased.

COil avatar Feb 21 '25 17:02 COil

And the CI fails, the files coming from dunglas/symfony-docker must be updated :

  • https://github.com/dunglas/symfony-docker/commit/46e07dfce7f06865ba83069fd330b4d111914fc4

COil avatar Feb 21 '25 17:02 COil