Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dotenv errors since Composer 1.7 #27

Closed
MWDelaney opened this issue Aug 3, 2018 · 5 comments
Closed

Dotenv errors since Composer 1.7 #27

MWDelaney opened this issue Aug 3, 2018 · 5 comments

Comments

@MWDelaney
Copy link

Hi,
Since Composer 1.7 was released earlier today, I can no longer install acf-pro-installer as part of a Trellis deployment; I get the following error(s) related to Dotenv/Dotenv:

Loading composer repositories with package information Installing
dependencies from lock file Package operations: 20 installs, 0 updates, 0
removals As there is no 'unzip' command installed zip files are being
unpacked using the PHP zip extension. This may cause invalid reports of
corrupted archives. Installing 'unzip' may remediate them. - Installing
composer/installers (v1.5.0): Loading from cache - Installing johnpbloch
/wordpress-core-installer (1.0.0.2): Loading from cache - Installing
vlucas/phpdotenv (v2.5.1): Loading from cache - Installing philippbaschke
/acf-pro-installer (v1.0.2): Loading from cache - Installing advanced-custom-
fields/advanced-custom-fields-pro (5.6.10): PHP Fatal error: Uncaught Error:
Class 'Dotenv\Dotenv' not found in /srv/www/example.com/releas
es/20180803151702/vendor/philippbaschke/acf-pro-
installer/src/ACFProInstaller/Plugin.php:246 Stack trace: #0 /srv/www/example.com/releases/20180803151702/vendor/philippbaschke/acf-pro-
installer/src/ACFProInstaller/Plugin.php(226):
PhilippBaschke\ACFProInstaller\Plugin->loadDotEnv() #1 /srv/www/example.com/releases/20180803151702/vendor/philippbaschke/acf-pro-
installer/src/ACFProInstaller/Plugin.php(144):
PhilippBaschke\ACFProInstaller\Plugin->getKeyFromEnv() #2 [internal
function]: PhilippBaschke\ACFProInstaller\Plugin->addKey(Object(Composer\Plug
in\PreFileDownloadEvent)) #3 phar:///usr/local/bin/composer/src/Composer/Even
tDispatcher/EventDispatcher.php(176): call_user_func(Array,
Object(Composer\Plugin\PreFileDownloadEvent)) #4 phar:///usr/local/bin/compos
er/src/Composer/EventDispatcher/EventDispatcher.php(81):
Composer\EventDispatcher\EventDispatcher->doDispatch(Object(Composer\Plugin\P
in /srv/www/example.com/releases/20180803151702/vendor/philipp
baschke/acf-pro-installer/src/ACFProInstaller/Plugin.php on line 246
fatal: [staging.example.com]: FAILED! => {"changed": false, "stdout": "Loading composer repositories with package information\nInstalling dependencies from lock file\nPackage operations: 20 installs, 0 updates, 0 removals\nAs there is no 'unzip' command installed zip files are being unpacked using the PHP zip extension.\nThis may cause invalid reports of corrupted archives. Installing 'unzip' may remediate them.\n  - Installing composer/installers (v1.5.0): Loading from cache\n  - Installing johnpbloch/wordpress-core-installer (1.0.0.2): Loading from cache\n  - Installing vlucas/phpdotenv (v2.5.1): Loading from cache\n  - Installing philippbaschke/acf-pro-installer (v1.0.2): Loading from cache\n  - Installing advanced-custom-fields/advanced-custom-fields-pro (5.6.10): PHP Fatal error:  Uncaught Error: Class 'Dotenv\\Dotenv' not found in /srv/www/example.com/releases/20180803151702/vendor/philippbaschke/acf-pro-installer/src/ACFProInstaller/Plugin.php:246\nStack trace:\n#0 /srv/www/example.com/releases/20180803151702/vendor/philippbaschke/acf-pro-installer/src/ACFProInstaller/Plugin.php(226): PhilippBaschke\\ACFProInstaller\\Plugin->loadDotEnv()\n#1 /srv/www/example.com/releases/20180803151702/vendor/philippbaschke/acf-pro-installer/src/ACFProInstaller/Plugin.php(144): PhilippBaschke\\ACFProInstaller\\Plugin->getKeyFromEnv()\n#2 [internal function]: PhilippBaschke\\ACFProInstaller\\Plugin->addKey(Object(Composer\\Plugin\\PreFileDownloadEvent))\n#3 phar:///usr/local/bin/composer/src/Composer/EventDispatcher/EventDispatcher.php(176): call_user_func(Array, Object(Composer\\Plugin\\PreFileDownloadEvent))\n#4 phar:///usr/local/bin/composer/src/Composer/EventDispatcher/EventDispatcher.php(81): Composer\\EventDispatcher\\EventDispatcher->doDispatch(Object(Composer\\Plugin\\P in /srv/www/example.com/releases/20180803151702/vendor/philippbaschke/acf-pro-installer/src/ACFProInstaller/Plugin.php on line 246\n", "stdout_lines": ["Loading composer repositories with package information", "Installing dependencies from lock file", "Package operations: 20 installs, 0 updates, 0 removals", "As there is no 'unzip' command installed zip files are being unpacked using the PHP zip extension.", "This may cause invalid reports of corrupted archives. Installing 'unzip' may remediate them.", "  - Installing composer/installers (v1.5.0): Loading from cache", "  - Installing johnpbloch/wordpress-core-installer (1.0.0.2): Loading from cache", "  - Installing vlucas/phpdotenv (v2.5.1): Loading from cache", "  - Installing philippbaschke/acf-pro-installer (v1.0.2): Loading from cache", "  - Installing advanced-custom-fields/advanced-custom-fields-pro (5.6.10): PHP Fatal error:  Uncaught Error: Class 'Dotenv\\Dotenv' not found in /srv/www/example.com/releases/20180803151702/vendor/philippbaschke/acf-pro-installer/src/ACFProInstaller/Plugin.php:246", "Stack trace:", "#0 /srv/www/example.com/releases/20180803151702/vendor/philippbaschke/acf-pro-installer/src/ACFProInstaller/Plugin.php(226): PhilippBaschke\\ACFProInstaller\\Plugin->loadDotEnv()", "#1 /srv/www/example.com/releases/20180803151702/vendor/philippbaschke/acf-pro-installer/src/ACFProInstaller/Plugin.php(144): PhilippBaschke\\ACFProInstaller\\Plugin->getKeyFromEnv()", "#2 [internal function]: PhilippBaschke\\ACFProInstaller\\Plugin->addKey(Object(Composer\\Plugin\\PreFileDownloadEvent))", "#3 phar:///usr/local/bin/composer/src/Composer/EventDispatcher/EventDispatcher.php(176): call_user_func(Array, Object(Composer\\Plugin\\PreFileDownloadEvent))", "#4 phar:///usr/local/bin/composer/src/Composer/EventDispatcher/EventDispatcher.php(81): Composer\\EventDispatcher\\EventDispatcher->doDispatch(Object(Composer\\Plugin\\P in /srv/www/example.com/releases/20180803151702/vendor/philippbaschke/acf-pro-installer/src/ACFProInstaller/Plugin.php on line 246"]}

This seems related to #21 and #17 but I haven't seen this problem specifically until the new version of Composer shipped this morning.

Pinning Composer to 1.6.5 on the server I'm deploying to resolves the issue for me, but this obviously isn't a great fix.

@HansCz
Copy link

HansCz commented Aug 3, 2018

@MWDelaney I have the exact same issue, but in my development environment.

I am quite new to Trellis, so I was hoping you could describe how you pin composer to 1.6.5 to fix this issue.

Thank you.

@MWDelaney
Copy link
Author

@HansCz here’s what I did:

At the top of trellis/group_vars/all/main.yml

Replace this line:

composer_keep_updated: true

With this:

composer_version: 1.6.5

That got me going for the day but it’s not a good fix for the problem. Hopefully there’s a simple fix somewhere. It almost seems like dotenv isn’t available by the time acf-pro-installer needs it? Could it be an order of operations thing?

@PhilippBaschke any insight? I love this tool and I’d hate to have to find another solution!

@HansCz
Copy link

HansCz commented Aug 4, 2018

Got it working. Thanks @MWDelaney

For anybody else as new to this as me who needs the steps spelled out in greater detail, add the following steps to @MWDelaney's instruction:

  • ssh into your virtual machine with vagrant ssh
  • remove or rename /usr/local/bin/composer
  • log out of the virtual machine
  • run ANSIBLE_TAGS=composer vagrant provision from inside trellis directory to reprovision composer.

Explanation of removal/renaming:
if you do not rename or remove the composer executable, the composer playbook will find an already existing composer installed and skip the reinstallation.
see trellis/vendor/roles/composer/tasks/main.yml line 7:

- name: Check if Composer is installed.
  stat: "path={{ composer_path }}"
  register: composer_bin

- name: Download Composer installer.
  get_url:
    url: https://getcomposer.org/installer
    dest: /tmp/composer-installer.php
    mode: 0755
  when: not composer_bin.stat.exists

- name: Run Composer installer.
  command: >
    {{ php_executable }} composer-installer.php {% if composer_version != '' %} --version={{ composer_version }}{% endif %}
    chdir=/tmp
  when: not composer_bin.stat.exists

- name: Move Composer into globally-accessible location.
  shell: >
    mv /tmp/composer.phar {{ composer_path }}
    creates={{ composer_path }}
  when: not composer_bin.stat.exists

@MWDelaney
Copy link
Author

It looks like this related issue with wp-cli has been acknowledged by Composer and a fix is in progress. Hopefully that fix resolves this issue, too.

@rafhun
Copy link

rafhun commented Aug 8, 2018

Composer has been patched. Updating to v1.7.1 solves the issue for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants