1
Composer-Noted-&-Troubleshooting
rob edited this page 2026-06-29 09:04:48 +00:00

This is a dump of composer related info, issues, errors, and troubleshooting. This should get organized more properly later. Anything obsolete or unnecessary should be removed.

Old email thread (Sep 5, 2022):

We have successfully configured Amazon SP API on the local machine, now to push this on live we need one package to be installed on the Live server

composer require double-break/spapi-php

I tried to install this package but got an error on live for a token, I tried adding a token by generating through the link provided by the composer, But still, I did not get luck in installation.

image.png{width="543" height="146"}
I don't want to mess up with the Server, so I am posting this information to you, please guide me or please install that package, so that we can start checking our code on live. 

I have pushed code to Gitlab but it's not merged into the master.

Composer on local development setup is latest, where as composer on the production server is 1.6.5 version. I tried to update the composer on production using following command: composer selfupdate

But I got following error.

image.png{width="563" height="100"}

Reply;

First, a more general note: you shouldn't be requiring individual packages on the server. That's a recipe for breaking things. Please review the composer documentation. You should only ever do "composer require" or "composer update" in a development environment. Composer will then figure out the right set of package versions, and record them in composer.lock. On the production server, you should only ever be running "composer install", which simply installs the packages/versions specified in composer.lock.

The typical "release code to production" process should really only ever be:

1. git pull

2. composer install

3. run any data base migrations.

As for the github token issue, I'm not sure what you're doing wrong. If you're pasting in the token correctly, it should just work. It seems like something else is going wrong, since when I look at the server, there's no file in /root/.config/composer/auth.json. 

I think you might want to upgrade composer (both locally and on the server) to the current version.  I notice on the server that it's still some old version (1.6.5).  It's possible it's not compatible with modern github tokens.

I would suggest the following:

1. Upgrade composer to the current version on your dev machine and on the server.

2. Get all the dependencies sorted out and working on your local machine. 

3. Commit composer.json and composer.lock

4. Check out the code on the server.

5. Do "composer install" on the server.

Upgrading composer should fix the token issue, and doing the correct process for deployment (installing versions from the lock file) should ensure you don't break things in production.

Solution: You can just download the latest version directly from https://getcomposer.org/download/

Something like this should work:

wget https://getcomposer.org/download/2.4.1/composer.phar    # download the current version

chmod +x composer.phar                                        # make it executable

mv composer.phar /usr/local/bin/composer                     # move it into place