thecodingmachine / docker-images-php

A set of PHP Docker images
MIT License
791 stars 140 forks source link

Composer self-update not working due to permissions #246

Closed benr77 closed 3 years ago

benr77 commented 3 years ago

Expected Behavior

When running a composer command, when it tries to self update, the self update succeeds.

Current Behavior

docker run -it --rm -v "$PWD":/usr/src/app thecodingmachine/php:7.4-v4-cli composer self-update

Instead, I get the following error

Upgrading to version 2.0.11 (stable channel).

  [Composer\Downloader\FilesystemException]                                                           
  Filesystem exception:                                                                               
  Composer update failed: "/usr/local/bin/composer" could not be written.                             
  rename(/home/docker/.composer/cache/composer-temp.phar,/usr/local/bin/composer): Permission denied  

self-update [-r|--rollback] [--clean-backups] [--no-progress] [--update-keys] [--stable] [--preview] [--snapshot] [--1] [--2] [--set-channel-only] [--] [<version>]

Context

This means I can't run the latest composer.

I get the impression that this would happen already to many many people, so am wondering if I'm missing something obvious?

Your Environment

Newly pulled latest thecodingmachine/php:7.4-v4-cli image.

gulien commented 3 years ago

Does it make sense to update composer manually in a Docker image?

Every week, we rebuild the images automatically so that we're up-to-date with the latest versions of PHP / Composer / etc. The idea is that by pulling the latest image, you should have most dependencies up-to-date.

Last build failed though and I didn't have time to look at the issue.

benr77 commented 3 years ago

Ok, I understand and agree with you.

The issue happened to me whilst running a build script in a third party package that first self updated composer. I could get round it by disabling the self-update statement.

As you say under normal circumstances if I'd just pulled the latest image it should have the latest composer etc by default anyway. So not to worry this is a non-issue then.

Thanks for your time.