Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This explanation makes me wonder if this might actually be a bug in
quarto_render(). @cderv it's possible that the quarto package should be doing this to ensure that you use the same library as the current R session.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this is what I was trying to get at here #2830 (comment).
I would have expected quarto to use the library path of the session it's being called in. Is there a situation where this shouldn't be the case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, as a general rule, whenever you run code in a new process I think it should inherit the libpaths of the current process.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see now more clearly.
Yes, I think the quarto R package should do that directly. It's using
processx::run(), and I should probably do something likecallr::r()and inherit.libPaths().There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Though I don't see exactly how using
withr::local_libpaths()does change things here. 🤔.libPaths()is retrieved inlib_path.libPaths(lib_path)Isn't it a roundtrip ?
So if
quarto_render()is not getting.libPaths()info in the first place, how does usingwithr::local_libpaths()helps here ?I was thinking I should do something more like
callr::r()when I need to assign the main process.libPaths()to environment variable, so that they are passed to new subprocess.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested with
And then
So the temporary library is not see for Quarto rendering.
I think
R_LIBSneeds to be set so that it works for sub process (that will inherit env var)So I am not this PR does help. I am looking at making the env var setting in quarto R package directly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TLDR I think setting lib path in quarto via
callr::ris the more robust solution.The intended behavior of this PR:
pkgdown::build_site(install = FALSE)is called, the standard library path is used (i.e., what you see above).pkgdown::build_site(install = TRUE)is called, the library is installed in a temporary location in a callr session, so we fetch the temporary lib path, which is prepended to.libPaths()(hence the.libPaths[1]).This was reported to fix the issue, but I could never figure out how to trigger this on GHA, so didn't have a test case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't use callr directly, but I can mimic it. I tried
.libPaths()as R_LIBS to quarto subprocess quarto-dev/quarto-r#228But it did not solve the issue I have in quarto for windows build
So I am still trying to understand.
For pkgdown issue I could not reproduce either yet.
This is what I understood. But then passing it to
withr::local_libpaths()will put this temporary library back in.libPaths(). As shown in example abovequarto_render()will callquartoCLI, which will call R directly and this.libPaths()from initial R session will not be passed to it.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok I got it to reproduce locally now, and I can check that quarto-dev/quarto-r#228 solves it.
I use your repo as an example: https://github.com/jayhesselberth/pkgdown.quarto.issue in a fork. This PR does not solve the problem for me.
I just found another issue from
pkgdown/R/build-quarto-articles.R
Lines 47 to 50 in 7645a47
articles\test-article.qmdis built in<temp>\pkgdown-quarto-<hash>\articles\test-article.html, but path check above is<temp>\pkgdown-quarto-<hash>\test-article.htmlwhich does not exists.I'll open a new issue about this.