Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"envDirName" does not work ("dotenvDirname" does) #93

Closed
jg-cantaa opened this issue Dec 8, 2021 · 4 comments
Closed

"envDirName" does not work ("dotenvDirname" does) #93

jg-cantaa opened this issue Dec 8, 2021 · 4 comments

Comments

@jg-cantaa
Copy link

The envDirName Setting does not work, although it is the option documented to work everywhere.
VSCode doesn't even recognize the option as valid.
Screenshot_2021-12-08_14-24-52
Screenshot_2021-12-08_14-24-26

@AnWeber
Copy link
Owner

AnWeber commented Dec 8, 2021

I think the cause is the typo in the path of httpyac.envDirName. I search for folder env by default. The search starts from folder of the http file and searches for the following files/ folder upwards (package.json, .httpyac.js, httpyac.config.json, env). However, since envDirName is now overwritten with .spec/env, it cannot find root and read the files. Commenting out envDirName fixes the error and it will find the files again.

@jg-cantaa
Copy link
Author

jg-cantaa commented Dec 10, 2021

So, after doing some experimenting I am still quite confused. Although the issue title does no longer apply, I am still having difficulties getting this to work. So I will try to explain how my current understanding is:

Assuming I have the folder structure

.vscode/
    settings.json
specs/
    api/
        request.http
    env/
        .env.test

  • It searches for the envDirName Folder first in the following places and order:
    • specs/api/<envDirName>
    • specs/<envDirName>
    • <envDirName>
  • If it finds a matching folder, It does not try to continue searching for other matching folders.
  • specifying envDirName with a absolute path will work
  • if the path is not absolute, it seems to have trouble resolving paths with more than one segment (e.g. Specifying envDirName to be test/env only finds environments in the first test folder it finds.)

In all honesty, this seems overly complicated to me, although I might not have the full picture and there might be valid reasons for this. The Documentation in the readme states "relative or absolute path to folder with dotenv files", which from my experimentation does not hold.

Could this be adjusted to reflect the description given in the readme?

AnWeber added a commit to AnWeber/httpyac that referenced this issue Dec 11, 2021
@AnWeber
Copy link
Owner

AnWeber commented Dec 11, 2021

The issue for the root folder determination is #50. Use case is that different environment variables can be set for different requests in the same project. Many Tools like tsc, eslint or Prettier also support such a config search.
And if you use it in the standard way, your example would just work without changing envDirName.

if the path is not absolute, it seems to have trouble resolving paths with more than one segment (e.g. Specifying envDirName to be test/env only finds environments in the first test folder it finds.)

Nested envDirName I have not considered correctly, and overlooked during implementation But I would recommend to just use the default one. I left the setting mainly for absolute file paths to allow cross-project settings or as hidden folder support in Linux.

@AnWeber
Copy link
Owner

AnWeber commented Dec 19, 2021

fix is released with v4.8.2. Thanks:-)

@AnWeber AnWeber closed this as completed Dec 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants