-
-
Notifications
You must be signed in to change notification settings - Fork 975
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
file.path("", "../path/file") and intermediates_dir make Rmarkdown create <intermediates_dir>/../path/file #2538
Comments
To clarify the context, why do you need to set the intermediates_dir to a different folder using absolute path ? This is not an expected usage and I would like to understand it better. Playing with path in rmarkdown is known to have side effect and usually is discouraged. It is there for advanced usage in specific case. pythonpath <- file.path("", "../py312/bin/python3.12") What is it used for example? Is this something used inside your My guess is that it is used somehow in your process, and it will be made relative to intermediates dir. This means that at some point the error will be
because you don't have the access right to create a new But I don't know why this is trying to create a directory - as I don't know what Anyhow, please to clarify the usage you have, and share a reproducible example. Thanks ! |
Thank you
Thank you, sir. I need the pythonpath to be used in reticulate::use_python(python = pythonpath) to call python in my Rmarkdown. But reticulate should be irrelavant to this probem because the error appears with only the two lines of code here.
By the way, I originally use this.path() package and dirname() of R to get the path of my Rmd file, say /home/user/project/tools/run.Rmd, and then I use
I use "../py312/bin/python3.12" with the prefix "../" because run.Rmd is in a directory (tools) which has the same parent directory as that of py312. In other words, the full path of python3.12 is /home/user/project/py312/bin/python3.12. Then I run
Here, /home/user/project/test contains my data files. I want to keep all intermediate files in the sam folder as my datafile to avoid permission issues for multi-user cases. Then I find that rmarkdown::render and file.path will do some evil things to intermediates_dir/../py312/bin/python3.12. After the rendering is done, my python excutable "intermediates_dir/../py312/bin/python3.12" will be deleted. Then I try to change intermediates_dir to "/home/user", I got the following error
So I guess rmarkdown::render and file.path tries to create a file, which is determined by the second parameter in file.path("/home/user/project/tools/run.Rmd", "../py312/bin/python3.12"). That is "../py312/bin/python3.12". Since the intermediates_dir = "/home/user", rmarkdown::render tries to create "/home/user/../py312/bin/python3.12". If intermediates_dir = "/home/user/project/test", this will be "/home/user/project/test/../py312/bin/python3.12". So my python excutable /home/user/project/py312/bin/python3.12 is replaced by the newly created python3.12. When rmarkdown ::render begins to clean intermediate files, it find that /home/user/project/py312/bin/python3.12 is created by itself, so it deletes python3.12. Then I try to replace file.path("/home/user/project/tools", "../py312/bin/python3.12") by file.path("", "../py312/bin/python3.12"), the error continues. This should exclude the problem of this.path() anddirname. Then I try to replace file.path("", "../py312/bin/python3.12") by file.path("", "py312/bin/python3.12"). This time, the error disappears. So the minimal code to cause problem is just the above two lines
In my project, I have avoid to use file.path. But rmarkdown::render with intermediates_dir and file.path("", "../py312/bin/python3.12") would try to create a file. I think this should be something unexpected. |
Checklist
When filing a bug report, please check the boxes below to confirm that you have provided us with the information we need. Have you:
formatted your issue so it is easier for us to read?
included a minimal, self-contained, and reproducible example?
pasted the output from
xfun::session_info('rmarkdown')
in your issue?upgraded all your packages to their latest versions (including your versions of R, the RStudio IDE, and relevant R packages)?
installed and tested your bug with the development version of the rmarkdown package using
remotes::install_github("rstudio/rmarkdown")
?My rmd file is
When I excute it, R report the error:
Warning messages:
1: In dir.create(dirname(dest), recursive = TRUE) :
cannot create dir '/home/user/../py312', reason 'Permission denied'
2: In file.create(to[okay]) :
cannot create file '/home/user/../py312/bin/python3.12', reason 'No such file or directory'
Seems that use "../" ("../py312/bin/python3.12") in file.path with intermediates_dir confuse Rmarkdown.
This error disappears when I remove the option intermediates_dir = "/home/user" or when I remove "../" from "../py312/bin/python3.12" in file.path
The text was updated successfully, but these errors were encountered: