From edaf78d0f156c18a7ebffbb3f78789308eb6126e Mon Sep 17 00:00:00 2001 From: Les Peabody Date: Tue, 2 Jun 2026 09:51:02 -0400 Subject: [PATCH 1/2] Don't abort composer install when polymer:init can't run MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Composer plugin scaffolds project files on initial install by shelling out to `polymer polymer:init`. When Polymer is pulled in as a transitive dependency (e.g. an extension package such as polymer-drupal building in CI), there is no Polymer project to initialize and `bin/polymer` exits with "Could not find .polymer directory", which the plugin rethrew as a fatal "Installation aborted" — breaking composer install entirely. Scaffolding is a convenience, not a hard requirement of installing the library, so log a warning and continue instead of aborting. Co-Authored-By: Claude Opus 4.8 --- src/Composer/Plugin.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Composer/Plugin.php b/src/Composer/Plugin.php index 394283c..a342d3a 100644 --- a/src/Composer/Plugin.php +++ b/src/Composer/Plugin.php @@ -192,9 +192,7 @@ protected function isInitialInstall(): bool } /** - * Executes `polymer polymer:update` and `polymer-console polymer:update` commands. - * - * @throws \Exception + * Scaffolds Polymer's project template files on initial install. */ protected function executePolymerUpdate(): void { @@ -204,8 +202,11 @@ protected function executePolymerUpdate(): void $command = $this->getVendorPath() . '/bin/polymer polymer:init'; $success = $this->executeCommand($command, [], true); if (!$success) { - $this->io->writeError("Polymer installation failed! Please execute $command --verbose to debug the issue."); - throw new \Exception('Installation aborted due to error'); + // Scaffolding is a convenience for projects adopting Polymer. When + // Polymer is pulled in as a transitive dependency (e.g. an extension + // package's own CI) there is no project to initialize, so warn and + // continue rather than aborting the entire composer install. + $this->io->writeError("Polymer could not initialize project files; skipping. If this is a Polymer project, run $command --verbose to debug."); } } } From a47b6bd9e31205b6c6b1d2271f639f6fc79b5ee0 Mon Sep 17 00:00:00 2001 From: Les Peabody Date: Tue, 2 Jun 2026 09:55:09 -0400 Subject: [PATCH 2/2] Skip polymer:init when there is no .polymer project (Gemini #78) Check for a .polymer directory before attempting initialization so transitive-dependency installs skip silently instead of printing scaffolding output and a failed-command warning. Co-Authored-By: Claude Opus 4.8 --- src/Composer/Plugin.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Composer/Plugin.php b/src/Composer/Plugin.php index a342d3a..b0d3d4d 100644 --- a/src/Composer/Plugin.php +++ b/src/Composer/Plugin.php @@ -197,15 +197,19 @@ protected function isInitialInstall(): bool protected function executePolymerUpdate(): void { if ($this->isInitialInstall()) { + // Only initialize within an actual Polymer project, which has a + // .polymer directory at its root. When Polymer is pulled in as a + // transitive dependency (e.g. an extension package's own CI) there is + // nothing to initialize, so skip silently rather than emitting noise + // or aborting the composer install. + if (!is_dir($this->getRepoRoot() . '/.polymer')) { + return; + } $this->io->write('Creating Polymer template files...'); /** @var string $command */ $command = $this->getVendorPath() . '/bin/polymer polymer:init'; $success = $this->executeCommand($command, [], true); if (!$success) { - // Scaffolding is a convenience for projects adopting Polymer. When - // Polymer is pulled in as a transitive dependency (e.g. an extension - // package's own CI) there is no project to initialize, so warn and - // continue rather than aborting the entire composer install. $this->io->writeError("Polymer could not initialize project files; skipping. If this is a Polymer project, run $command --verbose to debug."); } }