Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

7
  • 1
    You'd run just FOO=BAR to make it available as a shell variable in the "main" shell instance, or export FOO=BAR to make it available in that shell and in the environment of processes started from it. I'm not exactly at all sure why you'd run another shell here? Commented May 10, 2022 at 20:14
  • I am trying to inject HashiCorp Vault secrets into a Pod's container environnement variables. In order to do so, all the secrets are written in a file in the following format export SECRET_NAME=SECRET_VALUE so that the container can rus the command bash -c 'source /path/to/file' && npm start and. Yet none of the secrets I set in this script are available in any shell I start on the container later on. Commented May 10, 2022 at 20:21
  • 1
    if you run bash -c 'source /path/to/file' && npm start' the env vars set by the sourced script should be available to npm there. But there's no "global" environment where env vars would be set: they're only inherited to child processes, not to the parent, to to siblings. Commented May 10, 2022 at 20:28
  • Note sure if there's more to your specific case, but in general, this is basically just a duplicate of Is it possible to pass environment variables from child to parent in user space? Commented May 10, 2022 at 20:31
  • I believe so to, yet when I try to read any of the previously set environment variables in the Nodejs application launched by npm start using process.env.VAR_NAME, the variable is undefined. I am very confused that this does not work given that I am doing the very same thing described in this example: vaultproject.io/docs/platform/k8s/injector/… Commented May 10, 2022 at 20:50