Composer Install doesn't seem to run at all during deploys

Hi guys, first of all thanks! This workflow is beautiful :slight_smile: I almost managed to get it fully working.
But we I deploy the app through capistrano on my staging server, I can’t manage to get this command working at all

cd /home/www/XXX/releases/20140313122152 && ( WP_ENV=staging /usr/bin/env composer install --no-dev --no-scripts --quiet --optimize-autoloader )

To be a little more verbose here’s what I did.

I added a dependency on composer.json, committed and pushed on the repo.
Started a new release deploy which correctly finishes, and it doesn’t seem to throw any error out, and when I do check on releases/20140313122152/web/app/plugins the plugin I was expecting to be there is actually there. But when I take a look on current/web/app/plugins is not there.
As a consequence, of course, the vhost pointing on current doesn’t list any of the plugins I add through composer at all.

Any idea why this happens?

Can you post your composer.json file?

You could also try setting your Capistrano log level to debug and add this to your deploy.rb file:

set :composer_install_flags, '--no-dev --no-interaction --optimize-autoloader'

(This removes the default --quiet just so you can see more output of the composer command to see what’s going on.

1 Like
{
  "name": "roots/bedrock",
  "type": "project",
  "license": "MIT",
  "description": "A modern WordPress stack",
  "homepage": "http://roots.io/wordpress-stack/",
  "authors": [
    {
      "name": "Scott Walkinshaw",
      "email": "scott.walkinshaw@gmail.com",
      "homepage": "https://github.com/swalkinshaw"
    },
    {
      "name": "Ben Word",
      "email": "ben@benword.com",
      "homepage": "https://github.com/retlehs"
    }
  ],
  "keywords": [
    "wordpress", "stack", "capistrano", "composer", "vagrant", "wp"
  ],
  "support": {
    "issues": "https://github.com/roots/bedrock/issues",
    "forum": "http://discourse.roots.io/category/bedrock"
  },
  "config": {
    "preferred-install": "dist",
    "generate-salts": true
  },
  "autoload": {
    "psr-0": {"Bedrock\\Installer": "scripts"}
  },
  "scripts": {
    "post-root-package-install": ["Bedrock\\Installer::addSalts"]
  },
  "repositories": [
    {
      "type": "composer",
      "url": "http://wpackagist.org"
    },
    {
      "type": "package",
      "package": {
        "name": "wordpress",
        "version": "3.8.1",
        "type": "webroot",
        "dist": {
          "type": "zip",
          "url": "https://github.com/WordPress/WordPress/archive/3.8.1.zip"
        },
        "require" : {
          "fancyguy/webroot-installer": "1.1.0"
        }
      }
    }
  ],
  "require": {
    "php": ">=5.3.2",
    "wordpress": "3.8.1",
    "fancyguy/webroot-installer": "1.1.0",
    "composer/installers": "v1.0.6",
    "wp-cli/wp-cli": "v0.13.0",
    "wpackagist/advanced-custom-fields":"*", 
    "wpackagist/contact-form-7-to-database-extension":"*", 
    "wpackagist/contact-form-7":"*", 
    "wpackagist/context-manager":"*", 
    "wpackagist/custom-login":"*", 
    "wpackagist/custom-post-type-ui":"*", 
    "wpackagist/edit-flow":"*", 
    "wpackagist/simple-301-redirects":"*", 
    "wpackagist/disqus-comment-system": "*",
    "wpackagist/wordpress-seo":"*",
    "wpackagist/google-analyticator": "*",
    "vlucas/phpdotenv": "~1.0.5"  
  },
  "extra": {
    "installer-paths": {
      "web/app/plugins/{$name}/": ["type:wordpress-plugin"],
      "web/app/mu-plugins/{$name}/": ["type:wordpress-muplugin"],
      "web/app/themes/{$name}/": ["type:wordpress-theme"]
    },
    "webroot-dir": "web/wp",
    "webroot-package": "wordpress"
  }
}

that’s the composer file.

One more thing to try is to use the new wpackagist namespace: wpackagist-plugin

Not sure if they’ve removed just wpackagist or deprecated it.

DEBUG [16ec0e45] Command: cd /home/www/iedtv/releases/20140313182046 && ( WP_ENV=staging /usr/bin/env composer install --no-dev --no-interaction --optimize-autoloader )

DEBUG [16ec0e45] Loading composer repositories with package information
DEBUG [16ec0e45] Installing dependencies from lock file
DEBUG [16ec0e45] 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.
DEBUG [16ec0e45] - Installing fancyguy/webroot-installer (1.1.0)
DEBUG [16ec0e45] Loading from cache
DEBUG [16ec0e45]
DEBUG [16ec0e45] - Installing composer/installers (v1.0.6)
DEBUG [16ec0e45] Loading from cache
DEBUG [16ec0e45]
DEBUG [16ec0e45] - Installing zendframework/zendxml (1.0.0)
DEBUG [16ec0e45] Loading from cache
DEBUG [16ec0e45]
DEBUG [16ec0e45] - Installing zendframework/zendframework (2.3.0)
DEBUG [16ec0e45] Loading from cache
DEBUG [16ec0e45]
DEBUG [16ec0e45] - Installing slm/google-analytics (v0.3.1)
DEBUG [16ec0e45] Loading from cache
DEBUG [16ec0e45]
DEBUG [16ec0e45] - Installing vlucas/phpdotenv (1.0.6)
DEBUG [16ec0e45] Loading from cache
DEBUG [16ec0e45]
DEBUG [16ec0e45] - Installing wordpress (3.8.1)
DEBUG [16ec0e45] Loading from cache
DEBUG [16ec0e45]
DEBUG [16ec0e45] - Installing wp-cli/php-cli-tools (v0.9.3)
DEBUG [16ec0e45] Loading from cache
DEBUG [16ec0e45]
DEBUG [16ec0e45] - Installing symfony/finder (v2.4.2)
DEBUG [16ec0e45] Loading from cache
DEBUG [16ec0e45]
DEBUG [16ec0e45] - Installing rmccue/requests (v1.6.0)
DEBUG [16ec0e45] Loading from cache
DEBUG [16ec0e45]
DEBUG [16ec0e45] - Installing rhumsaa/array_column (1.1.2)
DEBUG [16ec0e45] Loading from cache
DEBUG [16ec0e45]
DEBUG [16ec0e45] - Installing mustache/mustache (v2.5.1)
DEBUG [16ec0e45] Loading from cache
DEBUG [16ec0e45]
DEBUG [16ec0e45] - Installing wp-cli/wp-cli (v0.13.0)
DEBUG [16ec0e45] Loading from cache
DEBUG [16ec0e45]
DEBUG [16ec0e45] - Installing wpackagist/advanced-custom-fields (4.3.4)
DEBUG [16ec0e45] Loading from cache
DEBUG [16ec0e45]
DEBUG [16ec0e45] - Installing wpackagist/contact-form-7 (3.7.2)
DEBUG [16ec0e45] Loading from cache
DEBUG [16ec0e45]
DEBUG [16ec0e45] - Installing wpackagist/contact-form-7-to-database-extension (2.6.3)
DEBUG [16ec0e45] Loading from cache
DEBUG [16ec0e45]
DEBUG [16ec0e45] - Installing wpackagist/context-manager (1.2.0)
DEBUG [16ec0e45] Loading from cache
DEBUG [16ec0e45]
DEBUG [16ec0e45] - Installing wpackagist/custom-login (2.2.3)
DEBUG [16ec0e45] Loading from cache
DEBUG [16ec0e45]
DEBUG [16ec0e45] - Installing wpackagist/custom-post-type-ui (0.8.2)
DEBUG [16ec0e45] Loading from cache
DEBUG [16ec0e45]
DEBUG [16ec0e45] - Installing wpackagist/disqus-comment-system (2.74)
DEBUG [16ec0e45] Loading from cache
DEBUG [16ec0e45]
DEBUG [16ec0e45] - Installing wpackagist/edit-flow (0.8)
DEBUG [16ec0e45] Loading from cache
DEBUG [16ec0e45]
DEBUG [16ec0e45] - Installing wpackagist/enable-media-replace (2.9.5)
DEBUG [16ec0e45] Loading from cache
DEBUG [16ec0e45]
DEBUG [16ec0e45] - Installing wpackagist/simple-301-redirects (1.06)
DEBUG [16ec0e45] Loading from cache
DEBUG [16ec0e45]
DEBUG [16ec0e45] - Installing wpackagist/wordpress-seo (1.5.2.1)
DEBUG [16ec0e45] Loading from cache
DEBUG [16ec0e45]
DEBUG [16ec0e45] zendframework/zendframework suggests installing doctrine/annotations (Doctrine Annotations >=1.0 for annotation features)
DEBUG [16ec0e45] zendframework/zendframework suggests installing ext-intl (ext/intl for i18n features (included in default builds of PHP))
DEBUG [16ec0e45] zendframework/zendframework suggests installing ircmaxell/random-lib (Fallback random byte generator for Zend\Math\Rand if OpenSSL/Mcrypt extensions are unavailable)
DEBUG [16ec0e45] zendframework/zendframework suggests installing ocramius/proxy-manager (ProxyManager 0.5.* to handle lazy initialization of services)
DEBUG [16ec0e45] zendframework/zendframework suggests installing zendframework/zendpdf (ZendPdf for creating PDF representations of barcodes)
DEBUG [16ec0e45] zendframework/zendframework suggests installing zendframework/zendservice-recaptcha (ZendService\ReCaptcha for rendering ReCaptchas in Zend\Captcha and/or Zend\Form)
DEBUG [16ec0e45] wp-cli/wp-cli suggests installing psy/psysh (Enhanced wp shell functionality)
DEBUG [16ec0e45] Generating optimized autoload files

It looks like it doesn’t fetch the most updated version of composer.json which doesn’t contain any reference to enable-media-replace and contains some more plugins.

Ideas?

The important part of that is:

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.

Have you ran composer update locally? You need to run that first, which will update your composer.lock file, then commit those changes to your repo.

Now once you deploy, composer install will work as it should.

Kind of relevant http://www.reddit.com/r/PHP/comments/2092ak/composer_too_brittle_for_production/

It’s really no different than any other package manager. Ideally you’d have a mirror just in case of situations like this. But a lot of those replies about running Composer locally wouldn’t even solve the problem of Packagist being down.

And when using a tool like Capistrano your deploy would fail gracefully. You’d still have a working site, just not your latest deploy. And again, doing some sort of local build process wouldn’t solve that either.

Thanks a lot! That made the trick, my for not following the golden rule of RTFM :slight_smile:

Hi guys,

I’m new to capistrano and seem to be running into the same problem myself. I think my issue is that the composer.json file isn’t being sent up at all.

[b277ff69] Finished in 0.049 seconds with exit status 0 (successful).
INFO [e6db62d3] Running /usr/local/bin/composer install --no-dev --no-interaction --optimize-autoloader on new.makerclub.org
DEBUG [e6db62d3] Command: cd /home/simon/makerclub.org/releases/20140725073838 && ( WP_ENV=production /usr/local/bin/composer install --no-dev --no-interaction --optimize-autoloader )
DEBUG [e6db62d3] Composer could not find a composer.json file in /home/simon/makerclub.org/releases/20140725073838
DEBUG [e6db62d3] To initialize a project, please create a composer.json file as described in the http://getcomposer.org/ “Getting Started” section

Do I need to put this in the deploy.rb somewhere? Or is there way to make it look in /home/simon/makerclub.org/releases/20140725073838/wordpress where the file does seem to be

Many thanks,
Simon

So your actual WP (Bedrock based?) project is in a wordpress/ subdirectory? Ideally you’d just have everything in the root of your git repository. Not sure if there’s a reason for that setup.

The location of your deploy.rb wouldn’t change anything. But there’s a Composer option to change the working dir: --working-dir.

Try setting this in your deploy.rb file:

set :composer_install_flags, '--working-dir=wordpress --no-dev --no-interaction --quiet --optimize-autoloader'

Never tried it myself so not sure if that relative path would work. You might have to set it like:

set :composer_install_flags, -> { "--working-dir=#{release_path.join('wordpress')} --no-dev --no-interaction --quiet --optimize-autoloader" }