Skip to content

Conversation

@kayw-geek
Copy link
Contributor

Background

By default, Composer silently falls back to cloning from source when dist downloads fail. While convenient, this behavior can be problematic in production/CI environments where:

  • Unpredictable build artifacts: Source installations include .git directories and other VCS files, causing deployments to fail or behave unexpectedly
  • Silent failures: Users have no way to detect when fallback occurs, making issues hard to diagnose

Usage

Config file:

  {
      "config": {
          "source-fallback": false
      }
  }

Command line:

composer install --no-source-fallback
composer update --source-fallback

Environment variable:

COMPOSER_SOURCE_FALLBACK=0 composer install

Behavior

  • true (default): Current behavior - fallback to alternative source on failure
  • false: Fail immediately if preferred source is unavailable

When disabled and a download fails, Composer will display a clear error message explaining that fallback is disabled, rather than silently trying alternatives.

Changes

  • Added source-fallback config option (defaults to true)
  • Added --[no-]source-fallback flag to install, update, require, reinstall, and create-project commands
  • Added environment variable support (COMPOSER_SOURCE_FALLBACK)
  • Added tests for config and download manager behavior

Fixes #4591

@Seldaek Seldaek added this to the 2.10 milestone Dec 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a --force-dist option to avoid cloning

2 participants