composer / composer

Dependency Manager for PHP
https://getcomposer.org/
MIT License
28.64k stars 4.56k forks source link

Symlinked config.json is not longer readable #12134

Open alexander-schranz opened 1 month ago

alexander-schranz commented 1 month ago

Interesting I'm not sure when it triggers into this error as I try create tmp projects in /tmp composer works fine but inside my normal working dir /Users/alexanderschranz/Documents/Projects/ stopped to working.

My `composer.json`: ```json { "name": "sulu/skeleton", "license": "MIT", "type": "project", "description": "Project template for starting your new project based on the Sulu content management system", "homepage": "https://sulu.io/", "keywords": [ "symfony", "sulu", "sulucms", "cms", "web-application", "platform", "data-managment", "project-template" ], "authors": [ { "name": "Sulu Community", "homepage": "https://github.com/sulu/skeleton/graphs/contributors" } ], "support": { "issues": "https://github.com/sulu/skeleton/issues", "source": "https://github.com/sulu/skeleton", "docs": "https://docs.sulu.io/", "chat": "https://sulu.io/services-and-support#chat" }, "require": { "php": "^8.2", "ext-ctype": "*", "ext-iconv": "*", "doctrine/doctrine-bundle": "^2.12", "doctrine/doctrine-fixtures-bundle": "^3.6", "friendsofsymfony/http-cache-bundle": "^3.0", "handcraftedinthealps/zendsearch": "^2.1", "jackalope/jackalope-doctrine-dbal": "^1.10 || ^2.0", "phpcr/phpcr-migrations-bundle": "^1.6", "phpcr/phpcr-shell": "^1.6", "scheb/2fa-bundle": "^7.2", "scheb/2fa-email": "^7.2", "scheb/2fa-trusted-device": "^7.2", "stof/doctrine-extensions-bundle": "^1.11", "sulu/sulu": "~2.6.4", "symfony/config": "^7.1", "symfony/dotenv": "^7.1", "symfony/flex": "^1.17 || ^2.0", "symfony/framework-bundle": "^7.1", "symfony/mailer": "^7.1", "symfony/monolog-bridge": "^7.1", "symfony/monolog-bundle": "^3.4", "symfony/runtime": "^7.1", "symfony/security-bundle": "^7.1", "symfony/twig-bundle": "^7.1" }, "require-dev": { "jangregor/phpstan-prophecy": "^1.0", "php-cs-fixer/shim": "^3.58", "phpspec/prophecy-phpunit": "^2.1", "phpstan/extension-installer": "^1.3", "phpstan/phpstan": "^1.10", "phpstan/phpstan-doctrine": "^1.3", "phpstan/phpstan-phpunit": "^1.3", "phpstan/phpstan-symfony": "^1.3", "phpstan/phpstan-webmozart-assert": "^1.2", "phpunit/phpunit": "^9.6", "rector/rector": "^1.0", "sulu/sulu-rector": "^1.0", "symfony/browser-kit": "^7.1", "symfony/css-selector": "^7.1", "symfony/debug-bundle": "^7.1", "symfony/error-handler": "^7.1", "symfony/phpunit-bridge": "^7.1", "symfony/thanks": "^1.2", "symfony/web-profiler-bundle": "^7.1", "thecodingmachine/phpstan-strict-rules": "^1.0", "vincentlanglet/twig-cs-fixer": "^3.0" }, "conflict": { "symfony/symfony": "*" }, "autoload": { "psr-4": { "App\\": "src/" } }, "autoload-dev": { "psr-4": { "App\\Tests\\": "tests/" } }, "replace": { "paragonie/random_compat": "2.*", "symfony/polyfill-ctype": "*", "symfony/polyfill-iconv": "*", "symfony/polyfill-php82": "*", "symfony/polyfill-php81": "*", "symfony/polyfill-php80": "*", "symfony/polyfill-php74": "*", "symfony/polyfill-php73": "*", "symfony/polyfill-php72": "*", "symfony/polyfill-php71": "*", "symfony/polyfill-php70": "*", "symfony/polyfill-php56": "*" }, "scripts": { "auto-scripts": { "cache:clear": "symfony-cmd", "assets:install %PUBLIC_DIR%": "symfony-cmd", "bin/websiteconsole cache:clear": "php-script", "bin/adminconsole sulu:media:init": "php-script", "bin/adminconsole massive:search:init": "php-script" }, "post-install-cmd": [ "@auto-scripts" ], "post-update-cmd": [ "@auto-scripts" ], "post-root-package-install": [ "@php -r \"file_put_contents('.env.local', 'APP_ENV=dev' . PHP_EOL);\"", "@php -r \"file_put_contents('.env', str_replace('APP_SECRET=\\'\\$ecretf0rt3st\\'', 'APP_SECRET=' . bin2hex(random_bytes(16)), file_get_contents('.env')));\"" ], "post-create-project-cmd": [ "@php -r \"file_put_contents('.gitignore', str_replace(['composer.lock' . PHP_EOL, 'package-lock.json' . PHP_EOL, 'yarn.lock' . PHP_EOL, 'bun.lockb' . PHP_EOL, 'pnpm-lock.yaml' . PHP_EOL], '', file_get_contents('.gitignore')));\"", "@php bin/adminconsole sulu:admin:info --ansi" ], "serve": [ "Composer\\Config::disableProcessTimeout", "@php -S 127.0.0.1:8000 -t public config/router.php" ], "bootstrap-test-environment": [ "@php bin/adminconsole doctrine:database:drop --if-exists --force --env test", "@php bin/adminconsole doctrine:database:create --env test", "@php bin/adminconsole doctrine:schema:create --env test" ], "test": "@php bin/phpunit", "test-with-coverage": "@test --coverage-php var/reports/coverage.php --coverage-cobertura=var/reports/cobertura-coverage.xml --coverage-html var/reports/html --log-junit var/reports/junit.xml", "lint": [ "@phpstan", "@lint-php-cs", "@lint-rector", "@lint-twig", "@lint-twig-cs", "@lint-yaml", "@lint-xliff", "@lint-translations", "@lint-container", "@lint-composer", "@lint-doctrine" ], "fix": [ "@rector", "@php-cs-fix", "@twig-cs-fix" ], "phpstan": [ "@php bin/websiteconsole cache:warmup --env=dev", "@php vendor/bin/phpstan analyze" ], "rector": [ "@php vendor/bin/rector process" ], "lint-rector": [ "@php bin/websiteconsole cache:warmup --env=dev", "@php vendor/bin/rector process --dry-run" ], "php-cs-fix": "@php vendor/bin/php-cs-fixer fix", "lint-php-cs": "@php vendor/bin/php-cs-fixer fix --verbose --diff --dry-run", "twig-cs-fix": "@php vendor/bin/twig-cs-fixer lint --fix", "lint-twig-cs": "@php vendor/bin/twig-cs-fixer lint", "lint-composer": "@composer validate --no-check-publish --strict", "lint-twig": "@php bin/console lint:twig templates/", "lint-xliff": "@php bin/console lint:xliff translations/", "lint-translations": [ "@php bin/console debug:translation en --only-missing" ], "lint-yaml": "@php bin/console lint:yaml config/ --parse-tags", "lint-container": [ "@php bin/console lint:container --env dev", "@php bin/console lint:container --env test", "@php bin/console lint:container --env stage", "@php bin/console lint:container --env prod" ], "lint-doctrine": [ "@php bin/console doctrine:schema:validate --skip-sync", "@php bin/console doctrine:ensure-production-settings --env stage", "@php bin/console doctrine:ensure-production-settings --env prod" ] }, "config": { "allow-plugins": { "composer/package-versions-deprecated": true, "php-http/discovery": true, "symfony/flex": true, "symfony/runtime": true, "symfony/thanks": true, "phpstan/extension-installer": true }, "optimize-autoloader": true, "sort-packages": true }, "extra": { "symfony": { "allow-contrib": true, "require": "7.1.*" } } } ```

