Composer Install Error: ZipArchive::extractTo(): Full extraction path exceed MAXPATHLEN (260) - installation

When I run:
php composer.phar require kartik-v/yii2-widgets "*"
I get the following output (using the -vvv verbose flag):
- Installing kartik-v/bootstrap-fileinput (v4.1.7)
Downloading https://api.github.com/repos/kartik-v/bootstrap-fileinput/zipball/f95a7e5fa0a9db1ead445e438653aa71e9f599f9
Downloading: connection...
Downloading: 0%
Downloading: 5%
...
Downloading: 95%
Downloading: 100%
Downloading: 100%
Writing C:/Users/Michael/AppData/Local/Composer/files/kartik-v/bootstrap-fileinput/f95a7e5fa0a9db1ead445e438653aa71e9f599f9.zip into cache
Extracting archive
[ErrorException]
ZipArchive::extractTo(): Full extraction path exceed MAXPATHLEN (260)
Exception trace:
() at phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/Downloader/ZipDownloader.php:79
Composer\Util\ErrorHandler::handle() at n/a:n/a
ZipArchive->extractTo() at phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/Downloader/ZipDownloader.php:79
Composer\Downloader\ZipDownloader->extract() at phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/Downloader/ArchiveDownloader.php:44
Composer\Downloader\ArchiveDownloader->download() at phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/Downloader/DownloadManager.php:201
Composer\Downloader\DownloadManager->download() at phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/Installer/LibraryInstaller.php:156
Composer\Installer\LibraryInstaller->installCode() at phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/Installer/LibraryInstaller.php:87
Composer\Installer\LibraryInstaller->install() at phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/Installer/InstallationManager.php:152
Composer\Installer\InstallationManager->install() at phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/Installer/InstallationManager.php:139
Composer\Installer\InstallationManager->execute() at phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/Installer.php:578
Composer\Installer->doInstall() at phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/Installer.php:225
Composer\Installer->run() at phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/Command/RequireCommand.php:154
Composer\Command\RequireCommand->execute() at phar://C:/ProgramData/ComposerSetup/bin/composer.phar/vendor/symfony/console/Symfony/Component/Console/Command/Command.php:253
Symfony\Component\Console\Command\Command->run() at phar://C:/ProgramData/ComposerSetup/bin/composer.phar/vendor/symfony/console/Symfony/Component/Console/Application.php:874
Symfony\Component\Console\Application->doRunCommand() at phar://C:/ProgramData/ComposerSetup/bin/composer.phar/vendor/symfony/console/Symfony/Component/Console/Application.php:195
Symfony\Component\Console\Application->doRun() at phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/Console/Application.php:147
Composer\Console\Application->doRun() at phar://C:/ProgramData/ComposerSetup/bin/composer.phar/vendor/symfony/console/Symfony/Component/Console/Application.php:126
Symfony\Component\Console\Application->run() at phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/Console/Application.php:84
Composer\Console\Application->run() at phar://C:/ProgramData/ComposerSetup/bin/composer.phar/bin/composer:43
require() at C:\ProgramData\ComposerSetup\bin\composer.phar:25
require [--dev] [--prefer-source] [--prefer-dist] [--no-progress] [--no-update] [--update-no-dev] [--update-with-dependencies] [--ignore-platform-reqs] [--sort-packages] [packages1] ... [packagesN]
I even tried using the flag "--prefer-source" but I get the same error. Is there a way to tell composer to increase the MAXPATHLEN? Which path exactly is it complaining about?

try using the --prefer-source flag
composer install --prefer-source

Composer is complaining about a path that is too long for PHP on Windows in the download. Windows has a max path length (MAXPATHLEN) of 260 characters so I don't think you can change that.
When I had this problem when installing Symfony, I fixed it by using a short path for the project directory (such as C:\projects\myproject).
While investigating this problem, I found it can also be fixed by using the --prefer-source flag when installing, like this:
php composer.phar install --prefer-source
Note that you need git in your Windows shell path for this to work, as this checks out the source from Github rather than downloading the distribution file. It is also slower.
Note also that you might have to remove the vendor/ folder before installing again using the --prefer-source flag:
rm -rf vendor/

