Question: I'm experiencing a random problem.

```
before_script:
  - cd sources
  - php -v

test:
    script:
        - phpunit -c mypath

```

70% of the time I'm getting this error:

```
$ php -v
bash: line 24: php: command not found

ERROR: Build failed with: exit code 1

```

But the weird thing is if I keep re running the same build it'll pass.

Any ideas?

Answer: 
Actually several runners are available, but I can only use one of them. All I had to do is to add `tags` to my job to select the runner.

```
before_script:
  - cd sources
  - php -v

test:
    script:
        - phpunit -c mypath
    tags:
      - php

```
PHP is not installed in the runners enviromnent where the tests are executed.

You have to make sure that the runner has an enviromnent which has PHP installed.
You did not specified what kind of runner you are using in your question, so I suggest you have a runner which runs docker container (as standard).

To accomplish your goal (avoiding `bash: line 24: php: command not found`) you can go two ways:

Let your project run in an docker image which has php installed

```
image: php
before_script:
  - cd sources
  - php -v

test:
    script:
        - phpunit -c mypath

```

**OR**

Use a rudementary image and install php

```
image: debian
before_script:
  - cd sources
  - apt-get install php5*
  - php -v

test:
    script:
        - phpunit -c mypath

```

If you are not using docker as runner executor then install php on your mashine where the runner runs.