"The lock file is not up to date with the latest changes" when deploying

I’m trying to update Wordpress and some plugins through Composer but when I deploy I get the following message.

Loading composer repositories with package information Installing dependencies from lock file Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. Run update to update them.

Then it uses the cached versions and doesn’t update. The only way to update is to run composer update on the actual server.

What could I be doing wrong? This was working a while ago and now suddenly not.
I have included my composer.json below:

{
  "name": "example/example",
  "type": "project",
  "description": "Example",
  "homepage": "https://example.com",
  "authors": [
    {
      "name": "Craig Dennis",
      "email": "craig@simplebitdesign.com",
      "homepage": "https://github.com/craigmdennis"
    },
  ],
  "config": {
    "preferred-install": "dist"
  },
  "repositories": [
    {
      "type": "composer",
      "url": "https://wpackagist.org"
    },
    {
      "type": "package",
      "package": {
        "name": "advanced-custom-fields/advanced-custom-fields-pro",
        "version": "5.5.14",
        "type": "wordpress-plugin",
        "dist": {
          "type": "zip",
          "url": "https://connect.advancedcustomfields.com/index.php?p=pro&a=download"
        },
        "require": {
          "philippbaschke/acf-pro-installer": "^1.0",
          "composer/installers": "^1.0"
        }
      }
    },
    {
      "type": "package",
      "package": {
        "name": "deliciousbrains/wp-migrate-db-pro",
        "type": "wordpress-plugin",
        "version": "1.7.1",
        "dist": {
          "type": "zip",
          "url": "https://deliciousbrains.com/dl/wp-migrate-db-pro-latest.zip?"
        },
        "require": {
          "igniteonline/wpm-pro-installer": "^1.0.4",
          "composer/installers": "^1.0"
        }
      }
    },
    {
      "type": "package",
      "package": {
        "name": "deliciousbrains/wp-migrate-db-pro-media-files",
        "type": "wordpress-plugin",
        "version": "1.4.7",
        "dist": {
          "type": "zip",
          "url": "https://deliciousbrains.com/dl/wp-migrate-db-pro-media-files-latest.zip?"
        },
        "require": {
          "igniteonline/wpm-pro-installer": "^1.0.4",
          "composer/installers": "^1.0"
        }
      }
    }
  ],
  "require": {
    "php": ">=5.6",
    "wpackagist-plugin/popup-builder": "^2.6",
    "composer/installers": "~1.0.12",
    "vlucas/phpdotenv": "^2.0.1",
    "johnpbloch/wordpress": "4.9.3",
    "oscarotero/env": "^1.0",
    "roots/wp-password-bcrypt": "^1.0.0",
    "advanced-custom-fields/advanced-custom-fields-pro": "*",
    "deliciousbrains/wp-migrate-db-pro": "*",
    "deliciousbrains/wp-migrate-db-pro-media-files": "*",
    "wpackagist-plugin/wordpress-seo": "^4.2",
    "wpackagist-plugin/archive-control": "^1.3.3",
    "wpackagist-plugin/post-type-archive-links": "^1.3.1",
    "wpackagist-plugin/post-types-order": "^1.9",
    "wpackagist-plugin/ninja-forms": "^3.0.26",
    "wpackagist-plugin/backwpup": "^3.3.4",
    "wpackagist-plugin/wordfence": "^6.3.1",
    "wpackagist-plugin/simple-301-redirects": "^1.07",
    "wpackagist-plugin/mailgun": "^1.5"
  },
  "require-dev": {
    "squizlabs/php_codesniffer": "^2.5.1"
  },
  "extra": {
    "installer-paths": {
      "web/app/mu-plugins/{$name}/": ["type:wordpress-muplugin"],
      "web/app/plugins/{$name}/": ["type:wordpress-plugin"],
      "web/app/themes/{$name}/": ["type:wordpress-theme"]
    },
    "wordpress-install-dir": "web/wp"
  },
  "scripts": {
    "test": [
      "vendor/bin/phpcs"
    ]
  }
}

This answer was correct but I actually needed to run composer clearcache from the /srv/www/example.com/current directory.

It’s worked on my staging droplet, now to try it on production.

Ok, so now I have the following when deploying:

Loading from cache - Installing deliciousbrains/wp-migrate-db-pro (1.7.1)
Loading from cache - Installing deliciousbrains/wp-migrate-db-pro-media-files
(1.4.7)

Loading from cache [InvalidArgumentException] Two packages cannot
share the same directory!

Could this be to do with having updated Trellis?
It runs fine when I composer install on the server.

Have you committed and pushed an up-to-date composer.lock file to your repo?

Could you try the steps here to deploy in a manner that avoids cached composer files? If it works, you should be able to go back to regular deploys.