PHP builds failing on "phpenv: command not found"

My builds keep failing when it attempts to set the PHP version. I get a message that says “Looks like we had a bug in our infrastructure…”, so is a possible Circle CI bug?

Here is the action message when it fails:

/opt/google-cloud-sdk/path.bash.inc: line 1: readlink: command not found
/home/ubuntu/.circlerc: line 47: phpenv: command not found
((phpenv global “7.0.4”)) returned exit code 127((phpenv global “7.0.4”)) returned exit code 127
Action failed: set php version to 7.0.4

And here is my circle.yml, if it helps:

machine:
  timezone:
    America/Chicago
  php:
    version: 7.0.4
  hosts:
    trackatron.dev: 127.0.0.1
  environment:
    APP_ENV: circle
    APP_DEBUG: true
    DB_HOST: 127.0.0.1
    DB_DATABASE: circle_test
    DB_USERNAME: ubuntu
    CACHE_DRIVER: file
    SESSION_DRIVER: file
    QUEUE_DRIVER: sync
    PATH: /home/ubuntu/bin, ~/.composer/vendor/bin
dependencies:
  post:
    - composer global require "laravel/envoy=~1.0"
    - php artisan key:generate
    - php artisan migrate --seed
general:
  branches:
    only:
      - master
      - develop
deployment:
  production:
    branch: master
    commands:
      - envoy run deploy

Hi,

If you’re running on the Trusty container, can you try using PHP version 7.0.3 instead of 7.0.4 to see if that works?

Just tried 7.0.3, same problem:

/opt/google-cloud-sdk/path.bash.inc: line 1: readlink: command not found
/home/ubuntu/.circlerc: line 47: phpenv: command not found

((phpenv global “7.0.3”)) returned exit code 127((phpenv global “7.0.3”)) returned exit code 127

Action failed: set php version to 7.0.3

Hi Michelle,

Sorry for the delay. I was running a bunch of test to figure out what the problem was here and I think I got it. It looks like when you set PATH in circle.yml, you’re killing something that is needed to properly load PHP. Based on the circle.yml snippet you provided above, I think I have a solution for you.

If you’re on a Trusty container, please make the following two changes to the machine section:

machine:
  php:
    version: 7.0.3
  environment:
    PATH: "${PATH}:${HOME}/.composer/vendor/bin"

For Precise, the following is good:

machine:
  php:
    version: 7.0.4
  environment:
    PATH: "${PATH}:${HOME}/.composer/vendor/bin"

Let me know if that fixes the issue. Also, if this works for you I’ll be sure to update our documentation to making using the PATH variable clearer.

Awesome, that seems to have fixed it. Thanks for your help! :slight_smile:

1 Like

I have the same error, but I don’t have PATH defined.

Hi,

Can you please create a new topic then as this sounds like a different issue? circle.yml (without any sensitive info) and the error text would be helpful.

Thanks.