composer 1 out of memory - impossible to update to 2 - composer-php

Everytime I try to install a new package on my webserver, I run into composer error (after very long delay). What is the solution? What is the work around?
pgodard#dedi13:~/public_html$ composer require setasign/fpdf:^1.8
Warning from https://repo.packagist.org: Support for Composer 1 is deprecated and some packages will not be available. You should upgrade to Composer 2. See https://blog.packagist.com/deprecating-composer-1-support/
Info from https://repo.packagist.org: #StandWithUkraine
./composer.json has been updated
Loading composer repositories with package information
Warning from https://repo.packagist.org: Support for Composer 1 is deprecated and some packages will not be available. You should upgrade to Composer 2. See https://blog.packagist.com/deprecating-composer-1-support/
Info from https://repo.packagist.org: #StandWithUkraine
Updating dependencies (including require-dev)
Fatal error: Allowed memory size of 1610612736 bytes exhausted (tried to allocate 12288 bytes) in phar:///usr/bin/composer/src/Composer/DependencyResolver/RuleSetGenerator.php on line 64
Check https://getcomposer.org/doc/articles/troubleshooting.md#memory-limit-errors for more infopgpgppgodard#dedi13:~/public_html$
If I try to update composer, I get another error...
pgodard#dedi13:~/public_html$ composer selfupdate --2
Updating to version 2.4.2 (2.x channel).
Downloading (100%)
[Composer\Downloader\FilesystemException]
Filesystem exception:
Composer update failed: "/usr/bin/composer" could not be written.
rename(/usr/bin/composer): Failed to open stream: Permission denied
On my local webserver on my mac, it works 100%.

To write to /usr/bin, you need elevated permissions. Run composer self-update through sudo, like sudo composer self-update

Related

Composer always fails to install symfony/var-dumper

I'm trying to install the latest version of Laravel 8 on the latest version of Homestead. When I run composer install or composer update, installation of symfony/var-dumper always fails:
Installing symfony/var-dumper (v5.2.6): Extracting archive
Install of symfony/var-dumper failed
[ErrorException]
file_get_contents(/home/vagrant/code/vendor/symfony/var-dumper/Resources/bin/var-dump-server):
Failed to open stream: No such file or directory
Despite the error exception, the file /vendor/symfony/var-dumper/Resources/bin/var-dump-server does exist.
Things I've tried:
Deleting the lock file and re-running composer update
Manually specifying specific versions of var-dumper, e.g. composer require symfony/var-dumper:5.2.0
I always get the same errors.
Remove /vendor folder, then run:
composer update -v
This turned out to be a compatibility issue with Composer 2.x. I downgraded to the 1.x channel using composer self-update --1, then ran composer install again, and the installation succeeded.
Composer version 2.2.4 2022-01-08 12:30:42
and
symfony/var-dumper v5.4.3
is working just fine

Install package composer require yajra/laravel-oci8 but got some error

I want to install a package with composer require yajra/laravel-oci8:^8. I'm using Laravel 8.10.0, it seems that the package supports that version but the following error appears:
How to solve this?
composer require yajra/laravel-oci8:^8
./composer.json has been updated
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
- Installation request for yajra/laravel-oci8 8 -> satisfiable by yajra/laravel-oci8[v8.0.0].
- yajra/laravel-oci8 v8.0.0 requires ext-oci8 >=2.0.0 -> the requested PHP extension oci8 is missing from your system.
To enable extensions, verify that they are enabled in your .ini files:
- C:\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.
Go to check with this PR and follow the instruction:
https://github.com/yajra/laravel-oci8/issues/429

How to install Laravel on AWS free tier? [duplicate]

This question already has an answer here:
Server composer install --no-dev killed
(1 answer)
Closed 2 years ago.
I am struggling to install Laravel on the AWS free tier Ubuntu instance. It gets stucks on the Composer installation due to a memory limit.
I initially ran the following commands:
sudo apt update && sudo apt upgrade
sudo apt install php7.2-common php7.2-cli php7.2-gd php7.2-mysql php7.2-curl php7.2-intl php7.2-mbstring php7.2-bcmath php7.2-imap php7.2-xml php7.2-zip
curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer
composer --version
composer create-project --prefer-dist laravel/laravel my_app
I set the storage limit to 30gb in the instance. I tried to find a solution and everybody suggested to set the Composer limit to =-1. It still didn't resolve my issue.
I got this error when installing packages with Composer:
composer updating dependencies (including require-dev) killed
I tried to find the memory limit like this:
php -r "echo ini_get('memory_limit').PHP_EOL;"
It showed -1.
I also got this memory information:
It showed the memory limit as 128M. Is my issue due to this? If yes, then how can I increase the memory?
I just wanted to know that can we install Laravel with Composer on the free tier. I am not understanding everything clearly on this matter or is it any other configuration issue?
Yes, we can.
I verified that on AWS using t2.micro Ubuntu 18.04 with 30GB (don't need 30GB, but I used what you have).
For laravel installation, the following command was used:
composer global require laravel/installer
And also got memory error:
The following exception is caused by a lack of memory or swap, or not having swap configured
Check https://getcomposer.org/doc/articles/troubleshooting.md#proc-open-fork-failed-errors for details
In Process.php line 344:
proc_open(): fork failed - Cannot allocate memory
Based on the message, I added 1GB of swap by following these steps.
Once the swap was setup, I executed laravel installation command again and this time it worked.
I tested newly installed laravel by generating its standard blog project:
composer create-project --prefer-dist laravel/laravel blog
The command worked:
Installing laravel/laravel (v7.12.0)
- Installing laravel/laravel (v7.12.0): Loading from cache
Created project in blog
> #php -r "file_exists('.env') || copy('.env.example', '.env');"
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 92 installs, 0 updates, 0 removals
#
# not shown
#
Package manifest generated successfully.
> #php artisan key:generate --ansi
Application key set successfully.
Hope this helps.
p.s.
Installing php and various php extensions were also required.
Rob suggested this previously:
Download an existing composer.lock file from your git project. Then install Composer in same location. If you don't have a composer.lock file in your git repository, first push it to git from your development environment. Thanks Rob.

composer require laravel/dusk error

I am trying to install Laravel/Dusk on a laravel 5.4 application.
The command that I am running is, according to the documentation: https://laravel.com/docs/5.4/dusk
composer require laravel/dusk
The output in terminal:
Using version ^1.0 for laravel/dusk
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
- Installing facebook/webdriver (1.3.0)
Loading from cache
- Installing laravel/dusk (v1.0.10)
Downloading: 100%
Killed
That Killed is what's bothering. So, the package is being added to my composer.json file but no files can be found in vendor/laravel/dusk
I am trying to install this on my webhost and not on my local environment.
Any ideas?
The error is due to your machine on the host running out of memory, like described on this thread: https://github.com/composer/composer/issues/1815
So you may have to increase the performance on your account to be able to run more composer commands from your webhost.

Composer doesn't run in presence of composer.json

I installed composer globally on my Debian server
~$ which composer
/usr/local/bin/composer
It works, gets updated and I used it for three different (Symfony) sites.
~$ composer self-update
You are already using composer version 1.3.3 (stable channel).
However, when I am in the directory of one of the sites, and try to update all dependencies, I get an error (before, this just worked and updated the vendors etc).
~/website-path$ ls composer.*
composer.json composer.lock
~/website-path$ composer update
[ErrorException]
Illegal string offset 'version'
~/website-path$ composer
[ErrorException]
Illegal string offset 'version'
When I rename composer.json, this Error disappears (but the lack of .json file makes this quite useless)
What went wrong here and how can I fix this?
The problem magically went away overnight by upgrading to 1.4.0
~$ composer -V
Composer version 1.4.0 2017-03-08 17:51:24
~/website-path$ composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
[...]

Resources