Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Dotenv] Emebed commands inside .env files makes the application crash  #38201

Copy link
Copy link
Closed
@tristanbes

Description

@tristanbes
Issue body actions

Symfony version(s) affected: 4.4.13

Description
When adding an embed command inside the .env and run the composer dump-env prod, the application crashes:

PHP Fatal error:  Uncaught Error: Call to undefined method Symfony\Component\Process\Process::inheritEnvironmentVariables() in /Users/tbessoussa/workspace/dotenv-reproducer/vendor/symfony/dotenv/Dotenv.php:406
Stack trace:
#0 [internal function]: Symfony\Component\Dotenv\Dotenv->Symfony\Component\Dotenv\{closure}(Array)
#1 /Users/tbessoussa/workspace/dotenv-reproducer/vendor/symfony/dotenv/Dotenv.php(389): preg_replace_callback('/\n            (...', Object(Closure), '$(git rev-parse...')
#2 /Users/tbessoussa/workspace/dotenv-reproducer/vendor/symfony/dotenv/Dotenv.php(320): Symfony\Component\Dotenv\Dotenv->resolveCommands('$(git rev-parse...', Array)
#3 /Users/tbessoussa/workspace/dotenv-reproducer/vendor/symfony/dotenv/Dotenv.php(200): Symfony\Component\Dotenv\Dotenv->lexValue()
#4 /Users/tbessoussa/workspace/dotenv-reproducer/vendor/symfony/dotenv/Dotenv.php(513): Symfony\Component\Dotenv\Dotenv->parse('# In all enviro...', './.env')
#5 /Users/tbessoussa/workspace/dotenv-reproducer/vendor/symfony/dotenv/Dotenv.php(65): Symf in /Users/tbessoussa/workspace/dotenv-reproducer/vendor/symfony/dotenv/Dotenv.php on line 406

Fatal error: Uncaught Error: Call to undefined method Symfony\Component\Process\Process::inheritEnvironmentVariables() in /Users/tbessoussa/workspace/dotenv-reproducer/vendor/symfony/dotenv/Dotenv.php:406
Stack trace:
#0 [internal function]: Symfony\Component\Dotenv\Dotenv->Symfony\Component\Dotenv\{closure}(Array)
#1 /Users/tbessoussa/workspace/dotenv-reproducer/vendor/symfony/dotenv/Dotenv.php(389): preg_replace_callback('/\n            (...', Object(Closure), '$(git rev-parse...')
#2 /Users/tbessoussa/workspace/dotenv-reproducer/vendor/symfony/dotenv/Dotenv.php(320): Symfony\Component\Dotenv\Dotenv->resolveCommands('$(git rev-parse...', Array)
#3 /Users/tbessoussa/workspace/dotenv-reproducer/vendor/symfony/dotenv/Dotenv.php(200): Symfony\Component\Dotenv\Dotenv->lexValue()
#4 /Users/tbessoussa/workspace/dotenv-reproducer/vendor/symfony/dotenv/Dotenv.php(513): Symfony\Component\Dotenv\Dotenv->parse('# In all enviro...', './.env')
#5 /Users/tbessoussa/workspace/dotenv-reproducer/vendor/symfony/dotenv/Dotenv.php(65): Symf in /Users/tbessoussa/workspace/dotenv-reproducer/vendor/symfony/dotenv/Dotenv.php on line 406

How to reproduce
You can use the reproducer here: tristanbes/process-reproducer#1

But you can test by just simply adding SOURCE_VERSION=$(git rev-parse HEAD) inside your .env and running composer dump-env prod you end up with a fatal error.

Additional context

Composer version 1.10.10 2020-08-03 11:35:19
Tested PHP version: 7.4.9, 7.4.10
Tested OS: MacOS with zsh / Debian 10 with zsh 

Also tested and reproduced with Platform.sh

As stated in the documentation, it should be possible doing so
and it was working in previous version of Symfony

The_Dotenv_Component__Symfony_4_3_Docs_

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.