composer_manager_write_if_changed() bypasses the value of composer_manager_autobuild_file if invoked via the CLI SAPI. There's no indication as to why that's necessary and it causes Drush to return a non-zero exit code when enabling modules via Drush in a read-only environment.

One use case for this is being able to test site installation via continuous integration: we want to prevent the codebase from being modified during integration testing. Drush will return a non-zero exit code, indicating a failure and leading to an overall build failure, even though the rest of the installation succeeded only because Composer Manager ignored composer_manager_autobuild_file and attempted to write where it wasn't allowed.

Comments

Mark Trapp created an issue. See original summary.

mark trapp’s picture

Status: Active » Needs review
StatusFileSize
new1.65 KB

Attached is a patch that removes the bypass.

mark trapp’s picture

Looks like this was originally introduced in #2000694: Rebuild the composer.json file and run composer update only when necessary while enabling a module via Drush. I agree with the sentiment in that issue, especially about being able to run it on hosted environments like Acquia Cloud which do not have write access: another use case for removing the drupal_is_cli() bypass is running Drush as part of a post-deploy hook.

Double-checked to see if 8.x-1.x needed any modifications, and it doesn't look like it: files aren't rebuilt when modules are enabled like 7.x-1.x. They are rebuilt automatically after modules are downloaded via Drush, but that can be prohibited via the SKIP_COMPOSER_UPDATE environment variable.

c4rl’s picture

Status: Needs review » Reviewed & tested by the community

I also needed this functionality, it was causing a lot of confusion.

Thanks for the patch, marking RTBC.

c4rl’s picture

I made these changes explicit in the UI.

c4rl’s picture

Oops typo

matt2000’s picture

+1 and RTBC on c4rl's UI text update.

markhalliwell’s picture

Indeed, RTBC. Quite frustrating when enabling modules with drush on remote server.

  • deviantintegral committed f9e1367 on 7.x-1.x authored by c4rl
    Issue #2545680 by c4rl, Mark Trapp: Autobuild settings are not honored...
deviantintegral’s picture

Status: Reviewed & tested by the community » Fixed

This would also be an issue with uninstalling modules. Code looks good and works as advertised. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.