Comments (9)
That would be very fragile, as it is not clean what versions of what platforms need which env vars.
It would also be a breaking change, as existing code might rely on the inheritance of environment variables.
Nevertheless, if you want to do that, you can, by setting (nearly?) all existing env vars to NA
.
from callr.
So if one wants to do that manually, they just wrap callr
with a variant of the set(temporary); callr(...); set(previous)
dance?
from callr.
No, you can use the env
argument:
❯ Sys.setenv("FOO" = "bar")
❯ callr::r(function() Sys.getenv("FOO"))
[1] "bar"
❯ callr::r(function() Sys.getenv("FOO"), env = c(FOO = NA_character_))
[1] ""
from callr.
Ah. No, I meant to implement the logic I hinted at in the first post.
from callr.
Yes, if you want to start with a clean environment, set all current env vars to NA
in the env
argument.
from callr.
I guess since both Sys.unsetenv
and callr
's env
parameter require explicit listing of the existing variables to "unset" it is only a question of API stability.
from callr.
No, do not use Sys.unsetenv()
, that's not a good solution. R is single threaded, but occasionally there is a async code execution, e.g. finalizers might be triggered by the garbage collector, and they may use env vars.
Plus, callr's machinery might use env vars as well, so if you unset them before calling callr, then you might change callr's behavior.
from callr.
Good point!
from callr.
A better solution to reset the environment for the subprocess is to exploit a platform-dependent solution like env -i
then.
from callr.
Related Issues (20)
- Upkeep for callr (2023)
- Add alt-text to pictures, plots, etc; see https://posit.co/blog/knitr-fig-alt/ for examples
- Alternative to `arch` argument with `callr` v3.3.2 HOT 2
- r_bg processes hang when waiting for others to spawn HOT 2
- How to detect failure in `r_bg()` ? HOT 1
- Release callr 3.7.4
- please do not run unsigned dll files with random names from temp folder HOT 7
- Release callr 3.7.5
- callr update from CRAN HOT 1
- callr update from CRAN HOT 2
- Rtmp files left in /tmp directory with VSCode HOT 2
- How to use customize functions in the `func` function? HOT 4
- callr update from CRAN HOT 3
- Release callr 3.7.6 HOT 1
- how to get out of session$attach() HOT 5
- Setting different R_HOME for the callr subprocess HOT 1
- r_process subclass shouldn't be cloneable HOT 1
- Spawn background processes across HPC cluster nodes HOT 1
- Use `testthat::with_mock()` instead of mockery
- `r_bg()` don't finished until run `rp$read_error()` and `rp$read_output()`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from callr.