Updating a Composer Package - NCIOCPL/cgov-digital-platform GitHub Wiki

- ¡¡¡¡¡NEVER RUN `composer update` EVER!!!!!
- ¡¡¡¡¡NEVER try to update a composer package without having done an install first!!!!!

For Specialized Packages


Steps to Update a Composer Package

  1. Make sure the package that you are updating does not have any patches defined in our composer.json.
    • If it does, abort and document how to re-roll the patch...
  2. Checkout your develop branch
  3. composer cgov-clean to remove current packages
  4. composer install to install a fresh set of packages
  5. Checkout a new branch e.g git checkout -b ticket/123-update-pkg-name
  6. Install the drupal site (blt cgov:reinstall --no-interaction)
  7. Upgrade your package: composer require <PACKAGE_NAME>:<VERSION> --update-with-dependencies
    • E.g. composer require drupal/acquia_connector:^1.16 --update-with-dependencies
  8. Run drush updb --yes to run any update hooks for the module.
    • These update hooks CAN modify the configurations, so it is important that we update the configurations in config/install
    • Do not run blt drupal:update it will overwrite any updated configs
  9. Run drush features:list:packages and export any packages that have changed.

    Warning Any configs in profiles/custom/cgov_site/config/install or in a module that does not have a <module>.features.yml file will not be exported. You need to update those configs by hand.

  10. Test, including, but not limited to:
  • Review the changes to composer.lock.json at a high-level. Check and see if only those items you expected were updated. (e.g. if you update the acquia connector module you should not see an update to Drupal core.)
  • blt cgov:rebuild-feq && blt cgov:reinstall --no-interaction
    • Did drupal install correctly, did the content load?
    • Does the site look like a web site?
  • blt paratest
    • Did the tests pass?
  1. If testing works, commit your code and submit a PR

Composer failure - memory exhausted

Composer may sometimes fail on some commands with this message: PHP Fatal error: Allowed memory size of XXXXXX bytes exhausted <...> In this case, the PHP memory_limit should be increased:

  1. Find php.ini. It should be in /usr/local/etc/php/7.2/php.ini, but to be sure, run php -i | grep php.ini to find the path.
  2. Open php.ini and find the line that says memory_limit = <some_number>. Change the number to the desired value or -1 for unlimited.
⚠️ **GitHub.com Fallback** ⚠️