Reputation: 503
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?
Upvotes: 45
Views: 75568
Reputation: 345
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.
Upvotes: 7
Reputation: 2121
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"
}
Upvotes: -1
Reputation: 186
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.
Upvotes: 0
Reputation: 89
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".
Upvotes: -1
Reputation: 387
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.
Upvotes: -1
Reputation: 1455
It generally happens when composer is unable to autoload classmap. Check whether the location to the file or folder is correct.
Upvotes: 0
Reputation: 317
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
Upvotes: 0
Reputation: 149
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
Upvotes: 0
Reputation: 1390
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.
;C:\bin
to your PATH environment variable (related help)C:\bin\phpunit.phar
Windows+R
» type cmd
» ENTER)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
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.
Upvotes: 0
Reputation: 6343
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
Upvotes: 50
Reputation: 921
My problem was that I've had App
instead of app
in my directory path. Maybe this will help someone.
Upvotes: 1
Reputation: 1128
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!
Upvotes: 3
Reputation: 87799
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.
Upvotes: 18