After composer update Laravel project, getting VirtualAlloc() failed: [0x00000008] Not enough memory error [duplicate] - laravel

This question already has answers here:
Composer require runs out of memory. PHP Fatal error: Allowed memory size of 1610612736 bytes exhausted
(39 answers)
Closed 2 years ago.
I am working on a laravel project and after taking clone of files from Github.
When Running Composer update command bellow error is coming
VirtualAlloc() failed: [0x00000008] Not enough memory resources are available to process this command.
VirtualAlloc() failed: [0x00000008] Not enough memory resources are available to process this command.
PHP Fatal error: Out of memory (allocated 868220928) (tried to allocate 58720256 bytes) in phar://C:/composer/composer.phar/src/Composer/DependencyResolver/RuleSet.php on line 90
Fatal error: Out of memory (allocated 868220928) (tried to allocate 58720256 bytes) in phar://C:/composer/composer.phar/src/Composer/DependencyResolver/RuleSet.php on line 90

you should set your memory_limit = -1 in your php config php.ini, but do not forget in production to let the default memory_limit and only do a composer install --no-dev.
This way, composer will do the install of your vendors based on composer.lock file.
You should also do the composer install --no-dev on your local machine to make sure that you have no developpement dependencies not compatible with the production environnement.

Related

Why do I have to "composer install" whenever I switch to a branch? Does it kill my memory?

