`composer update` doesn't update to the latest version

Viewed 6300

In my composer.json I have

"require": {
    . . .
    "unisharp/laravel-filemanager": "~1.8"
}

Currently, the latest version is v1.8.2.2 and after running the composer update command I have it installed on my localhost project (everything is OK).

I have pushed (git push origin master) from localhost to the remote repo on Bitbucket, and via SSH I have connected to the web server and cloned (git clone ...) it from that remote repo.

Now, when I run composer update (on web server) - it installs v1.8.0 which has some bug. After that, when I try again to run composer update - I get:

Nothing to install or update

... but it's still v1.8.0 (not v1.8.2.2 like it is on localhost).

So, I have identical project with identical composer.json on my localhost and on live server but, for some reason, localhost has the latest version of the package and live version has the old version with bug and composer update doesn't update it.

Do you know why this is happening and how can I solve it?

2 Answers

You should run composer update locally. This will update composer.lock with the versions of all the packages you have installed. You should commit your composer.lock file to your version control.

On your server, once you've updated your files you should then run a composer install so Composer can update its dependencies to match those specified in your composer.lock file.

I just spent two hours debugging this. Turns out the problem was that there was a "version" tag in the composer.json file.

When there is a version tag there, that version will be used in priority above any git tag version that you apply.

Related