BluesparkLabs / spark

✨ Toolkit to develop, test and run Drupal websites.
MIT License
2 stars 1 forks source link

.env file should be optional #19

Closed jameswilson closed 6 years ago

jameswilson commented 6 years ago

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:

@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
jameswilson commented 6 years ago

@balintk PR #21 should solve this, would appreciate a review/merge at earliest convenience.