try to shorten your project full path like c://www/yii-project because windows operating system didn't allow directory more than 250 chars

I believe it is complaining that this C:/Users/Michael/AppData/Local/Composer/files/kartik-v/bootstrap-fileinput/f95a7e5fa0a9db1ead445e438653aa71e9f599f9.zip is probably more then 256 chars. From what I know, you cannot have a path longer than that in Windows.
Not sure there is a solution to this. You can probably create a shorted path and have your application installed there.

Try run in command line
mklink /j <Link> <Target>
to create symbolic link and decrease your filepath length to less than 260 chars. More details https://technet.microsoft.com/en-us/library/cc753194(v=ws.11).aspx

Related

What debugging techniques are available for Laravel 6?

I'm new to Laravel. I'm using Laravel 6 in VSCode and my first real app is not performing as desired. If I were writing Java or PHP, I would use a debugger to step-trace my way through the code to see what is happening where. What is the equivalent of that for VSCode and Laravel 6?
I've searched extensions and can't find any Laravel Debug extensions, at least not with those words in its name. I've searched YouTube for videos on debugging Laravel and came across one that talked about Laravel Debugbar, here. I installed it - or at least tried to - but something is not right; the Firefox developer tool says:
ReferenceError: PhpDebugBar is not defined
I don't see any channel for tech support at the Github page for this tool so I'm not sure what I've done wrong. How would I either fix the debugbar install or uninstall it altogether?
From what I can see in the video, this tool doesn't let me step-trace my way through the code anyway: it's more of a monitor that shows me information about the status of my code at various points. That, of course, could still be useful but it's not really what I want. Is there a true step-trace debugger for Laravel?
My laptop is a Windows 10 machine.
========================================================================
EDIT
I'm trying to follow the advice I was given. I tried to self-update composer but it seemed to already be up to date. I tried to remove and reinstall debugbar but that doesn't seem to have worked very well. Here is the output from that attempt which was done in a VSCode terminal:
PS C:\Laravel\Somers01> composer remove barryvdh/laravel-debugbar --dev
barryvdh/laravel-debugbar could not be found in require but it is present in require-dev
Do you want to remove it from require-dev [yes]? y
–-dev is not required in your composer.json and has not been removed
Dependency "laravel/framework" is also a root requirement, but is not explicitly whitelisted. Ignoring.
Dependency "laravel/framework" is also a root requirement, but is not explicitly whitelisted. Ignoring.
Dependency "laravel/framework" is also a root requirement, but is not explicitly whitelisted. Ignoring.
Package "–-dev" listed for update is not installed. Ignoring.
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 0 installs, 0 updates, 2 removals
- Removing maximebf/debugbar (v1.16.1)
- Removing barryvdh/laravel-debugbar (v3.2.9)
Writing lock file
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> #php artisan package:discover --ansi
In ProviderRepository.php line 208:
Class 'Barryvdh\Debugbar\ServiceProvider' not found
Script #php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1
PS C:\Laravel\Somers01> composer require barryvdh/laravel-debugbar --dev
[InvalidArgumentException]
Could not find package barryvdh/laravel-debugbar in a version matching –-dev
require [--dev] [--prefer-source] [--prefer-dist] [--no-progress] [--no-suggest] [--no-update] [--no-scripts] [--update-no-dev] [--update-with-dependencies] [--update-with-all-dependencies] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [--sort-packages] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--] [<packages>]...
Is debugbar fully removed now? If not, how do I remove the rest of it so that I can try the install again? I'm very new to Laravel, Composer, Artisan and the rest so I have no experience to draw on.
That error suggests a dependency is missing. Did you install it using composer, following the guide in the documentation? But about your quesiton: I THINK Xdebug might have something like that.
It's not a Laravel specific library but a php extension with some integration with IDEs.

