1

When I try to debug Drupal 8 (8.6.11) using Xdebug in VS Code (I'm on Win 10 but I doubt it is relevant in this case) I get the following error:

Exception has occurred. Dotenv\Exception\InvalidPathException: Unable to read the environment file at /app/.env.

The problem is either with VS Code or with Drupal as someone has reported exact same behaviour on High Sierra and they were using Drupal 8.6.10: https://github.com/lando/lando/issues/1501

I did not find anything in drupal docs about the neccessity of creating a .env file to use Xdebug, so I suspect a bug eihter in Drupal 8 or VS Code.

Has someone encountered similar behaviour? Should I file a bug report on Drupal site?

  • It sounds like there is a DotEnv package enabled that is expecting to find a .env file? – Kevin Apr 2 at 11:39
  • @Kevin, could you be more specific? I'm new to Drupal and don't know what you are reffering to. – Tommy Apr 2 at 12:05
0

InvalidPathException is an exception related to the vlucas/phpdotenv composer package so this issue isn't related to the Lando & VS Code codebases; it's an issue with your Drupal code base.

You can confirm phpdotenv is a Drupal dependency by looking at your composer.json file and looking at the require section.

The issue is the package dependency isn't finding the /app/.env file in your Lando environment. Confirm that the .env exists in your Lando project root (the same dir as your .lando.yml file).

  • I should have added that I'm using Acquia Dev Desktop and the site is working fine. It is only when I'm trying to use Xdebug in VS Code that the problem is occuring. Why doesn't the bug fire off when using Acquia's setup? As I said earlier I'm new to Drupal, but shouldn't the .env file be loaded only when it exists as I concluded from reading the contents of the dotenv.init.yml file? – Tommy Apr 3 at 11:23
  • I can only speculate since no one can debug your own environment except you. Try following the stack trace for the exception that originally caused that error. – Shawn Conn Apr 3 at 16:15
  • 1
    It turns out that I made a mistake - to anyone who may experience similar strange exceptions: check if in your VS Code when in debug mode under BREAKPOINTS label you don't have the box next to 'Everything' checked - if yes then uncheck it and you should be fine :-) – Tommy May 24 at 13:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.