Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Support for multiple envFile in launch.json #1746

Closed
alexus1024 opened this issue Jun 20, 2018 · 8 comments
Closed

Support for multiple envFile in launch.json #1746

alexus1024 opened this issue Jun 20, 2018 · 8 comments

Comments

@alexus1024
Copy link

There are multiple env files for each environment in my project - one for "public things" such as server addreses and another for "private things" such as passwords. Currently I can pass only one of them with "envFile" attribute.

It would be cool to pass both of them in launch.json somehow.

@ramya-rao-a
Copy link
Contributor

But then, how would you decide which one to use?

@alexus1024
Copy link
Author

They all should be used. Each next file adds its contents to env and rewrite existing variables. So, order is significant.
Same as docker-compose files, for example. https://docs.docker.com/compose/compose-file/#env_file

@ricochet
Copy link

I encountered this. My workflow is usually centered around kicking off a script to start a delve server and then launching my debug config in code. I worked around this by adding to that little script to create a mega-env.

ENV_GEN_FILE=".env_generated"
printf "#\n# Do not edit this file. It is generated!\n#\n" > $ENV_GEN_FILE

# Look for run specific details - first try in $HOME, then override with local
for ENV in $HOME/.env .env
do
    if [ -f $ENV ]; then
        cat $ENV >> $ENV_GEN_FILE
    fi
done

@ramya-rao-a
Copy link
Contributor

ramya-rao-a commented Feb 3, 2019

My apologies @alexus1024, for taking so long to get back to this issue.

So, following the example in https://docs.docker.com/compose/compose-file/#env_file, we can update our support of the envFile attribute to also take in either a string or an array of strings.

PRs are most welcome to add this feature.

Code Pointers:

  • See Build and Debug Extension to set up local dev environment
  • The package.json file needs to be updated to support both string and array of string as valid inputs
  • We currently use parseEnvFile to parse a given env file. We can add a new function parseEnvFiles that can take in an array of paths, and internally use parseEnvFile in the right order
  • Then, update the types for the envFile property in goDebug.ts file and call parseEnvFiles instead of parseEnvFile
  • https://github.com/Microsoft/vscode-go/blob/0.8.0/src/debugAdapter/Readme.md is helpful if you want to debug the goDebug.ts file

@SteelPhase
Copy link
Contributor

@ramya-rao-a could you take a look at #2395 and see if this is what you expected for a solution to this?

@offero
Copy link

offero commented May 19, 2019

Now that I think about it, this should be contributed in a place where it can be used from multiple launch configurations such as node also. Wherever envFile is supported.

@jcbit
Copy link

jcbit commented Dec 20, 2019

I agree, I am working with node and looking for a way to use multiple envfiles

@ramya-rao-a
Copy link
Contributor

The latest version (0.13.0) of this extension has this feature

Thanks for the PR @SteelPhase and Thanks for reporting @alexus1024 !

Happy Coding!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants