bamarni / composer-bin-plugin

No conflicts for your bin dependencies
MIT License
462 stars 22 forks source link

Composer cache dir seems not be respected #63

Closed FrankGiesecke closed 2 years ago

FrankGiesecke commented 2 years ago

We have configured a special cache directory using the environment variable COMPOSER_CACHE_DIR.
When running composer install, the cache dir is used by composer.

But all packages installed by the composer-bin-plugin are always downloaded from their origin.

Why is the configured cache dir ignored?

$ composer install --no-interaction
Installing dependencies from lock file (including require-dev)
Verifying lock file contents can be installed on current platform.
Package operations: 96 installs, 0 updates, 0 removals
  - Installing bamarni/composer-bin-plugin (1.4.1): Extracting archive
  - Installing composer/package-versions-deprecated (1.11.99.1): Extracting archive
  - Installing azuyalabs/yasumi (2.3.0): Extracting archive
  - Installing ckeditor/ckeditor (4.4.8): Extracting archive
  - Installing clue/stream-filter (v1.5.0): Extracting archive
  - Installing developerforce/force.com-toolkit-for-php (dev-master a131708): Extracting archive
  - Installing doctrine/cache (1.11.0): Extracting archive
  - Installing doctrine/deprecations (v0.5.3): Extracting archive
  - Installing doctrine/event-manager (1.1.1): Extracting archive
  - Installing psr/container (1.1.1): Extracting archive
  - Installing symfony/service-contracts (v2.4.0): Extracting archive
  - Installing symfony/stopwatch (v5.2.7): Extracting archive
  - Installing symfony/polyfill-php80 (v1.23.1): Extracting archive
  - Installing symfony/polyfill-mbstring (v1.23.1): Extracting archive
  - Installing symfony/polyfill-intl-normalizer (v1.23.0): Extracting archive
  - Installing symfony/polyfill-intl-grapheme (v1.23.1): Extracting archive
  - Installing symfony/polyfill-ctype (v1.23.0): Extracting archive
  - Installing symfony/string (v5.3.10): Extracting archive
  - Installing symfony/polyfill-php73 (v1.23.0): Extracting archive
  - Installing symfony/deprecation-contracts (v2.5.0): Extracting archive
  - Installing symfony/console (v5.3.7): Extracting archive
  - Installing symfony/filesystem (v5.2.7): Extracting archive
  - Installing laminas/laminas-zendframework-bridge (1.1.1): Extracting archive
  - Installing laminas/laminas-eventmanager (3.2.1): Extracting archive
  - Installing laminas/laminas-code (3.4.1): Extracting archive
  - Installing friendsofphp/proxy-manager-lts (v1.0.3): Extracting archive
  - Installing doctrine/dbal (2.13.1): Extracting archive
  - Installing doctrine/migrations (2.3.3): Extracting archive
  - Installing symfony/property-info (v5.3.8): Extracting archive
  - Installing symfony/property-access (v5.2.4): Extracting archive
  - Installing symfony/options-resolver (v5.2.4): Extracting archive
  - Installing psr/log (1.1.3): Extracting archive
  - Installing symfony/polyfill-php72 (v1.22.1): Extracting archive
  - Installing symfony/polyfill-intl-idn (v1.22.1): Extracting archive
  - Installing ralouphie/getallheaders (3.0.3): Extracting archive
  - Installing psr/http-message (1.0.1): Extracting archive
  - Installing guzzlehttp/psr7 (1.8.2): Extracting archive
  - Installing guzzlehttp/promises (1.4.1): Extracting archive
  - Installing guzzlehttp/guzzle (6.5.5): Extracting archive
  - Installing dsvgruppe/zebra-adapter (1.2.0): Extracting archive
  - Installing react/promise (v2.8.0): Extracting archive
  - Installing ezimuel/guzzlestreams (3.0.1): Extracting archive
  - Installing ezimuel/ringphp (1.1.2): Extracting archive
  - Installing elasticsearch/elasticsearch (v7.11.0): Extracting archive
  - Installing facebook/graph-sdk (5.6.3): Extracting archive
  - Installing jdorn/sql-formatter (v1.2.17): Extracting archive
  - Installing phpseclib/phpseclib (2.0.31): Extracting archive
  - Installing paragonie/random_compat (v9.99.99): Extracting archive
  - Installing jumbojett/openid-connect-php (v0.9.2): Extracting archive
  - Installing kairos/phpqrcode (v1.0.0): Extracting archive
  - Installing laminas/laminas-loader (2.6.1): Extracting archive
  - Installing laminas/laminas-stdlib (3.2.1): Extracting archive
  - Installing container-interop/container-interop (1.2.0): Extracting archive
  - Installing laminas/laminas-validator (2.13.5): Extracting archive
  - Installing laminas/laminas-escaper (2.6.1): Extracting archive
  - Installing laminas/laminas-uri (2.7.1): Extracting archive
  - Installing laminas/laminas-server (2.8.1): Extracting archive
  - Installing laminas/laminas-soap (2.8.0): Extracting archive
  - Installing laminas/laminas-xml (1.2.0): Extracting archive
  - Installing laminas/laminas-math (3.2.0): Extracting archive
  - Installing laminas/laminas-http (2.13.0): Extracting archive
  - Installing laminas/laminas-xmlrpc (2.9.0): Extracting archive
  - Installing league/mime-type-detection (1.7.0): Extracting archive
  - Installing league/flysystem (2.3.1): Extracting archive
  - Installing league/flysystem-memory (2.0.6): Extracting archive
  - Installing php-http/message-factory (v1.0.2): Extracting archive
  - Installing php-http/message (1.11.0): Extracting archive
  - Installing psr/http-client (1.0.1): Extracting archive
  - Installing php-http/promise (1.1.0): Extracting archive
  - Installing php-http/httplug (2.2.0): Extracting archive
  - Installing php-http/discovery (1.13.0): Extracting archive
  - Installing php-http/guzzle6-adapter (v2.0.2): Extracting archive
  - Installing thecodingmachine/gotenberg-php-client (6.3.0): Extracting archive
  - Installing league/flysystem-sftp (2.2.1): Extracting archive
  - Installing league/flysystem-ftp (2.3.1): Extracting archive
  - Installing dg/bypass-finals (v1.3.1): Extracting archive
  - Installing mikey179/vfsstream (v1.6.8): Extracting archive
  - Installing mustache/mustache (v2.13.0): Extracting archive
  - Installing nikic/fast-route (v1.3.0): Extracting archive
  - Installing php-amqplib/php-amqplib (v2.7.3): Extracting archive
  - Installing roave/security-advisories (dev-master db47aac)
  - Installing sentry/sentry (1.11.0): Extracting archive
  - Installing squizlabs/php_codesniffer (3.6.0): Extracting archive
  - Installing symfony/var-exporter (v5.2.7): Extracting archive
  - Installing psr/cache (1.0.1): Extracting archive
  - Installing symfony/cache-contracts (v2.4.0): Extracting archive
  - Installing symfony/cache (v5.2.7): Extracting archive
  - Installing symfony/finder (v5.2.4): Extracting archive
  - Installing symfony/http-foundation (v5.2.7): Extracting archive
  - Installing symfony/lock (v5.2.6): Extracting archive
  - Installing symfony/process (v5.4.0): Extracting archive
  - Installing symfony/serializer (v5.3.12): Extracting archive
  - Installing tedivm/jshrink (v1.3.3): Extracting archive
  - Installing symfony/css-selector (v5.2.7): Extracting archive
  - Installing tijsverkoyen/css-to-inline-styles (2.2.3): Extracting archive
  - Installing webmozart/assert (1.10.0): Extracting archive
Package container-interop/container-interop is abandoned, you should avoid using it. Use psr/container instead.
Generating autoload files
composer/package-versions-deprecated: Generating version class...
composer/package-versions-deprecated: ...done generating version class
43 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
Installing dependencies from lock file (including require-dev)
Verifying lock file contents can be installed on current platform.
Package operations: 3 installs, 0 updates, 0 removals
  - Downloading php-parallel-lint/php-console-color (v0.3)
  - Downloading php-parallel-lint/php-console-highlighter (v0.5)
  - Downloading php-parallel-lint/php-parallel-lint (v1.3.1)
  - Installing php-parallel-lint/php-console-color (v0.3): Extracting archive
  - Installing php-parallel-lint/php-console-highlighter (v0.5): Extracting archive
  - Installing php-parallel-lint/php-parallel-lint (v1.3.1): Extracting archive
Generating autoload files
theofidry commented 2 years ago

The plugin itself does very little there: https://github.com/bamarni/composer-bin-plugin/blob/master/src/BinCommand.php#L115

so the first thing I would investigate is how COMPOSER_CACHE_DIR is passed if it's correctly inherited by ComposerApplication. I can't have a look at it before a while though

theofidry commented 2 years ago

@FrankGiesecke as per #116 everything looks fine here: the bin plugin may only change the bin directory and nothing else.

I did notice however that if COMPOSER_CACHE_DIR points to a relative path, then the resolved path will not be the same when executed from the root than to a namespace as the environment variables are re-evaluated.

FrankGiesecke commented 2 years ago

as per https://github.com/bamarni/composer-bin-plugin/pull/116 everything looks fine here: the bin plugin may only change the bin directory and nothing else.

That's good and I can confirm that this also works in real live.

@FrankGiesecke as per https://github.com/bamarni/composer-bin-plugin/pull/116 everything looks fine here: the bin plugin may only change the bin directory and nothing else.

I did notice however that if COMPOSER_CACHE_DIR points to a relative path, then the resolved path will not be the same when executed from the root than to a namespace as the environment variables are re-evaluated.

Thats good to know. I'll check my pipelines for this and give you a feedback.