12

I have downgraded a Symfony 5.2 app template to use Symfony 4.4 in order to allow the use of some libraries that require an older version of Symfony. The problem is that when I do composer install, I get this error near the end of the installation:

sh: symfony-cmd: command not found

It seems that the installations are mostly successful, as my vendor folder is created and populated. But I'm worried about the error.

What does this error mean? How do I fix it?

====

Edit: Here's my composer.json file:

{
    "type": "project",
    "license": "proprietary",
    "minimum-stability": "dev",
    "prefer-stable": true,
    "require": {
        "php": ">=7.4.0",
        "ext-ctype": "*",
        "ext-iconv": "*",
        "ext-json": "*",
        "composer/package-versions-deprecated": "1.11.99.1",
        "cweagans/composer-patches": "^1.7",
        "doctrine/doctrine-bundle": "^2.4",
        "doctrine/doctrine-migrations-bundle": "^3.1",
        "doctrine/orm": "^2.9",
        "phpdocumentor/reflection-docblock": "*",
        "sensio/framework-extra-bundle": "*",
        "symfony/framework-bundle": "4.4.*",
        "symfony/http-client": "*",
        "symfony/intl": "*",
        "symfony/mailer": "*",
        "symfony/mime": "*",
        "symfony/monolog-bundle": "^3.1",
        "symfony/notifier": "*",
        "symfony/process": "*",
        "symfony/property-access": "*",
        "symfony/property-info": "*",
        "symfony/proxy-manager-bridge": "*",
        "symfony/security-bundle": "*",
        "symfony/serializer": "*",
        "symfony/string": "*",
        "symfony/translation": "*",
        "symfony/twig-bundle": "*",
        "symfony/validator": "*",
        "symfony/web-link": "*",
        "symfony/yaml": "*",
        "twig/extra-bundle": "*",
        "twig/twig": "*"
    },
    "require-dev": {
        "doctrine/doctrine-fixtures-bundle": "^3.4",
        "roave/security-advisories": "dev-master",
        "symfony/browser-kit": "*",
        "symfony/css-selector": "*",
        "symfony/debug-bundle": "*",
        "symfony/maker-bundle": "*",
        "symfony/phpunit-bridge": "*",
        "symfony/stopwatch": "*",
        "symfony/var-dumper": "*",
        "symfony/web-profiler-bundle": "*",
        "vimeo/psalm": "^4.9"
    },
    "config": {
        "optimize-autoloader": true,
        "preferred-install": {
            "*": "dist"
        },
        "sort-packages": true
    },
    "autoload": {
        "psr-4": {
            "App\\": "src/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "App\\Tests\\": "tests/"
        }
    },
    "replace": {
        "symfony/polyfill-ctype": "*",
        "symfony/polyfill-iconv": "*",
        "symfony/polyfill-php72": "*"
    },
    "scripts": {
        "auto-scripts": {
            "cache:clear": "symfony-cmd",
            "assets:install %PUBLIC_DIR%": "symfony-cmd"
        },
        "post-install-cmd": [
            "@auto-scripts"
        ],
        "post-update-cmd": [
            "@auto-scripts"
        ]
    },
    "conflict": {
        "symfony/symfony": "*"
    },
    "extra": {
        "symfony": {
            "allow-contrib": false,
            "require": "5.2.*"
        },
        "patches": {
            "symfony/maker-bundle": {
                "Provide flag to force annotation in make entity command": "https://raw.githubusercontent.com/vklux/maker-bundle-force-annotation/master/maker-force-annotation-flag.patch"
            }
        }
    }
}

4 Answers4

30

For those who have the symfony/flex package installed and are still getting the error, make sure the symfony/flex package is allowed to execute code when running composer.

This is because since Composer 2.2.0 the allow-plugins option adds a layer of security that allows you to restrict which Composer plugins can execute code at startup time.

So make sure you have the appropriate line in the allow-plugins config in your composer.json file

"config": { 
    // other config...

    "allow-plugins": {
        "symfony/flex": true
    }
},
emrdev
  • 2,155
  • 3
  • 9
  • 15
15

symfony-cmd is a part of Symfony Flex. Your composer.json does not contain any requirement for Flex, so running composer require symfony/flex might resolve that problem.

Nico Haase
  • 11,420
  • 35
  • 43
  • 69
5

While adding symfony/flex to the project is one solution, keep in mind that Flex is optional. If you want to get rid of the error without installing Flex, simply remove the symfony-cmd command references from your composer.json.

Before:

    "scripts": {
        "auto-scripts": {
            "cache:clear": "symfony-cmd",
            "assets:install %PUBLIC_DIR%": "symfony-cmd"
        },
        "post-install-cmd": [
            "@auto-scripts"
        ],
        "post-update-cmd": [
            "@auto-scripts"
        ]
    },

After:

    "scripts": {
        "auto-scripts": {},
        "post-install-cmd": [],
        "post-update-cmd": []
    },
Charlie Hills
  • 636
  • 6
  • 13
0

I ran into a special case were an old deploy script added --no-plugins to my composer command. Removing that solved my issue with using deployer v6.

set('composer_options', '{{composer_action}} --verbose --prefer-dist --no-progress --no-interaction --no-dev --optimize-autoloader');

Apparently you need plugins for flex to work, and I'm assuming since the scripts block has some commands you need that too. So having no script/plugins will break your installation.

exts
  • 9,788
  • 4
  • 19
  • 21