symfony: error on install --no-dev --optimize-autoloader, cache-clear

Symfony version(s) affected: 4.2.1

Description
When preparing for deployment, running composer install --no-dev --optimize-autoloader will throw error: Script cache:clear returned with error code 255 if "symfony/dotenv": "^4.0" is NOT on the required section of composer.json.

I do not plan to use .env on production and I am already running into issues on the production environment that may, or may not, be related to this.

There, on the production environment, I have added the env variables to index.php and deleted the .env files.

How to reproduce
Below is the code for composer.json BEFORE moving dotenv to require. Otherwise, APP-ENV=prod on .env. Of course, should run composer install --no-dev --optimize-autoloader.

     "type": "project",
"license": "proprietary",
"require": {
    "php": "^7.2.1",
    "ext-iconv": "*",
    "beberlei/DoctrineExtensions": "^1.1",
    "doctrine/doctrine-migrations-bundle": "^1.3",
    "friendsofsymfony/user-bundle": "^2.1",
    "sensio/framework-extra-bundle": "^5.1",
    "stof/doctrine-extensions-bundle": "^1.3",
    "symfony/asset": "^4.0",
    "symfony/console": "^4.0",
    "symfony/debug-pack": "*",
    "symfony/expression-language": "^4.0",
    "symfony/flex": "^1.0",
    "symfony/form": "^4.0",
    "symfony/framework-bundle": "^4.0",
    "symfony/monolog-bundle": "^3.1",
    "symfony/orm-pack": "^1.0",
    "symfony/process": "^4.0",
    "symfony/security-bundle": "^4.0",
    "symfony/serializer-pack": "*",
    "symfony/swiftmailer-bundle": "^3.1",
    "symfony/translation": "^4.0",
    "symfony/twig-bundle": "^4.0",
    "symfony/validator": "^4.0",
    "symfony/web-link": "^4.0",
    "symfony/yaml": "^4.0"
},
"require-dev": {
    "symfony/browser-kit": "^4.0",
    "symfony/css-selector": "^4.0",
    "symfony/maker-bundle": "^1.5",
    "symfony/phpunit-bridge": "^4.0",
    "symfony/profiler-pack": "*",
    "symfony/web-server-bundle": "^4.0",
    "symfony/dotenv": "^4.0"
},
"config": {
    "preferred-install": {
        "*": "dist"
    },
    "sort-packages": true
},
"autoload": {
    "psr-4": {
        "App\\": "src/"
    }
},
"autoload-dev": {
    "psr-4": {
        "App\\Tests\\": "tests/"
    }
},
"replace": {
    "symfony/polyfill-iconv": "*",
    "symfony/polyfill-php71": "*",
    "symfony/polyfill-php70": "*",
    "symfony/polyfill-php56": "*"
},
"scripts": {
    "auto-scripts": {
        "cache:clear": "symfony-cmd",
        "assets:install --symlink --relative %PUBLIC_DIR%": "symfony-cmd"
    },
    "post-install-cmd": [
        "@auto-scripts"
    ],
    "post-update-cmd": [
        "@auto-scripts"
    ]
},
"conflict": {
    "symfony/symfony": "*"
},
"extra": {
    "symfony": {
        "id": "01C7GQTT5A95EBYYFAVQ47GFDB",
        "allow-contrib": false
    }
}

}

Possible Solution

Additional context

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 15 (8 by maintainers)

Most upvoted comments

It honestly is not clear for me: The documentation states that the use of Dotenv is discourage in production. Which seems logical given that it would require me to place my config variables in the project directory.

Now, it seems like we need Dotenv? Where is that change reflected in the documentation?

And if we move it to the require section, will it then ONLY use the ENV vars defined in the files ? Will I still be able to use “real” ENV vars ?

Sorry, but this is all very confusing and not very straight forward …