Search code examples
laravelcomposer-phptravis-ci

Travis CI: Build failing because of "uncommitted changes"


We've been using Travis CI for weeks on this project without issue, now suddenly our builds are failing because of "uncommitted changes". I've no idea why.

  - Upgrading ramsey/collection (1.1.1 => 1.1.3): Checking out 28a5c4ab2f from cache
  - Upgrading brick/math (0.9.1 => 0.9.2): Checking out dff976c2f3 from cache
  - Upgrading symfony/translation (v5.2.1 => v5.2.5): Checking out 0947ab1e3a from cache
                                                                               
  [RuntimeException]                                                           
  Source directory /home/travis/build/vendor/nesbot/carbon has uncommitted changes.  

What's strange is that our .travis.yml file hasn't changed at all.

language: php

php:
  - 7.3

services:
  - mysql

before_install:
  - mysql -e 'CREATE DATABASE travis_test;'

cache:
  directories:
    - node_modules
    - vendor

before_script:
  - cp .env.travis .env
  - sudo mysql -e 'create database homestead;'
  - composer self-update
  - composer install --prefer-source --no-interaction --dev
  - php artisan key:generate
  - php artisan migrate --no-interaction -vvv
  - php artisan import:required-data

script:
  - php artisan test

notifications:
  email: false

What is causing this "uncommitted changes" error? How can I fix it?


Solution

  • Travis CI stores a cache of your vendor folder. Sometimes if you've performed a composer update locally it can cause some issues with that cached folder. The solution is to clear your caches and force Travis CI to build everything from scratch again.

    To do this, go to your project in Travis CI, click More options > Caches. And on that page you can clear all your caches. Then ask Travis CI to rebuild.

    It will take a lot longer the first time, but it should clear this error message.