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

Cannot change existing environment variable #731

Open
mischajonker opened this issue Jan 21, 2025 · 3 comments
Open

Cannot change existing environment variable #731

mischajonker opened this issue Jan 21, 2025 · 3 comments
Labels

Comments

@mischajonker
Copy link

Once an environment variable already exists, we cannot override it anymore.

.env file:

TEST=foo

Script executed in runme.dev:

export TEST=bar
echo ${TEST}
export TEST_2=foo
export TEST_2=bar
echo ${TEST_2}

Expected result:

bar
bar

Actual result:

foo
bar

A similar situation happens when sourcing another script that sets environment variables. These environment variables can also not be overridden.

@jlewi
Copy link
Contributor

jlewi commented Jan 25, 2025

@mischajonker Is this the same issue as #653 ? That issue has a long discussion on environment variable behavior.

@mischajonker
Copy link
Author

Thank you @jlewi . Yes, it seems to be the same issue indeed.

It looks like the proposed shell option in #653 would solve it for my use case.

The current behavior with promptEnv=no is a bit counterintuitive (at least for me), because it only allows setting an environment variable once; I think a new switch is being proposed that would separate the prompt from the "do not allow updating environment variable" behavior, but I can't entirely parse what is being proposed in the ticket.

@sourishkrout
Copy link
Contributor

Please find the response/discussion here: #653 (comment)

sourishkrout added a commit that referenced this issue Mar 13, 2025
…d docs-mode) (#761)

In a nutshell, this PR introduces different strategies to retain
environment variables. This option will allow to make available a user
setting that sets it's value according to the use case. The problem is
that Runme's user base has different use cases that roughly break down
into these two:

### 1. "Docs Mode"
Existing runbooks/notebooks/markdown with placeholder values, e.g.,
export OPEN_API_KEY=[insert super secret key]. Once a value is
set/confirmed by a user prompt, don't ask/evaluate again (unless
overwritten promptEnv requires it in cell/document config). Essentially,
the **first** value resolved for a variable is retained, and subsequent
reassignments are ignored.

### 2. "Shell Mode"
Take exported environment variables as is, aka "shell script" style.
e.g. export MY_VAR=foo followed by export MY_VAR=bar, the last
ran/evaluated value wins. When reassigned, subsequently the **last**
value assigned is retained.

### Protobuf Changes
This PR introduces `Retention` with values `RetentionFirstRun` and
`RetentionLastRun`. If `RetentionUnspecified` it defaults to
`RetentionFirstRun` which is up for reconsideration in a future major
release.

Related to #731.
Related to
#653 (comment).

---------

Signed-off-by: Sebastian (Tiedtke) Huckleberry <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants