usethis icon indicating copy to clipboard operation
usethis copied to clipboard

Helper for saving an env var

Open hadley opened this issue 1 month ago • 1 comments

In my recent LLM workshop, folks had a hard time following by instructions to add environment variables to .Renviron. This is possible due to my poor instructions, but I think it would be useful to have a helper that could add a new value. The signature would look something like like use_env_var("API_KEY") and the value would be captured using {askpass} or similar.

This would mainly be aimed at people who don't have a lot in the env var (e.g. in my workshop I didn't see anyone with an existing .Renviron) so would need relatively little intelligence. I I think it would be reasonable to start by just appending a newNAME=value line at the bottom of the file.

hadley avatar Nov 26 '25 08:11 hadley

I like this idea a lot! It might also be useful to have an open argument that defaults to TRUE (which just calls edit_r_environ()) to nudge people into understanding the process a bit better.

ateucher avatar Nov 26 '25 18:11 ateucher