PHPStan error when scanning modules: unable to create directory

Created on 10 September 2023, 10 months ago
Updated 11 June 2024, 15 days ago

Problem/Motivation

When scanning any module (custom or contrib) we run into this error:

PHPStan command failed:
/usr/local/php8.1/bin/php /mnt/www/html/company/vendor/bin/phpstan analyse --memory-limit=1500M --error-format=json --configuration=/mnt/tmp/company/upgrade_status/deprecation_testing.neon /mnt/www/html/company/docroot/modules/custom/company

Command output:
Empty.

Command error:
RuntimeException thrown in /mnt/www/html/company/docroot/core/tests/Drupal/TestTools/PhpUnitCompatibility/PhpUnit8/ClassWriter.php on line 113 while loading bootstrap file /mnt/www/html/company/vendor/mglaman/phpstan-drupal/drupal-autoloader.php: Unable to create directory: /mnt/www/html/company/docroot/core/tests/Drupal/TestTools/PhpUnitCompatibility/PhpUnit8/../../../../../../sites/simpletest

Steps to reproduce

- Go to /admin/reports/upgrade-status
- Scan any module
- Click on local scan result

----

Has anybody experienced this and could anybody give any pointers here? That would be great, thank you!

๐Ÿ› Bug report
Status

Postponed: needs info

Version

4.0

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @simon2d
  • Status changed to Postponed: needs info 10 months ago
  • ๐Ÿ‡ญ๐Ÿ‡บHungary Gรกbor Hojtsy Hungary

    Is your sites directory writable?

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States Shawn DeArmond

    I'm having the same problem. And no, my sites directory is not writable, and I don't want it to be.

    It shouldn't be putting it directly in the sites folder anyway. Shouldn't it go into something like `/sites/MYSITE/files/simpletest`?

  • ๐Ÿ‡ฌ๐Ÿ‡ชGeorgia almador

    I have the same problem after transferring the site from Pantheon to Linode.
    Another custom module, but the same errors.

  • ๐Ÿ‡จ๐Ÿ‡ฆCanada chrisck

    Same issue

  • ๐Ÿ‡ท๐Ÿ‡บRussia sashken2

    I have the same issue too.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States rondog469

    I am also having this issue unfortunately. Running it my local I have a different error than what it gives me on pantheon

    My local shows this:

    PHPStan command failed:
    /Applications/MAMP/bin/php/php8.1.13/bin/php-cgi /Users/ronnieswietek/Sites/xxx/xxxt/vendor/bin/phpstan analyse --memory-limit=1500M --error-format=json --configuration=/Applications/MAMP/tmp/php/upgrade_status/deprecation_testing.neon /Users/ronnieswietek/Sites/xxx/xxx/web/modules/custom/my_custom_module
    
    Command output:
    X-Powered-By: PHP/8.1.13 Cache-Control: must-revalidate, no-cache, private Date: Mon, 02 Oct 2023 18:16:06 GMT Content-Type: application/json X-UA-Compatible: IE=edge Content-language: en X-Content-Type-Options: nosniff X-Frame-Options: SAMEORIGIN Expires: Sun, 19 Nov 1978 05:00:00 GMT X-Generator: Drupal 9 (https://www.drupal.org) {"message":"Scanned my_custom_module"}
    
    Command error:
    Empty.

    When I run it on pantheon, I get the error shown in the OP

  • ๐Ÿ‡ต๐Ÿ‡ญPhilippines monph

    I'm having the same issue on both contrib and custom modules.

    Drupal version: 9.5.11
    PHP 8.1
    Upgrade Status 4.0

    PHPStan command failed:
    /usr/local/php8.1/bin/php /mnt/www/html/mysite/vendor/bin/phpstan analyse --memory-limit=1500M --error-format=json --configuration=/mnt/tmp/mysite/upgrade_status/deprecation_testing.neon /mnt/www/html/mysite/docroot/themes/custom/adb_2022
    
    Command output:
    Empty.
    
    Command error:
    RuntimeException thrown in /mnt/www/html/mysite/docroot/core/tests/Drupal/TestTools/PhpUnitCompatibility/PhpUnit8/ClassWriter.php on line 113 while loading bootstrap file /mnt/www/html/mysite/vendor/mglaman/phpstan-drupal/drupal-autoloader.php: Unable to create directory: /mnt/www/html/mysite/docroot/core/tests/Drupal/TestTools/PhpUnitCompatibility/PhpUnit8/../../../../../../sites/simpletest
    
  • ๐Ÿ‡จ๐Ÿ‡ฆCanada chrisck

    I managed to get around this error by doing two things, though Iโ€™m not sure which has fixed the issue for me.

    • Upgraded mglaman/drupal-check to ^1.4
    • Upgraded weitzman/drupal-test-traits to ^2.1

    In โ€œrequire-devโ€ of composer.json

  • ๐Ÿ‡ฒ๐Ÿ‡บMauritius j.b

    I also have the same problem.

    tried to do as in #10, but no success

  • ๐Ÿ‡จ๐Ÿ‡ฆCanada chinosingson

    I have the same problem. No luck either with #10.

  • Same issue, affecting 2 custom modules and my 2 child themes, on pantheon.

  • Same problem here. Potentially bypassed by just creating a /simpletest directory in place myself. Note that it may be an exception in your .gitignore file that needs to be removed if you are using git update mode instead of SFTP.

  • In Pantheon, changing the mode from git to SFTP fixes this issue.

  • Thanks, @Swathi257. That does the trick.

  • I'm on the same boat. Has anyone been able to resolve this?

    Drupal version: 9.5.11
    PHP 8.1
    Upgrade Status 4.0

  • This is what got rid of the bug for me... I went into
    /app/web/core/tests/Drupal/TestTools/PhpUnitCompatibility

    Noticed there was a PhpUnit9 folder but no PhpUnit8 folder. mkdir PhpUnit8 did the trick! :)

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States samia.wyatt

    Thanks @Swathi257 changing to SFTP mode on Pantheon fixed the error!

  • Fixed it by creating a folder named "simpletest" in /web/sites. You need to have /web/sites/simpletest.

  • ๐Ÿ‡ธ๐Ÿ‡ฐSlovakia voloda86

    Have the same PHPStan failed issue on all modules.

    - make change permission 777 to sites, default, modules, cotrib, on all modules directory,
    - create simpletest folder
    - I had PhpUnit8
    Cant do this: changing the mode from git to SFTP fixes this issue.

    Is this error PHPStan error bad for upgrate from D9.5 to D10.1?

    Have someone some another sollution to fix this?
    Thanks

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia mageshbcet1

    I'm also having the same issue in my custom modules.

    Drupal version: 9.5.11
    PHP 8.1
    Upgrade Status 4.0
    Hosted on Acquia Cloud

    Any solutions how to fix this issue?

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States dhillopexus

    @mender adding a directory named simpletest worked!

Production build 0.69.0 2024