42

I'm trying to install composer in terminal by entering this command:

php composer.phar install

it starts to install required packages but I'm getting this error type:

[RuntimeException]
Could not scan for classes inside "app/commands" which does not appear to be a file nor a folder

How can I overcome this issue?

13 Answers 13

48

Usually this happens when you have some corrupted files or any composer update has crashed or interrupted.

To solve, just delete the vendor folders and run composer install

7
  • 5
    This does not always work. I am getting /vendor/seb astian/diff/src/" which does not appear to be a file nor a folder error and delete vendor and re-running composer install does not work. The original solution of manually adding the folder does. The problem is that my CI validator dies in github because of this problem. Very annoying.
    – RyanNerd
    May 8, 2017 at 21:05
  • Have you try to delete the vendor folder?
    – albanx
    May 9, 2017 at 12:57
  • 2
    NOTE: Emptying the folder is not enough, gotta delete the folder itself. Happened to me. Feb 12, 2018 at 23:45
  • 6
    I use both method, composer clearcache && rm -rf vendor && composer install everything works again
    – kl3sk
    Dec 12, 2019 at 11:22
  • 2
    Thanks @kl3sk but even with all that, it does not seem to be working for me Mar 31, 2020 at 18:51
18

When you install Laravel it creates a

app/commands

folder. Looks like it's not there. Just create it or remove from composer.json:

"classmap": [
    "app/commands",  /// <--- this line
],

And run

composer update
artisan dump-autoload

The last one is similar to composer dump-autoload, but it does some Laravel stuff too.

If you don't have any commands you don't really need it. If you plan to create artisan commands, create that folder and it should work.

4
  • Laravel has a .gitkeep file there. But as an empty folder should work too. Dec 15, 2013 at 15:04
  • Package "artisan" listed for update is not installed. Ignoring. Package "dump-autoload" listed for update is not installed. Ignoring. Dec 15, 2013 at 15:20
  • This is actually wrong. Although correct in other situations. In the op case he has the classmap defined, he is missing to what it points. 'app/commands' is either needed- meaning the op is missing files, or has been removed and is still in the installs composer.lock file and should be removed.
    – KazaJhodo
    Feb 5, 2021 at 22:28
  • THANKS FOR YOUR VALUABLUE ANSWER, YOU'VE MADE MY DAY Oct 20 at 19:52
4

You should be able to solve this issue by simply running:

rm -rf vendor/autoload.php vendor/autoload_runtime.php vendor/composer && composer install

This cleans up the corrupted files without having to remove the entire vendor folder or cleaning up the global cache.

As others have mentioned, this usually happens if you interrupt a running Composer (e.g., Ctrl+C during composer update). But it does not corrupt all of the files, only the composer internals – which the command above then removes.

This is an older question with valid answers, but somebody might find this helpful.

3

I had the same problem. In my case, I noticed that there was no app/commands folder in my laravel install. I created the commands folder and composer dump-autoload was working again!

2
  • 1
    If you check out your project from a version control system often the apps/commands folder gets lost. You have to manually recreate it on your local dev machine. Feb 26, 2015 at 17:32
  • This will resolve the error, but perhaps not fix the actual problem. In the case of the op I think this will fix it. This error can also happen if an autoloader is in your composer.lock file, and a newer version of the module no longer uses that autoloader. In which case, reference my answer.
    – KazaJhodo
    Feb 5, 2021 at 22:24
1

My problem was that I've had App instead of app in my directory path. Maybe this will help someone.

2
  • yepp, its case-sensitive
    – zedling
    Mar 16, 2017 at 19:25
  • Useful for me. The composer.json file was created by a window user, and the composer install command failed in my linux installation.
    – Tuxman
    Jan 30, 2018 at 13:04
0

I am Xampp user on Windows 10. I try all of the above methods but none of them work for me. I fixed my problem with this method, and Hopefully, it will help others.

  1. Create a directory C:\bin
  2. Append ;C:\bin to your PATH environment variable (related help)
  3. Download https://phar.phpunit.de/phpunit-5.7.phar and save the file as C:\bin\phpunit.phar
  4. Open a command line (e.g., press Windows+R » type cmd » ENTER)
  5. Create a wrapping batch script (results in C:\bin\phpunit.cmd):

    C:\Users\username> cd C:\bin
    C:\bin> echo @php "%~dp0phpunit.phar" %* > phpunit.cmd
    C:\bin> exit
    
  6. Open a new command line and confirm that you can execute PHPUnit from any path:

    C:\Users\username> phpunit --version
    PHPUnit x.y.z by Sebastian Bergmann and contributors.
    

