PHPStan binary was not found in the default vendor directory

Created on 30 November 2021, almost 3 years ago
Updated 8 July 2024, 4 months ago

Hi team,

I have added the upgrade status module via composer to one of my websites.

Getting the following error on enabling the module -
"The PHPStan binary was not found in the default vendor directory based on the location of /var/www/html/website-path/composer.json. You may need to configure a vendor-dir in composer.json. See https://getcomposer.org/doc/06-config.md#vendor-dir. Attempted: /var/www/html/website-paths/vendor/bin/phpstan. Scanning is not possible until this is resolved."

The composer.json file have the following code.

 "require-dev": {
        "phpstan/phpstan": "^1.2",
        "phpunit/phpunit": "^9.5"
    }
}

Thanks
Divya

๐Ÿ’ฌ Support request
Status

Active

Version

3.12

Component

Code

Created by

๐Ÿ‡ฎ๐Ÿ‡ณIndia divya.lakshman

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

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

    In my case this issue was resolved by removing my vendor directory and `composer install`-ing again.

  • Thanks @COBadger & @cslevy in both cases your answers work, is there something we can do (maybe just linking to this issue) that can help reduce any time for future people searching for a fix?

  • ๐Ÿ‡ฌ๐Ÿ‡ทGreece tarasiadis

    hi
    i confirm that #6 also solved my case

    thanks to @cslevy

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia varun pradeep

    Hi

    @ cslevy In my case there was no composer.json file in web folder, so i have tried @COBadger "composer install" command. It didn't resolved my issue.
    i have researched more and found out 2 commands which resolved my issue
    composer require --dev palantirnet/drupal-rector --with-all-dependencies
    composer require drupal/upgrade_status --update-with-all-dependencies

    Thanks

  • ๐Ÿ‡ช๐Ÿ‡ธSpain gmoraleb

    Hello,

    In my case, #6 fixed my issue.
    Thanls

  • ๐Ÿ‡ช๐Ÿ‡ธSpain gmoraleb

    Hello,

    In my case, #6 fixed my issue.
    Thanks.

  • ๐Ÿ‡ฏ๐Ÿ‡ฒJamaica axle_foley00

    I had the same issue and am confirming that I had a stray composer.json file in the web folder. Once that was removed the error disappeared.

  • Status changed to Active 4 months ago
  • ๐Ÿ‡ญ๐Ÿ‡บHungary Gรกbor Hojtsy Hungary

    How do people end up with an empty composer.json at the wrong place? I believe this is the error message you all are hitting:

        throw new \Exception('The PHPStan binary was not found in the default vendor directory based on the location of ' . $composer_json_path . '. You may need to configure a vendor-dir in composer.json. See https://getcomposer.org/doc/06-config.md#vendor-dir. Attempted: ' . $binPath . '/phpstan.');
    

    We can probably refine this text to say something like this?

    The PHPStan binary was not found in the default vendor directory based on the location of ' . $composer_json_path . '. Is this the right composer.json file? If it is, you may need to configure a vendor-dir in composer.json....

    I am not clear if it could be a valid case that we found a composer.json file that should not be deleted but is still not the right composer.json file. Could that happen? (I would avoid suggesting you remove useful composer.json files, if that were the case).

  • ๐Ÿ‡ฏ๐Ÿ‡ฒJamaica axle_foley00

    @Gรกbor Hojtsy

    So in my case I had a team member who accidentally tried to run the composer command in the web directory instead of the directory above and when it complained about a composer.json file being missing then they ended up adding a new composer.json file there. So once I realized and cleared that up with them we removed the incorrect one.

    I do believe the changes to the message you suggested could help to point future users in the right direction though. I also agree we shouldn't suggest removing other composer.json files that might be legitimately be added by users.

Production build 0.71.5 2024