Composer is not working for installing yii2 extensions

I want to install some yii2 extension and want to use them in yii2 framework. While using Composer I am getting Error.
Also I've tried manually adding extension and adding it's content in composer.json still nothing works.
Some some of command include composer.phar file name and I don't have this file in my main project repository. I tried manually adding composer.phar using composer command but still it didn't run.
When I run this command I got error.
composer require dmstr/yii2-adminlte-asset "^2.1"
I got this error
Cannot create cache directory /home/kaushalendra/.composer/cache /repo/https---asset-packagist.org/, or directory is not writable. Proceeding without cache
Cannot create cache directory /home/kaushalendra/.composer/cache/repo/https---repo.packagist.org/, or directory is not writable. Proceeding without cache
Cannot create cache directory /home/kaushalendra/.composer/cache/files/, or directory is not writable. Proceeding without cache
./composer.json has been updated
Cannot create cache directory /home/kaushalendra/.composer/cache /repo/https---asset-packagist.org/, or directory is not writable. Proceeding without cache
Cannot create cache directory /home/kaushalendra/.composer/cache/repo/https---repo.packagist.org/, or directory is not writable. Proceeding without cache
Cannot create cache directory /home/kaushalendra/.composer/cache/files/, or directory is not writable. Proceeding without cache
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages .
Problem 1- codeception/base 2.5.6 requires ext-curl * -> the requested PHP extension curl is missing from your system.
- codeception/base 2.5.6 requires ext-curl * -> the requested PHP extension curl is missing from your system.
- codeception/base 2.5.6 requires ext-curl * -> the requested PHP extension curl is missing from your system.
- Installation request for codeception/base (locked at 2.5.6, required as ^2.4.0) -> satisfiable by codeception/base[2.5.6].
To enable extensions, verify that they are enabled in your .ini files:
- /etc/php/7.3/cli/php.ini
- /etc/php/7.3/cli/conf.d/10-opcache.ini
- /etc/php/7.3/cli/conf.d/10-pdo.ini
- /etc/php/7.3/cli/conf.d/20-calendar.ini
- /etc/php/7.3/cli/conf.d/20-ctype.ini
- /etc/php/7.3/cli/conf.d/20-exif.ini
- /etc/php/7.3/cli/conf.d/20-fileinfo.ini
- /etc/php/7.3/cli/conf.d/20-ftp.ini
- /etc/php/7.3/cli/conf.d/20-gettext.ini
- /etc/php/7.3/cli/conf.d/20-iconv.ini
- /etc/php/7.3/cli/conf.d/20-json.ini
- /etc/php/7.3/cli/conf.d/20-phar.ini
- /etc/php/7.3/cli/conf.d/20-posix.ini
- /etc/php/7.3/cli/conf.d/20-readline.ini
- /etc/php/7.3/cli/conf.d/20-shmop.ini
- /etc/php/7.3/cli/conf.d/20-sockets.ini
- /etc/php/7.3/cli/conf.d/20-sysvmsg.ini
- /etc/php/7.3/cli/conf.d/20-sysvsem.ini
- /etc/php/7.3/cli/conf.d/20-sysvshm.ini
- /etc/php/7.3/cli/conf.d/20-tokenizer.ini
You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.
Installation failed, reverting ./composer.json to its original content.
I've seen somewhere that using this command it will work but getting this error.
composer global require "fxp/composer-asset-plugin:1.0.0-beta4"
and got this error
[ErrorException]
file_put_contents(./composer.json): failed to open stream: Permission denied
require [--dev] [--prefer-source] [--prefer-dist] [--no-progress] [--no-suggest] [--no-update] [--no-scripts] [--update-no-dev] [--update-with-dependencies] [--update-with-all-dependencies] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [--sort-packages] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--] [<packages>]...`
Use the following command to remove the permission warning and to make sure your user has permissions on the global composer folder.
sudo chown -R kaushalendra:<YOUR_GROUP> /home/kaushalendra/.composer
Note: to lookup which group your user belongs to
groups kaushalendra
For me, it shows the following groups
omeraslam : omeraslam sudo www-data docker
after : all are the groups my user is assigned i can use omeraslam as username and omeraslam as group so for me the command will be sudo chown -R omeraslam:omeraslam /home/kaushalendra/.composer
Then run the following command on terminal
sudo apt-get install php-curl
Then restart apache
sudo service apache2 restart
Apparently, you don't have permissions to write to ./composer.json
You have 2 ways to fix this. Either give write permissions to the user or the group to that user by running chmod XXX composer.json or you can change the owner of the file to the user which composer is using(He probably has those permissions already).
The XXX above should be numbers. You can read here what those numbers are supposed to be, but you probably want something like a 660 or a 770.
Some people might use 777 to fix this issue, but this should !!NOT!! be used, as you do not want others to access files, unless they really need to.
You can change the owner of the file by using chown. It should look something like chown user:group composer.json.
Please, let me know if there is something that you do not understand and I will clarify, as I know it is hard to understand permissions as a new linux user.
Please note, that this is only for the last error, but handling the other errors is similar. You just need to give the user, which composer is using the right permissions for the right files and/or folders. You can use -R flag for handling directories.

How to get my composer working with Drupal 8

After a lot of effort I finally managed to get my composer (with drush) working with Drupal 8.5.3
However I would like to update Drupal to latest version with composer.
Updating composer with sudo doesnt gives me errors but doesnt update my Drupal.
I used this command from my project dir;
sudo composer update drush/drush --with-dependencies
I read that it's bad practice to use sudo for composer and because it doesnt update my Drupal
I try using composer update without sudo.
First I got some warnings that cache could not be used. Because they're only warnings I ignored them.
After some time it sees 11 updates and right after that I got a big red errormessage;
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 1 install, 11 updates, 0 removals
[RuntimeException]
/path-to-my-site/drupal-composer-build/vendor/symfony/polyfill-ctype does not exist and could not be created.
I then tried the sollution in RuntimeException] vendor does not exist and could not be created
So I did;
Add your user in the www-data group (this action require you to logout and login again)
sudo usermod -a -G www-data `whoami`
Give these permissions to your project
sudo chown -R www-data:www-data /var/www/<project>
sudo chmod -R 774 /var/www/<project>
I skipped the 2nd part that gives rights to /var/www because I'm on a shared server without root userrights.
I got the following message;
No composer.json in current directory, do you want to use the one at /path-to-site? [Y,n]? y
after that got some cache warnings again and the following question;
Cannot create cache directory /home/maikel/.composer/cache/repo/https---repo.packagist.org/, or directory is not writable. Proceeding without cache
Cannot create cache directory /home/maikel/.composer/cache/files/, or directory is not writable. Proceeding without cache
Cannot create cache directory /home/maikel/.composer/cache/repo/https---repo.packagist.org/, or directory is not writable. Proceeding without cache
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 0 installs, 6 updates, 0 removals
- Updating symfony/event-dispatcher (v3.4.14 => v3.4.15):
Update failed (Could not delete /path-to-site/vendor/symfony/event-dispatcher/GenericEvent.php: )
Would you like to try reinstalling the package instead [yes]? y
I anwered yes again, then;
- Removing symfony/event-dispatcher (v3.4.14)
[RuntimeException]
Could not delete /path-to-site/vendor/symfony/event-dispatcher/GenericEvent.php:
update [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev]
[--lock] [--no-custom-installers] [--no-autoloader] [--no-scripts] [--no-
progress] [--no-suggest] [--with-dependencies] [--with-all-dependencies]
[-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-
authoritative] [--apcu-autoloader] [--ignore-platform-reqs] [--prefer-
stable] [--prefer-lowest] [-i|--interactive] [--root-reqs] [--]
[<packages>]...
My two questions are;
Do I really really need composer (with drush)? I rather drop composer
or Drupal alltogether
If I really need it to properly manage updates in the future, how can
I configure composer to update, do I need a global configuration?
Thanks a lot in advance
If I can update this question with more information/config files please let me know, I'll gladly do, I honestly don't know where to begin.

Installing Address module on Drupal 8

I have been struggling with this now for 2 days and cannot get past trying to enable the address module as I just get the error message "Address requires the commerceguys/addressing library."
Documentation seems a bit unclear how to enable this, and even the documentation page returns a 404 error. I have followed the README.me file in the address module but still just getting the same error.
My Steps:
1.) Download Address module, unzip and add to /modules
2.) Enable in the D8 extend page, message returned "Address requires the commerceguys/addressing library"
I then download and unzip the library from the git page https://github.com/commerceguys/addressing, this unzips a directory called addressing-master
Now I'm not sure where I should put this folder. do I make a '/libraries' folder and put it in there? Do I put it in '/vendor'?
I tried both the above and re attempted to enable the address module but still got the same message returned "Address requires the commerceguys/addressing library."
So I have installed composer manager, run init.php from the command line, all good, went to enable the address module and still got that same message.
I then try cd into the address module directory in terminal then run $ composer install, still got that same message.
Now I try adding "commerceguys/addressing": "dev-master" to the require part of the composer.json file that's in the root directory then running composer drupal-update from the root of my project and I get this:
Drupal\composer_manager\Composer\Command::update
Loading composer repositories with package information
Updating dependencies (including require-dev)
- Updating jcalderonzumba/mink-phantomjs-driver dev-master (10d7c48 => 5bf53fa)
[RuntimeException]
The .git directory is missing from /Users/barrypoore/mampsites/d8/vendor/jcalderonzumba/mink-phantomjs-driver, see https://getcomposer.org/commit-deps for m
ore information
update [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--lock] [--no-plugins] [--no-custom-installers] [--no-autoloader] [--no-scripts] [--no-progress] [--with-dependencies] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [--] [
]...
I have googled as much as I can to try to resolve this but 2 days now and I'm still stuck with no address module enabled, can somebody please advise?
Thanks you in advance.
At least part of your problem is a Drupal core issue with the jcalderonzumba/mink-phantomjs-driver package that they've fixed in 8.0.x-dev:
https://www.drupal.org/node/2629772
I couldn't get their patch to apply cleanly but when I manually made the changes, I was able to run drupal-update and install the Address module.

Composer neither installing nor updating RecursiveDirectoryIterator Cannot find path specified

I have been trying to update / install with composer on my windows7 64 bit machine. But lately I am getting this errors:
$ php composer.phar install
Loading composer repositories with package information
Installing dependencies (including require-dev)
- Installing zendframework/zendxml (dev-master 559b34f)
Cloning 559b34f426d33a11c3db118e00ce14bb8dc64e5f
Failed to download zendframework/zendxml from source: RecursiveDirectoryIterator
::__construct(C:\wamp\www\projects\vendor\zendframework\zendxml,C:\wamp\www\projects\vendor\zendframework\zendxml): The system cannot find the path specified. (
code: 3)
Now trying to download from dist
- Installing zendframework/zendxml (dev-master 559b34f)
Downloading: 100%
[UnexpectedValueException]
RecursiveDirectoryIterator::__construct(C:\wamp\www\projects\vendor/zendfra
mework/zendxml,C:\wamp\www\projects\vendor/zendframework/zendxml): The syst
em cannot find the path specified. (code: 3)
I have tried to remove the vendor directory as well as empty the composer cache but this didn't solve the issue.
Any suggestions?
My problem was that I moved a directory which enabled colors in cmd.exe. Now the directory was not linked properly anymore.
Check out https://getcomposer.org/doc/articles/troubleshooting.md#-the-system-cannot-find-the-path-specified-windows- and also check for invalid paths.
Maybe a write permisions error in the vendor's folder.
Stop Apache and delete the folder /vendor/zendframework and run again composer install.

Resources