This method solves my problem. Hope It will save your day too.

0

I had the same issue. For me it happened after I deleted a class dir and forgot to update composer.json.

The fix was simply updating the classmap array in composer.json

1
  • This is also correct, although it doesn't really address how to fix with any sort of detail. If you know what he means, it would get you there.
    – KazaJhodo
    Feb 5, 2021 at 22:20
0

I think it happens because composer cache error. Try to clear its cache:

composer clearcache

then run the installer again

composer create-project --prefer-dist laravel/laravel blog
0

It generally happens when composer is unable to autoload classmap. Check whether the location to the file or folder is correct.

1
  • This is completely correct, although my response has further definition of how to fix it.
    – KazaJhodo
    Feb 5, 2021 at 22:18
0

This happens due to your composer.lock file.

For instance in my case I was getting: Could not scan for classes inside ".../vendor/drupal/core-composer-scaffold/PEAR/" which does not appear to be a file nor a folder

That directory indeed did not exist. However, search for 'PEAR' inside of your composer.lock... 'app/commands' in this case- and you will find the modules definition:

{
            "name": "drupal/core-composer-scaffold",
            "version": "8.9.11",
            "source": {
                "type": "git",
                "url": "https://github.com/drupal/core-composer-scaffold.git",
                "reference": "c902d07cb49ef73777e2b33a39e54c2861a8c81d"
            },
            "dist": {
                "type": "zip",
                "url": "https://api.github.com/repos/drupal/core-composer-scaffold/zipball/c902d07cb49ef73777e2b33a39e54c2861a8c81d",
                "reference": "c902d07cb49ef73777e2b33a39e54c2861a8c81d",
                "shasum": ""
            },
            "require": {
                "php": ">=4.4.0"
            },
            "require-dev": {
                "phpunit/phpunit": "*"
            },
            "type": "class",
            "extra": {
                "branch-alias": {
                    "dev-master": "1.0.x-dev"
                }
            },
            "autoload": {
                "classmap": [
                    "PEAR/"
                ]
            },
            "notification-url": "https://packagist.org/downloads/",
            "include-path": [
                "."
            ],
            "license": [
                "BSD-2-Clause"
            ],
            "authors": [
                {
                    "name": "Helgi Thormar",
                    "email": "[email protected]"
                },
                {
                    "name": "Greg Beaver",
                    "email": "[email protected]"
                }
            ],
            "description": "The PEAR Exception base class.",
            "homepage": "https://github.com/pear/PEAR_Exception",
            "keywords": [
                "exception"
            ],
            "time": "2019-12-10T10:24:42+00:00"
        },

Our important piece is:

"autoload": {
                "classmap": [
                    "PEAR/"
                ]
            },

Composer is attempting to autoload from that directory, which is why you get a composer crash- that directory doesn't exist. Likely the same thing in your case of 'app/commands'.

Remove the entire package from your composer.lock- which for clarity is the longer code posting above. Then rerun your 'composer require' for that package. Example: composer require drupal/core-composer-scaffold.

In my case I needed a specific version, the default would give me version 9, I needed 8. My command was composer require drupal/core-composer-scaffold:^8.

Once this is done your composer install will run without a hitch.

-1

Here is another debugging idea:

I accidentally added the vendor/ folder to my repository which then got deployed. After removing it from the repository, the error message composer RuntimeException Could not scan for classes inside polyfill-php80/Resources/stubs which does not appear to be a file nor a folder disappeared.

-1

in most of cases it is happen because of copy or cloning so try to remove or rename VENDOR folder from the magento installation and rerun "composer install".

-1

In my case, I was installing wordpress plugins by composer, especially yoast (wordpress-seo) and woocommerce from packagist.org. I changed the sources to wpackagist and it started to work ok:

  "require": {
    "wpackagist-plugin/wordpress-seo": "dev-trunk",
    "wpackagist-plugin/woocommerce": "dev-trunk"
  }

Not the answer you're looking for? Browse other questions tagged or ask your own question.