Composer install fails


I use CircleCI to build (with docker) a test environement to run my symfony 3.4 application.

The last successful build was 27 days ago. I deployed a new feature yesterday but the composer install step is failing for no reason (the message is not very explicit).

This the error message:

This step used to run without trouble.

Here is the config.yml:

# PHP CircleCI 2.0 configuration file
# Check for more details
version: 2
        # docker:
        #- image: circleci/php:7.1-cli-jessie-node-browsers-legacy
        machine: true
        working_directory: ~/repo

            - checkout
            - run: mkdir ~/repo/features/fail-screenshots

            - run: cp .circleci/.env.dist .env
            - run: cp .circleci/parameters.yml.dist app/config/parameters.yml
            - run: docker-compose up -d

            # Download and cache dependencies
            - restore_cache:
                    - v1-dependencies-{{ checksum "composer.json" }}
                    # fallback to using the latest cache if no exact match is found
                    - v1-dependencies-

            - run: docker-compose exec --user 1001:1002 php composer install -n --prefer-dist

            - save_cache:
                    - ./vendor
                key: v1-dependencies-{{ checksum "composer.json" }}

            - run: docker-compose run --rm front yarn install
            - run: docker-compose run --rm front yarn build

            # run tests!

            # Circleci uses a user with id 1001 and a group with id 1002
            # We use this user instead of the default one in our dockerfile (1000)
            # to avoid permissions issues
            - run: docker-compose exec --user=1001:1002 php vendor/bin/phpspec run -vvv
            # We use the root user here to change logs and cache permissions
            - run: docker-compose exec --user=root php chmod -R 777 var/logs
            - run: docker-compose exec --user=root php chmod -R 777 var/cache
            - run: docker-compose exec php console doctrine:database:drop --if-exists --force --env=test
            - run: docker-compose exec php console doctrine:database:cre --env=test
            - run: docker-compose exec php console doc:sch:cre --env=test
            - run: docker-compose exec php console doctrine:fixtures:load --env=test -n
            # Here we use 1001:1002 to launch behat cause it can create screenshots
            # so it needs to write in a directory owned by 1001:1002 (circleci user)
            - run: docker-compose exec --user 1001:1002 php ./vendor/bin/behat -v

            # This line is to be able to access failing screenshots in the
            # artifacts section in CircleCI
            - store_artifacts:
                path: ~/repo/features/fail-screenshots

            - store_artifacts:
                path: ~/repo/features/spooled-emails

The PHP docker file:

FROM php:7.1-fpm-alpine

RUN apk --no-cache add \
    mariadb-client \

RUN docker-php-ext-configure intl

RUN docker-php-ext-install \
    intl \
    pdo \

RUN docker-php-ext-enable intl

RUN echo "date.timezone=\"Europe/Paris\"" >> /usr/local/etc/php/conf.d/timezone.ini

RUN mkdir -p /usr/share/www/project && adduser -D -u 1000 user

RUN php -r "copy('', 'composer-setup.php');" \
    && php composer-setup.php \
    && php -r "unlink('composer-setup.php');" \
    && mv composer.phar /usr/bin/composer

USER user

RUN composer global require hirak/prestissimo
RUN composer global require friendsofphp/php-cs-fixer

WORKDIR /usr/share/www/project

ENV PATH "$PATH:vendor/bin:bin:$HOME/.composer/vendor/bin"

You’ll find that won’t build locally either. You’ve requested a conflicting set of packages, and you need to adjust your composer.json to sort that out.

Do you have a composer.lock committed in your repo? That is a good idea too.

Hello @halfer thanks for your answer.

I tested to build it locally (I removed the vendor directory and it worked). That’s why I’m a bit lost and I did’nt add any new dependency.

I have a composer.lock file committed. Do you have an idea ?

My guess is that the version you have locally is not the same as the one you have remotely. Try a completely fresh checkout in a separate folder on your local machine.

It may also be worth ensuring you have not committed a vendor folder to the repo also, in case that is confusing things.

@halfer You were right. I managed to find the packages that caused this issue :slight_smile:

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.