acquia / cli

Acquia CLI
GNU General Public License v2.0
44 stars 47 forks source link

CLI-1332: acli app:new:from:drupal7 crashes on cPanel environment with "stream_get_contents(): Argument #1 ($stream) must be of type resource, bool given" on #1735

Open obriat opened 5 months ago

obriat commented 5 months ago

Describe the bug I try to migrate a Drupal 7 site with the Acquia Migrate: Accelerate app:new:from:drupal7..., it crashes with the following error message:

TypeError: stream_get_contents(): Argument #1 ($stream) must be of type resource, bool given in stream_get_contents() (line 22 of phar:///home2/ptgptbfr/bin/acli/vendor/composer/../../src/Command/App/From/JsonResourceParserTrait.php).

To Reproduce Follow the Acquia tutorials : https://dev.acquia.com/blog/acquia-migrate-accelerate-now-open-source#steps

Expected behavior The command should not crash or at least give more info about the problem.

Screenshots

$ acli app:new:from:drupal7 --drupal7-directory=/legacy/www --directory=/new/www -vvv

Box Requirements Checker
========================

> Using PHP 8.1.28
> PHP is using the following php.ini file:
  /opt/cpanel/ea-php81/root/etc/php.ini

> Checking Box requirements:
  ✔ The application requires a version matching "^8.1".
  ✔ The application requires the extension "json".
  ✔ The package "guzzlehttp/guzzle" requires the extension "json".
  ✔ The package "league/csv" requires the extension "json".
  ✔ The package "m4tthumphrey/php-gitlab-api" requires the extension "json".
  ✔ The package "ramsey/uuid" requires the extension "json".
  ✔ The package "zumba/amplitude-php" requires the extension "json".
  ✔ The package "composer/ca-bundle" requires the extension "openssl".
  ✔ The package "composer/ca-bundle" requires the extension "pcre".
  ✔ The package "vlucas/phpdotenv" requires the extension "pcre".
  ✔ The package "league/csv" requires the extension "filter".
  ✔ The package "m4tthumphrey/php-gitlab-api" requires the extension "xml".
  ✔ The package "marc-mabe/php-enum" requires the extension "reflection".
  ✔ The package "zumba/amplitude-php" requires the extension "curl".
  ✔ The package "laminas/laminas-servicemanager" conflicts with the extension "psr".
  ✔ The package "symfony/dependency-injection" conflicts with the extension "psr".
  ✔ The package "symfony/service-contracts" conflicts with the extension "psr".

 [OK] Your system is ready to run the application.

Acquia CLI version: 2.25.0
🤖 Scanning Drupal 7 site.
👍 Found Drupal 7 site (7.98 to be precise) at sites/default, with 77 modules enabled!
TypeError: stream_get_contents(): Argument #1 ($stream) must be of type resource, bool given in stream_get_contents() (line 22 of phar:///home2/ptgptbfr/bin/acli/vendor/composer/../../src/Command/App/From/JsonResourceParserTrait.php).

Desktop (please complete the following information):

wimleers commented 5 months ago
  1. Your command is using the default recommendations.
  2. The crash is happening at https://github.com/acquia/cli/blob/6ced4f931affdd8ac418bd03e25842651f99d5ff/src/Command/App/From/JsonResourceParserTrait.php#L22

Conclusion

It must be failing to retrieve to fetch the default recommendations URL.

Questions:

  1. What do you see if you run curl -vvv -O https://git.drupalcode.org/project/acquia_migrate/-/raw/recommendations/recommendations.json ?
  2. What is your php.ini setting for allow_url_fopen? (I suspect this is related, especially considering you're on a CPanel-managed server.)
obriat commented 5 months ago

Curl seems fine (I get the json content).

Your right, the cpanel php config seems a bit weird, php is not always returning the same config or version depending on the folder where it is executed. The allow_url_fopen is "on" for the source folder (--drupal7-directory) but "off" for the target one ( --directory).

Although I set the correct allow_url_fopen value for both folders in the cpanel admin ui.

I finally found a way to fixe it by setting PHPRC: export PHPRC=/new/www/php.ini

I guess it's a local problem, although a more details message would be great.

wimleers commented 5 months ago

although a more details message would be great.

That's fair! 😊