Context: I am roughly new to Laravel and Github. I am working on a project with 3 other people, and we have created all our individual branches. But every time, I switch to their branch (which I am to successfully) but whenever I am trying to run the server on port 8000 I get the following error:
C:\Users\Einstein\Documents\Program\Project>php artisan serve
PHP Warning: require(C:\Users\Einstein\Documents\Program\laravel\Project/vendor/autoload.php): failed to open stream: No such file or directory in C:\Users\Einstein\Documents\Program\laravel\Project\artisan on line 18
Warning: require(C:\Users\Einstein\Documents\Program\laravel\Project/vendor/autoload.php): failed to open stream: No such file or directory in C:\Users\Einstein\Documents\Program\laravel\Project\artisan on line 18
PHP Fatal error: require(): Failed opening required 'C:\Users\Einstein\Documents\Program\laravel\Project/vendor/autoload.php' (include_path='C:\xampp\php\PEAR') in C:\Users\Einstein\Documents\Program\laravel\Project\artisan on line 18
Fatal error: require(): Failed opening required 'C:\Users\Einstein\Documents\Program\laravel\Project/vendor/autoload.php' (include_path='C:\xampp\php\PEAR') in C:\Users...8```
However, I am to run the project whenever I perform composer install. Why is that so? It seems like I have to rerun the packages whenever I am switches to branches, does it kill my computer memory? If I have to reinstall packages (this is my assumption whenever I perform composer install) will kill my computer memory.
Thanks.
It is most likely because you are pulling in cached files calling the other peoples local paths and not yours. When you run composer install it pulls all the dependencies listed in the composer.json file to the /vendor folder, then rebuilds the config cache.
You can try and just rebuild the cache instead of re-installing all the dependencies with:
composer dump-autoload and php artisan clear:cache

Fatal error: Allowed memory size of 1610612736 bytes exhausted (tried to allocate 4096 bytes) in phar [duplicate]

This question already has answers here:
Composer require runs out of memory. PHP Fatal error: Allowed memory size of 1610612736 bytes exhausted
(39 answers)
Closed 2 years ago.
composer require livewire/livewire
Using version ^2.3 for livewire/livewire
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
PHP Fatal error: Allowed memory size of 1610612736 bytes exhausted (tried to allocate 4096 bytes) in phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/DependencyResolver/RuleWatchGraph.php on line 52
Fatal error: Allowed memory size of 1610612736 bytes exhausted (tried to allocate 4096 bytes) in phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/DependencyResolver/RuleWatchGraph.php on line 52
Check https://getcomposer.org/doc/articles/troubleshooting.md#memory-limit-errors for more info on how to handle out of memory errors.
C:\Users\vits\vitsagro>composer require livewire/livewire
Execute the following command for the package
COMPOSER_MEMORY_LIMIT=-1 composer require livewire/livewire
or
Try increasing the limit in your php.ini file
Use -1 for unlimited
memory_limit = -1
Don't forget to restrat your Apache server after this

Cannot install laravel/socialite package

I'm trying to install Socialite Package getting this error :
Fatal error: Allowed memory size of 1610612736 bytes exhausted
(tried to allocate 4096 bytes) in
phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/DependencyResolver/RuleSetGenerator.php
on line 126
I have change changed memory_limit in my php.ini file but facing same issue, any help will be highly appreciated.

Memory exhausted and PHP Version mismatch errors. Not able to install image intervention laravel 5.5 package

I want to change color of my image. So I'm trying to use image/intervention of laravel.
Followed their documentation:
http://image.intervention.io/getting_started/installation
https://packagist.org/packages/intervention/image
When i tried the following, i got an memory exhausted error:
1. composer require intervention/image
Error:
PHP Fatal error: Allowed memory size of 1610612736 bytes exhausted (tried to allocate 4096 bytes) in phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/DependencyResolver/Solver.php on line 223
Fatal error: Allowed memory size of 1610612736 bytes exhausted (tried to allocate 4096 bytes) in phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/DependencyResolver/Solver.php on line 223
Check https://getcomposer.org/doc/articles/troubleshooting.md#memory-limit-errors for more info on how to handle out of memory errors.
E:\xampp\htdocs\Myproject>php -r "echo ini_get('memory_limit').PHP_EOL;"
512M
So, i followed the below link and increased to memory_limit=-1 from memory_limit=512M
https://getcomposer.org/doc/articles/troubleshooting.md#memory-limit-errors
Now, again tried this command composer require intervention/image. Now i got a different error:
Error:
Your requirements could not be resolved to an installable set of packages.
Problem 1
- This package requires php ~7.2.0 but your PHP version (7.3.11) does not satisfy that requirement.
Problem 2
- mpociot/vat-calculator dev-master requires ext-soap * -> the requested PHP extension soap is missing from your system.
- mpociot/vat-calculator dev-master requires ext-soap * -> the requested PHP extension soap is missing from your system.
- mpociot/vat-calculator dev-master requires ext-soap * -> the requested PHP extension soap is missing from your system.
- Installation request for mpociot/vat-calculator dev-master -> satisfiable by mpociot/vat-calculator[dev-master].
To enable extensions, verify that they are enabled in your .ini files:
- E:\xampp\php\php.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.
Why am i getting these errors? How can i install image/intervention package in my application?
I'm using laravel 5.5 , PHP 7.3.11
As the error says, do i have to install 7.2.0 php version? Or is there any other solutions?
The first problem come because there is something like "php": "~7.2", in your composer.json. Change to "php": ^7.2" to allow all PHP minor version upper 7.2. Run composer update php to fix composer.lock
The second problem is because you are missing soap extension in PHP. Try to install it. This question/anwser could help you.

Composer update trouble

I'm using laravel + composer . I'm loading way/generators package and when I run composer update give me this error:
Loading composer repositories with package information Updating
dependencies (including require-dev)
Fatal error: Allowed memory size of 536870912 bytes exhausted (tried
to allocate 67108864 bytes) in
phar:///usr/local/Cellar/composer/1.0.0-alpha8/libexec/composer.phar/src/Composer/DependencyResolver/Solver.php
on line 170
I think, This is because composer update has used all the memory.
php -d memory_limit=1G /usr/local/Cellar/composer/1.0.0-alpha8/libexec/composer.phar update
This works for me on a mac.
Also check out to use composer install.
If you are on a server with less amount of RAM like 512MB you will need to create swap memory. Here is how you do it on ubuntu
touch swap.img
chmod 600 swap.img
Using 1GB for swap
dd if=/dev/zero of=/var/swap.img bs=1024k count=1000
mkswap /var/swap.img
swapon /var/swap.img
Here is the full article https://www.digitalocean.com/community/tutorials/how-to-configure-virtual-memory-swap-file-on-a-vps
I was having problem to install laravel with composer.
Original command was:
composer global require "laravel/installer=~1.1"
And Error message was:
Loading composer repositories with package information Updating dependencies (including require-dev)
Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 67108864 bytes) in phar:///usr/local/Cellar/composer/1.0.0-alpha8/libexec/composer.phar/src/Composer/DependencyResolver/Solver.php on line 170
Following command should work:
php -dmemory_limit=1G /usr/local/Cellar/composer/1.0.0-alpha8/libexec/composer.phar global require "laravel/installer=~1.1"
In my case I encountered the same problem and manage to solve by halting the Apache and MySQL service and then proceeding to install the laravel application via composer.
The sudo service stop apache2 followed by sudo service stop mysql stop this in turn killed the application that were consuming memory I then proceeded to install the Laravel via the normal composer command once done I just restarted the service and everything was fine.
I found solution, after read this post: https://github.com/composer/composer/issues/1898
Thank you to "Dynom, commented on Jul 4, 2013"
Needing 512MiB RAM for a package-manager is already a bit much, but I
also exceed it. The interesting part is that I exceed 512 MiB RAM (up
to around 800 MiB RAM according to my process output) when I use my
private Satis repository (which is actually just a cache for all
Github public repositories). I do not exceed it otherwise. Just by
adding my satis repository, composer consumes almost 400 MiB more RAM
To all the others raising their PHP CLI memory_limit globally, I
recommend against that. Instead I suggest to put it in the command
line, like so:
php -dmemory_limit=1G {composer location} update
Example:
php -dmemory_limit=1G bin/composer.phar update
Otherwise you could potentially miss certain unintended memory related
behaviour in your own work.
Tested on: Debian version 6
Do you have the last version of composer? I've fixed that problem with a simple update:
sudo composer self-update

Resources