My config.json:

{
    "config": {
        "preferred-install": {
            "sulu/*": "source",
            "l91/*": "source",
            "schranz/*": "source",
            "schranz-templating/*": "source",
            "php-task/*": "source",
            "handcraftedinthealps/*": "source",
            "massive/*": "source"
        }
    }
}

Output of composer diagnose:

In JsonFile.php line 204:

  The file "/Users/alexanderschranz/.composer/config.json" is not readable.

diagnose

When running inside /tmp it works and output:

Checking platform settings: OK
Checking git settings: OK git version 2.45.2
Checking http connectivity to packagist: OK
Checking https connectivity to packagist: OK
Checking github.com oauth access: OK expires on 2025-01-14 23:00:00 UTC
Checking disk free space: OK
Checking pubkeys: 
Tags Public Key Fingerprint: 57815BA2 7E54DC31 7ECC7CC5 573090D0  87719BA6 8F3BB723 4E5D42D0 84A14642
Dev Public Key Fingerprint: 4AC45767 E5EC2265 2F0C1167 CBBB8A2B  0C708369 153E328C AD90147D AFE50952
OK
Checking Composer version: OK
Checking Composer and its dependencies for vulnerabilities: OK
Composer version: 2.7.9
PHP version: 8.3.9
PHP binary path: /opt/homebrew/Cellar/php/8.3.9/bin/php
OpenSSL version: OpenSSL 3.3.1 4 Jun 2024
curl version: 8.8.0 libz 1.2.11 ssl (SecureTransport) OpenSSL/3.3.1
zip: extension present, unzip present, 7-Zip not available

When I run this command:

composer <command>

I get the following output:

  The file "/Users/alexanderschranz/.composer/config.json" is not readable.

Commands in /tmp dir works or without symlinked config.json:

Symlink:

lrwxr-xr-x   1 alexanderschranz  staff    63B 27 Sep 13:50 config.json@ -> /Users/alexanderschranz/Documents/dotfiles/composer/config.json

Config.json:

-rw-r--r--   1 alexanderschranz  staff   329B 17 Aug  2022 config.json

When my config.json is not longer a symlink it works again.

And I expected this to happen:

Happening since I updated to 2.7.9 did a rollback then to 2.7.7 but happening again so not 100% if its really upgrade problem.

Seldaek commented 1 month ago

Weird, I cannot repro this with the link like..

lrwxrwxrwx 1 seld seld 51 Oct 2 11:30 ~/.config/composer/config.json -> ~/.config/composer/config-real.json -rw-rw-rw- 1 seld seld 21 Jul 2 22:24 ~/.config/composer/config-real.json

diagnose works fine and other commands too.

Can you share output of this?

php -r '$f="/Users/alexanderschranz/.composer/config.json"; var_dump(is_readable($f), is_file($f), is_link($f), file_get_contents($f));'

I get true, true, true, <config contents>