I added phpdotenv in e0402cbb, however, running composer run robo reports an error Unable to read the environment file at /app/.env. when the file doesnt exist. Full stack trace below.
Proposed solution
Either:
only call Dotenv::load() if the .env file exists.
silently catch the InvalidPathException by wrapping the call to Dotenv::load() in an empty try {} catch (InvalidPathException $e) {}
@balintk I consider option 2 to be more clean, but do you have a preference on which solution to implement?
Marking this as a blocker because its preventing me from using or testing on Platform.sh, where we have limited abilities to customize the environment without writing extra deploy steps.
Stack trace
web@project-master-code--projectname:~$ composer run spark
> SPARK_WORKDIR=`pwd` robo --ansi --load-from vendor/bluesparklabs/spark
PHP Fatal error: Uncaught Dotenv\Exception\InvalidPathException: Unable to read the environment file at /app/.env. in /app/vendor/vlucas/phpdotenv/src/Loader.php:105
Stack trace:
#0 /app/vendor/vlucas/phpdotenv/src/Loader.php(82): Dotenv\Loader->ensureFileIsReadable()
#1 /app/vendor/vlucas/phpdotenv/src/Dotenv.php(106): Dotenv\Loader->load()
#2 /app/vendor/vlucas/phpdotenv/src/Dotenv.php(50): Dotenv\Dotenv->loadData()
#3 /app/vendor/bluesparklabs/spark/src/Robo/Tasks.php(40): Dotenv\Dotenv->load()
#4 /app/vendor/bluesparklabs/spark/src/Robo/Plugin/Commands/ContainerCommands.php(13): BluesparkLabs\Spark\Robo\Tasks->__construct()
#5 [internal function]: BluesparkLabs\Spark\Robo\Plugin\Commands\ContainerCommands->__construct()
#6 /app/vendor/league/container/src/Definition/ClassDefinition.php(47): ReflectionClass->newInstanceArgs(Array)
#7 /app/vendor/league/container/src/Container.php(290): League\Container\Definition\ClassDefinition->build()
#8 /app/vendor/league/container/src/Container.php(85): League\Container\Container->get in /app/vendor/vlucas/phpdotenv/src/Loader.php on line 105
Fatal error: Uncaught Dotenv\Exception\InvalidPathException: Unable to read the environment file at /app/.env. in /app/vendor/vlucas/phpdotenv/src/Loader.php:105
Stack trace:
#0 /app/vendor/vlucas/phpdotenv/src/Loader.php(82): Dotenv\Loader->ensureFileIsReadable()
#1 /app/vendor/vlucas/phpdotenv/src/Dotenv.php(106): Dotenv\Loader->load()
#2 /app/vendor/vlucas/phpdotenv/src/Dotenv.php(50): Dotenv\Dotenv->loadData()
#3 /app/vendor/bluesparklabs/spark/src/Robo/Tasks.php(40): Dotenv\Dotenv->load()
#4 /app/vendor/bluesparklabs/spark/src/Robo/Plugin/Commands/ContainerCommands.php(13): BluesparkLabs\Spark\Robo\Tasks->__construct()
#5 [internal function]: BluesparkLabs\Spark\Robo\Plugin\Commands\ContainerCommands->__construct()
#6 /app/vendor/league/container/src/Definition/ClassDefinition.php(47): ReflectionClass->newInstanceArgs(Array)
#7 /app/vendor/league/container/src/Container.php(290): League\Container\Definition\ClassDefinition->build()
#8 /app/vendor/league/container/src/Container.php(85): League\Container\Container->get in /app/vendor/vlucas/phpdotenv/src/Loader.php on line 105
ERROR: Uncaught Dotenv\Exception\InvalidPathException: Unable to read the environment file at /app/.env. in /app/vendor/vlucas/phpdotenv/src/Loader.php:105
Stack trace:
#0 /app/vendor/vlucas/phpdotenv/src/Loader.php(82): Dotenv\Loader->ensureFileIsReadable()
#1 /app/vendor/vlucas/phpdotenv/src/Dotenv.php(106): Dotenv\Loader->load()
#2 /app/vendor/vlucas/phpdotenv/src/Dotenv.php(50): Dotenv\Dotenv->loadData()
#3 /app/vendor/bluesparklabs/spark/src/Robo/Tasks.php(40): Dotenv\Dotenv->load()
#4 /app/vendor/bluesparklabs/spark/src/Robo/Plugin/Commands/ContainerCommands.php(13): BluesparkLabs\Spark\Robo\Tasks->__construct()
#5 [internal function]: BluesparkLabs\Spark\Robo\Plugin\Commands\ContainerCommands->__construct()
#6 /app/vendor/league/container/src/Definition/ClassDefinition.php(47): ReflectionClass->newInstanceArgs(Array)
#7 /app/vendor/league/container/src/Container.php(290): League\Container\Definition\ClassDefinition->build()
#8 /app/vendor/league/container/src/Container.php(85): League\Container\Container->get
in /app/vendor/vlucas/phpdotenv/src/Loader.php:105
I added phpdotenv in e0402cbb, however, running
composer run robo
reports an errorUnable to read the environment file at /app/.env.
when the file doesnt exist. Full stack trace below.Proposed solution
Either:
Dotenv::load()
if the.env
file exists.InvalidPathException
by wrapping the call toDotenv::load()
in an emptytry {} catch (InvalidPathException $e) {}
@balintk I consider option 2 to be more clean, but do you have a preference on which solution to implement?
Marking this as a blocker because its preventing me from using or testing on Platform.sh, where we have limited abilities to customize the environment without writing extra deploy steps.
Stack trace