Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
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

Usage instructions for with_tempdir is unclear #259

Open
jfunction opened this issue May 24, 2024 · 1 comment
Open

Usage instructions for with_tempdir is unclear #259

jfunction opened this issue May 24, 2024 · 1 comment

Comments

@jfunction
Copy link

I'm not sure how to reference the temporary directory within the code and the documentation is not helping me understand that. Does the code execute in an environment where the working directory is the tempdir, is there a special variable name (eg path) which references the tempdir that is created, or something else? Looking at the code it creates the tempfile and leverages with_dir so maybe this should be referred to in the documentation?

@MLopez-Ibanez
Copy link
Contributor

I believe you are correct: with_tempdir() changes the working directory to the created directory, however local_tempdir() doesn't. Both should do the same. Also, the documentation should document this behavior.

> withr::with_tempdir(getwd())
[1] "/tmp/Rtmpioxj34/file1f35521d2f647"
> local({ withr::local_tempdir(); getwd()})
[1] "/home/manu"

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

No branches or pull requests

2 participants