Why Composer uninstall things right after the installation? - composer-php

Composer keeps removing the files just after it installs them!
I used composer create-project otra/skeleton --remove-vcs otra-user -vvv to debug and it shows things like :
- Installing otra/otra (1.0.0-alpha.2.4.0): Extracting archive
Executing async command (CWD): unzip -qq -o '/var/www/html/perso/otra-user/vendor/composer/tmp-ad5334fdc8c968f8ad3d54814c2b67c1' -d '/var/www/html/perso/otra-user/vendor/composer/cc30fdc4'
Executing command (CWD): rm -rf '/var/www/html/perso/otra-user/vendor/otra/otra'
Executing command (CWD): rm -rf '/var/www/html/perso/otra-user/vendor/composer/cc30fdc4'
And as usual since a few months, it finished with the infinite loop that shows :
2 packages you are using are looking for funding.
Use the composer fund command to find out more!
Loading composer repositories with package information
Updating dependencies
Nothing to modify in lock file
Installing dependencies from lock file (including require-dev)
Nothing to install, update or remove
Composer works like a charm before, I do not know what they have changed so I have all those issues now.
I have updated my Composer version and I did a composer diagnose but it shows nothing wrong.
I am using Composer 2.0.12 and PHP 8.0.3.

Thanks to #yivi that pointed me to an another problem in composer.json where I indeed did a loop...
I solved my problem replacing #otra-update by #otra-init in post-install-cmd and post-update-cmd which was what I really wanted to do.
Thanks for your time #Nico Haase and #yivi :)

Related

Composer: Command Not Found on Mac

I have installed Composer as per the instructions command not found
After installing I get the prompt that Composer is successfully installed but when I go to check the version it gives me error "Composer: Command Not Found"
I have been looking how to fix this issue and I had to read and understand little bit and the environment variables on MAC.
I understand the issue looks simple but it will get over complicated if you didn't understand how to install composer probably.
Solution 1
I found this solution here: https://duvien.com/blog/installing-composer-mac-osx
Open a terminal and navigate to your user directory, ie cd /User//
Run this command shown below to download Composer. This will create a Phar (PHP Archive) file called composer.phar:
curl -sS https://getcomposer.org/installer | php
Now we move composer.phar file to a directory
sudo mv composer.phar /usr/local/bin/
We want to run Composer with having to be root al the time, so we need to change the permissions:
sudo chmod 755 /usr/local/bin/composer.phar
Next, we need to let Bash know where to execute Composer:
nano ~/.bash_profile
Add this line below to bash_profile and save
alias composer="php /usr/local/bin/composer.phar"
and then run this command:
source ~/.bash_profile
Finally, run:
composer --version
Solution 2:
I understand that the first command you will find online when you try to google this issue would be
curl -sS https://getcomposer.org/installer | php
But actually this is the main terminal installation but sometimes I wanted to manually install the composer, so this 2nd solution about manually installing the composer in specific directory
First of all you need to understand where are you now on the terminal
use
pwd
and then install composer manually using the following commands
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') ==='baf1608c33254d00611ac1705c1d9958c817a1a33bce370c0595974b342601bd80b92a3f46067da89e3b06bff421f182') { echo 'Installer verified'; } else { echo 'Installer corrupt';
unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"
to use it on that case you will read on the terminal to use this composer installation use
Use it: php composer.phar
so just write
php composer.phar
and it should be working.... one more thing, during this installation you can install the composer to specific directory / project folder... in that case you can use a flag with command No.4 to tell the terminal to install the composer in specific directory...this flag is --install-dir=your-directory-path
and you will the terminal this time after installing composer asking you to use the following path to call the composer
Use it: php /Users/muatafa/composer.phar
if you want to read more about this issue, I think you must read the composer documentation how to install it>>> https://getcomposer.org/download/
that's how I solved my current issue... if you still have any issues comment on this replay & Hopefully we can figure it out!
I had the same problem. "composer require something" works if installed in global and not locally.
If you install composer locally you'll then install dependencies using "php composer.phar require nameofyoudependency"
To install globally open a terminal to install as mentionned on the composer website. Then run "sudo mv composer.phar /usr/local/bin/composer"
Now you can use "composer" directly to install dependencies like => "composer require something/sdk"
the composer you installed is still named /usr/local/bin/composer.phar - look in the second yellow/brownish line in your output. Just rename it to just composer
Your composer command is not set to path, use
export PATH=$PATH:/usr/local/bin/
I had the same issue, After installing composer using the command line on their website. I forgot to put composer.phar into a directory on my PATH, so it can simply be called from any directory (Global install). and then I ran this command "sudo mv composer.phar /usr/local/bin/composer" and it was resolved
I figured out. in place of "composer require twilio/sdk" I needed to use
"composer.phar require twilio/sdk" since I am on mac. It worked

