question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Name resolution stop working when I set `path` and `basePath` options

See original GitHub issue

I configured this plugin in serverless.yml as below:

custom:
  dotenv:
      basePath: config
      path: config/.env

I have some env files under config directory:

config/.env
config/.env.joey

when I deploy with a stage name joey, e.g. sls deploy --stage joey, it still loads file config.env. It doesn’t look at config.env.joey. The output is always:

Serverless: DOTENV: Loading environment variables from config/.env:

If I remove the option basePath and path from serverless.yml file and put these env files in the default location which is ./. Everything works fine. Could you support automatic name resolution with customised path?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
pflugs30commented, Apr 2, 2021

One comment about the basePath option. I configured my serverless.yml file to load from a folder containing all my env files, but the plugin consistently couldn’t find them or resolve the environment names. I resolved the problem when I added a trailing ‘/’ character to the property, like this:

  dotenv:
    basePath: env/

Note: I am developing on Windows 10 with Visual Studio Code. Perhaps other people may have different results on different platforms? Otherwise, perhaps this line should use some kind of environment specific path combine function?

1reaction
aldex32commented, Feb 11, 2021

Nevermind, basePath is the way to go.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Resolve absolute path from relative path and/or file name
You can just add a base path: SET FilePath=%CD%\%1 so that it could be like C:\Foo\Bar\..\..\some\other\dir\file.txt . Programs seem to understand such a ......
Read more >
Import Path Resolution — Solidity 0.8.17 documentation
When a source unit name is passed to the loader, it prepends the base path to it and performs a filesystem lookup. If...
Read more >
How to define base url in swashbuckle 5.0 within asp.net core ...
I am using asp.net core 3.1 with swashbuckle 5. I am not able tofind the way for defining base url. RootUrl option seem...
Read more >
Documentation - Module Resolution - TypeScript
A non-relative import can be resolved relative to baseUrl , or through path mapping, which we'll cover below. They can also resolve to...
Read more >
File path formats on Windows systems | Microsoft Learn
In this article, learn about file path formats on Windows systems, such as traditional DOS paths, DOS device paths, and universal naming ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found