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

Environment variable handling in a crossplatform way #262

Open
matyasf opened this issue Feb 16, 2021 · 10 comments
Open

Environment variable handling in a crossplatform way #262

matyasf opened this issue Feb 16, 2021 · 10 comments

Comments

@matyasf
Copy link

matyasf commented Feb 16, 2021

Environment variables are passed differently in Windows and unix systems, so we cannot write scripts easily that run on both platforms. It would be very nice if concurrently would include such functionality, so we don't need to write horrors like

concurrently "cross-env FIRST_ENV=one my-program arg1" cross-env ANOTHER_ENV=two my--other-program arg3
@milahu
Copy link

milahu commented May 8, 2021

so we don't need to write horrors like

whats so horrific about cross-env KEY=val cmd?
how should concurrently do that better? with --env <key>=<val> arguments ...?

@gustavohenke
Copy link
Member

Keen to hear more thoughts. I'm not too strong either way.

@matyasf
Copy link
Author

matyasf commented Jul 15, 2021

whats so horrific about cross-env KEY=val cmd?

That I need 2 packages (and their zillions of dependencies) just to run 2 executables in parallel properly.

how should concurrently do that better? with --env = arguments ...?

Yep, that would be great, for example:

concurrently "my-program arg1" "my-other-program arg2" --env1=FIRST_ENV=one  --env2=ANOTHER_ENV=two

@kotx
Copy link

kotx commented Sep 7, 2021

Though --env1 and --env2 etc don't seem too elegant, I'm in favor of a feature like this. +1

@milahu
Copy link

milahu commented Sep 7, 2021

this works already

concurrently "cross-env FIRST_ENV=one my-program arg1" cross-env ANOTHER_ENV=two my--other-program arg2

possible solutions

  1. concurrently "my-program arg1" "my-other-program arg2" --env1=FIRST_ENV=one --env2=ANOTHER_ENV=two

  2. concurrently --env=FIRST_ENV=one "my-program arg1" --env=ANOTHER_ENV=two "my-other-program arg2"

  3. concurrently --parse-env "FIRST_ENV=one my-program arg1" "ANOTHER_ENV=two my--other-program arg2"

  4. concurrently "FIRST_ENV=one my-program arg1" "ANOTHER_ENV=two my--other-program arg2"

@kotx
Copy link

kotx commented Sep 7, 2021

I'd prefer 2nd option, the 3rd and 4th could likely break or produce unintended behavior.

@milahu
Copy link

milahu commented Sep 7, 2021

we can implement both 2 and 3 with backward compatibility (default is --no-parse-env)

@matyasf
Copy link
Author

matyasf commented Sep 20, 2021

cross-env is no longer developed anymore. Is it OK if I try to submit a PR for this issue?

@gustavohenke
Copy link
Member

I'd be open to see a PR for this, but i prefer to see it implemented initially via a --env flag that passes the vars to every command.

Parsing env vars from each input is probably too much at this stage and requires a lot more thought.
E.g. should this work? concurrently "SOME_VAR=1 npm:watch"

Interleaving commands and flags should probably also be out of the initial scope, e.g. concurrently "echo bla" --env SOME_VAR=1 "echo hello".

@atomkirk
Copy link

are you open to a PR that lets us pass a .env file? Is there a reason not to have concurrently look for and load a .env automatically?

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

No branches or pull requests

6 participants