Laravel Installer method

Normally I do install Laravel 5.1 by following this command regarding to documentation:
composer create-project laravel/laravel --prefer-dist
It works fine.
But I read in the documentation under "Via Laravel Installer" also it is possible to install via Laravel Installer, which is much faster than installing via Composer:
laravel new blog
But to use this method I need to run following command once:
composer global require "laravel/installer=~1.1"
When I do run it I get following errors many times
Deprecation Notice: Composer\Package\Version\VersionParser::parseLinks
is deprecated. Use \Composer\Package\Loader\ArrayLoader::parseLinks()
instead in
phar://C:/ProgramData/Composer/bin/composer.phar/src/Composer/Package/Version/VersionParser.php:226
after many line of same error ./composer.json has been updated appears and it continues with the same line of errors, it ends with following
Loading composer repositories with package information Updating
dependencies (including require-dev) Nothing to install or update
Generating autoload files
What is wrong with it? Any idea or solution.
My environment: Windows 10, GitBash and cmder console.
Update of composer, I did ran composer self-update also
Snapshot of console
EDIT:
Note, I can confirm after solving the issue that the installation via Laravel Installer method is faster than composer.
The Composer Assets Plugin you've installed locally is using a deprecated method of Composer. The plugin is already fixed, so run composer global update to get the latest versions with the bug fix. After it, you should be able to run the command succesfully.
If this doesn't work (as you might get the same error running the previous command), try removing the global vendor directory. When running any global Composer command, it outputs something like "Changed current directory to XXX". Remove the XXX/vendor directory and then try running the command.
In addition to #WouterJ answer.
Worst case if the steps provided by #WouterJ did not work, you could manage to uninstall and reinstall composer for windows.
When done, run composer global update to be sure to get latest updates, if there was.
Then run composer global require "laravel/installer=~1.1" and it should works.
Remember to update your windows environment path C:\Users\UserName\AppData\Roaming\Composer\vendor\bin

Can't run any "composer create-project" or "composer require" command

I tried to clone some packages to my symfony projects, but it seems there are some issues with repository servers.
My command stays there for ever and does nothing:
$ php composer.phar require sonata-project/admin-bundle
Does anyone know how to work around it?
Thanks,

Composer returning question marks

My mac is installed with composer and it works fine. I then clone a laravel project. When I run composer update, some of the dependencies require some php stuff to be downloaded first, like php53-mcrypt. After installing the php stuff, i ran composer update again, it returns a bunch of question marks. A bit of googling returns me answers that require to set the
detect_unicode=Off
in the php.ini. Set it off but still the same. Reinstall composer with the following command
curl -s getcomposer.org/installer | php -d detect_unicode=Off
Still the same. Anyone can help?
Apparently, I had to make sure I added the detect_unicode = off in the correct php.ini file. Reinstall composer with homebrew again and it works.

Composer ask me for update every time

When I try to do:
$ sudo php composer.phar update
I get this warning:
Warning: This development build of composer is over 30 days old. It is recommended to update it by running "composer.phar self-update" to get the latest version.
When I type:
$ sudo php composer.phar self-update
$ sudo php composer.phar update
the warning disappear, but the next time I want to execute the same command (not after 30 days), the warning comes again. How can I solve it?
My guess is that something else overwrites your composer.phar with an old copy. If the self-update process was failing, then you would still see the warning when doing an update right after. If you don't then something must be happening in the meantime.
You can use php composer.phar -V to see the exact version of the phar you have. You could check after a self-update and check after a while again to see if the version changed. Maybe it's checked out in git or you have a build process reverting it or something?

Resources