PHP 7.3: pre-install PHPUnit version 9.0 is broken

Running a php 7.3 build, pre-installed PHPUnit 9 fails:

$ phpunit
PHPUnit 9.0.1 by Sebastian Bergmann and contributors.
Cannot open file "/home/travis/build/[secure]/carddav2fb/vendor/autoload.php".
The command "phpunit" exited with 1.

This happens due to the PHPUnit step executed before the repo is cloned. It seems that PHPUnit 9.1does not have this behaviour.

This is still a problem. The PHP 7.3 version is unusable for me:

$ phpenv global 7.3
$ composer self-update
Updating to version 1.10.7 (stable channel).
Downloading (connecting...)Downloading (100%)
Use composer self-update --rollback to return to version 1.10.6
Setting up build cache

$ php --version
PHP 7.3.18 (cli) (built: May 15 2020 06:05:01) ( ZTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.18, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.3.18, Copyright (c) 1999-2018, by Zend Technologies
    with Xdebug v2.9.5, Copyright (c) 2002-2020, by Derick Rethans
$ composer --version
Composer version 1.10.7 2020-06-03 10:03:56

$ phpunit
PHPUnit 9.1.4 by Sebastian Bergmann and contributors.

Cannot open file "/home/travis/build/[secure]/carddav2fb/vendor/autoload.php".

When reporting problems, please consider including:

  1. What you are trying to achieve
  2. What you have tried (probably a link to the configuration)
  3. What happened instead (often, pointing to a build log URL, in the form of https://travis-ci.com/OWNER/REPO/build/NNNNNNN would be helpful).

I’m trying to run a php 7.3 build, here is an example: https://travis-ci.org/github/andig/carddav2fb/builds/696800149.

The configuration is in https://github.com/andig/carddav2fb/blob/master/.travis.yml.

Why is this file getting loaded? And does it exist?

A simple invocation of phpunit does not exhibit this behavior https://travis-ci.org/github/BanzaiMan/travis_production_test/builds/696826619#L449

As an aside, I mention that


defines both matrix and jobs, so jobs is ignored. See the config validation message in https://travis-ci.org/github/andig/carddav2fb/jobs/696800150/config

The file does not exist because it will only exist after composer install has run. I wrote:

This happens due to the PHPUnit step executed before the repo is cloned. It seems that PHPUnit 9.1does not have this behaviour.

I was wrong about repo being cloned, the relevant step is composer install.

The main point here is that- independent from matrix vs jobs (which I’ll double-check) that invoking phpunit before composer is broken when phpunit 9.0 is used. As this is happening before using script in travis is run, it’s out of user’s control.

In PHP, there is no default install step, so composer install should not be running. I don’t see the evidence it, either. If your repo is expecting to run composer install in the install phase, you’ll have to make sure that it is. (Because it is not, due to your error in .travis.yml.)

Looks like your fixing the build configuration fixed this issue.

https://travis-ci.org/github/andig/carddav2fb/jobs/696865229

Indeed, thanks to your hint I was able to fix the config. This used to work before (which is what users are always saying, I know ;).
I understand the install step is run before phpunit version is executed. I wasn‘t aware of the connection, thank you very much!

1 Like