Closed hadley closed 8 years ago
@yihui will know for sure, but I think this might be an artifact of running the knit of each chapter in it's own session (so temp directories disappear after the chapter is knit).
On Fri, Feb 12, 2016 at 7:11 AM, Hadley Wickham notifications@github.com wrote:
bookdown::render_book("index.rmd")#> Error: path for html_dependency not found: /tmp/RtmpO4fv0m/widgetbindingcb3263a9aa9f
traceback()#> 10: stop("path for html_dependency not found: ", list$src$file, call. = FALSE) at html_dependencies.R#141#> 9: FUN(X[[i]], ...) at html_dependencies.R#128#> 8: lapply(dependencies, validate_html_dependency) at html_dependencies.R#93#> 7: dependency_resolver(all_dependencies) at html_extras.R#13#> 6: html_extras_for_document(knit_meta, runtime, dependency_resolver, #> format_deps) at html_document_base.R#92#> 5: base(...) at output_format.R#81#> 4: output_format$pre_processor(yaml_front_matter, utf8_input, runtime, #> knit_meta, files_dir, output_dir) at render.R#387#> 3: rmarkdown::render(main, output_format, ..., clean = clean, envir = envir, #> run_pandoc = TRUE, knit_meta = knit_meta) at render.R#129#> 2: render_new_session(files, main, force_knit, output_format, clean, #> envir, ...) at render.R#86#> 1: bookdown::render_book("index.rmd")
Any ideas?
— Reply to this email directly or view it on GitHub https://github.com/rstudio/bookdown/issues/15.
Right. That is also a problem I wanted to solve with https://github.com/ramnathv/htmlwidgets/pull/183 so please merge it before the next release of htmlwidgets.
Okay, I will definitely merge that before the next release of htmlwidgets
On Friday, February 12, 2016, Yihui Xie notifications@github.com wrote:
Right. That is also a problem I wanted to solve with ramnathv/htmlwidgets#183 https://github.com/ramnathv/htmlwidgets/pull/183 so please merge it before the next release of htmlwidgets.
— Reply to this email directly or view it on GitHub https://github.com/rstudio/bookdown/issues/15#issuecomment-183436088.
For now, I'll just install htmlwidgets from that branch.
@yihui do you know about the remotes field that devtools now supports? You can use it to specify that bookdown should install from specified github repos/branches/pull requests.
Ok - I installed from the branch, deleted all the caches I could find (including _main.rds
) but I'm still getting the same error
Hmm, that is weird. Were you testing it on the r4ds book? Could you email me _main.rds
?
Yeah - if you check out http://github.com/hadley/r4ds and then bookdown::render_book("index.rmd")
you should be able to recreate the problem. I'll email you the rds.
Sorry I should have mentioned that both my htmlwidgets branch and the development version of htmltools are required. I just added Remotes
in DESCRIPTION.
Ah got it - thanks!
The problem emerge again when I first build the book under Windows and then build the book under Ubuntu. I fixed it by deleting the _bookdown_files
dir. I think there is something wrong with cache verification. Though most people would probably not do the similar thing, it's would be nice if you can add some check. @yihui
I think the problem would also occur when someone install a new version of R, thus change the location of installed R packages.
the error message is
Error: path for html_dependency not found: W:/program/lib/R/htmlwidgets/ww
wherein W:/program/lib/R
is where I put my R packages on Windows. And I get the error when I want to rebuild the book on Ubuntu (with new_session=T
)
Not to bump something that may be considered solved, but this issue just happened to me using R Markdown knitting when I had rsync'd a directory of work from one machine to another. Had to delete the _cache and _files directories, then it worked fine. Wasn't a terribly informative error, but Google led me here, so it's all good. :)
just bumped into this problem as well
packageVersion("rmdformats") [1] '0.3.4' packageVersion("rmarkdown") [1] '1.9' packageVersion("htmlwidgets") [1] '0.9'
I have tried to delete the cache folder but it did not help
You need to provide minimal information for reproducing the problem if you want others to help you.
Create a GitHub repo might be a good idea. GitHub issue also support uploading files now.
For what it's worth, I just hit this problem building our book Geocomputation with R in a docker container. Confirmed: after running this bash command the book compiled fine:
rm -rv _bookdown_files
Heads-up @yihui I'm sorry to say that this issue has raised its head with vengeance for me. The previous solution of removing the cache no longer fixes the issue I'm afraid...
Reproducible example:
git clone git@github.com:robinlovelace/geocompr
cd geocompr
make html
Generates this (when all geo dependencies are installed):
output file: references.knit.md
List of 10
$ name : chr "leaflet-providers"
$ version : chr "1.9.0"
$ src :List of 1
..$ file: chr "/tmp/RtmprIInyg"
$ meta : NULL
$ script : chr "leaflet-providers_1.9.0.js"
$ stylesheet: NULL
$ head : NULL
$ attachment: NULL
$ package : NULL
$ all_files : logi FALSE
- attr(*, "class")= chr "html_dependency"
Error: path for html_dependency not found: /tmp/RtmprIInyg
Execution halted
makefile:2: recipe for target 'html' failed
make: *** [html] Error 1
@Robinlovelace Do you have a minimal reproducible example? I'm afraid it will be difficult to debug the issue if the example is a whole book project...
Where is installed the package on your environment?
Xavier Faure-Miller
From: Yihui Xie notifications@github.com Sent: Monday, January 13, 2020 3:41:46 AM To: rstudio/bookdown bookdown@noreply.github.com Cc: Xavier Faure-Miller Xavier.Faure-Miller@ldc.com; Comment comment@noreply.github.com Subject: Re: [rstudio/bookdown] html_dependency problem (#15)
WARNING Message originated from outside of our organization.
@Robinlovelacehttps://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FRobinlovelace&data=02%7C01%7CXavier.Faure-Miller%40ldc.com%7C766ef4f54f294c782b1608d797977660%7C40a64d0bf2f94a34b1b30992ac0e5e4e%7C1%7C0%7C637144549102880533&sdata=NXv8hP3AdeLkJ7pvbdU8jZIpT8K7d5%2FnDJGvTLggHIo%3D&reserved=0 Do you have a minimal reproducible example? I'm afraid it will be difficult to debug the issue if the example is a whole book project...
— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Frstudio%2Fbookdown%2Fissues%2F15%3Femail_source%3Dnotifications%26email_token%3DAFQK56NMHKFJU3OC2MMHFXTQ5NW7VA5CNFSM4B3D52L2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIXCMKY%23issuecomment-573449771&data=02%7C01%7CXavier.Faure-Miller%40ldc.com%7C766ef4f54f294c782b1608d797977660%7C40a64d0bf2f94a34b1b30992ac0e5e4e%7C1%7C0%7C637144549102880533&sdata=ndt07R8juDJZUBrjj%2B%2BSeW%2BGpZdjKDEd5KZV2dfX2HQ%3D&reserved=0, or unsubscribehttps://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAFQK56MD2ATMWXWRFGACNRDQ5NW7VANCNFSM4B3D52LQ&data=02%7C01%7CXavier.Faure-Miller%40ldc.com%7C766ef4f54f294c782b1608d797977660%7C40a64d0bf2f94a34b1b30992ac0e5e4e%7C1%7C0%7C637144549102890492&sdata=bOz1wkNgNnwAOZRbE4Biii1pFYHNDNam6IVjn7WS7HY%3D&reserved=0.
CONFIDENTIAL This message and any attachments (the "Message") are confidential and intended solely for the addressee(s). If you are not the intended recipient, any use, copying or dissemination is strictly prohibited. If you are not the intended recipient, please notify the sender immediately by return and delete this original Message and any copies from your system. E-mails are susceptible to alteration. Louis Dreyfus Company BV and its subsidiaries and other affiliates shall not be liable if the Message is altered, changed or falsified.
This is an environment friendly email. Please do not print it unless it is really necessary.
Agreed. this is the basis of a minimal reproducible example:
git clone git@github.com:rstudio/bookdown-demo
bookdown-demo
Rscript -e 'bookdown::render_book("index.Rmd")'
Then replace the contents of 02-literature.Rmd
with this:
# Test leaflet
```{r}
remotes::install_github("rstudio/leaflet")
remotes::install_github("rstudio/bookdown")
remotes::install_github("nowosad/spData")
remotes::install_github("mtennekes/tmap")
library(leaflet)
leaflet() %>%
addPolygons(data = spData::lnd)
library(tmap)
tmap_mode("view")
tm_shape(spData::lnd) + tm_polygons()
Unfortunately that doesn't reproduce the issue, but is a step towards a minimal reproducible example I think, guess it's a clash between leaflet JS versions needed by different mapping packages. Any ideas @nowosad? Many thanks for quick replies by the way!
But I can reproduce the example in the book. It seems a file needed for htmltools
cannot be found from the error message. Any further ideas on debugging this welcome, other than replacing chapters section-by-section...
https://github.com/rstudio/rmarkdown/blob/master/R/html_dependencies.R#L234
Heads-up @yihui, I've found a reproducible example, BINGO! It's when you build the book with new_session
enabled.
Please try the following
git clone git@github.com:rstudio/bookdown-demo
bookdown-demo
Rscript -e 'bookdown::render_book("index.Rmd")'
and add this to 02-literature.Rmd
:
```{r}
library(leaflet)
popup = c("Robin", "Jakub", "Jannes")
leaflet() %>%
addProviderTiles("NASAGIBS.ViirsEarthAtNight2012") %>%
addMarkers(lng = c(-3, 23, 11),
lat = c(52, 53, 49),
popup = popup)
That should reproduce it.
Then run:
Rscript -e 'bookdown::render_book("index.Rmd", output_format = "bookdown::gitbook", clean = FALSE, new_session = TRUE)'
So it builds the 'M-K' way: https://bookdown.org/yihui/bookdown/new-session.html
@Robinlovelace After some investigation, I'm afraid that leaflet::addProviderTiles()
cannot work with the K-M method of bookdown. The reason is that leaflet writes the HTML dependency to the tempdir()
, which will be deleted after the R session quits. In the new_session: true
mode, each Rmd is knitted in a separate R session; when that session quits, its tempdir()
is deleted. Then rmarkdown can no longer find the HTML dependency. Relevant code here:
If the leaflet authors can stabilize this HTML dependency (like other dependencies, of which the paths are R package paths instead of temp paths), your problem will go away.
Or use the default M-K method...
Many thanks for the investigations @yihui. I did also try the M-K method on the entire book (see https://github.com/Robinlovelace/geocompr/pull/461/files ) and, for some unknown reason to my surprise, aslo got the same error message. I think your solution, to stabilize the HTML dependency, sounds reasonable. Any ideas how I would start exploring options for implementing that in code?
Many thanks again.
@Robinlovelace The minimal example above works fine with the M-K method. The PR you mentioned failed with a different reason: https://travis-ci.org/Robinlovelace/geocompr/builds/636229884
You have to talk to leaflet authors on stabilizing the path of the leaflet-providers
dependency. I don't really know if this is possible, or why it uses a temp path (there must be a reason for this unusual treatment).
Thanks Yihui. The fail with the M-K method I mentioned happened on my local computer, not Travis. In any case it sounds like this is not a problem in bookdown. Worth me raising this issue here?: https://github.com/rstudio/leaflet/issues
@Robinlovelace I'm unable to reproduce the issue locally with the M-K method.
@Robinlovelace i was having a similar issue with leaflet in our GIS practical book, the M-K method wasn't working as well. Not sure what happened but looks like htmltools and htmlwidgets weren't loaded. Seems to have solved my issue.
Great, thanks for sharing @andrewmaclachlan
@andrewmaclachlan @Robinlovelace Sorry I don't understand your solution. How did you solve? I am having the same problem with leaflet + blogdown.
I already installed the latest leaflet version from Github and also loaded htmlwidgets and htmltools.
I actually now think it's an issue with caching. For all the code chunks that used leaflet i turned caching to FALSE and now the book builds locally using the M-K method. @Robinlovelace has essentially saved his maps and then loaded them again to avoid the issue, you can see his fix here: https://github.com/Robinlovelace/geocompr/pull/465/files. This is for bookdown though, i'm not as familiar with blogdown.
@andrewmaclachlan THanks indeed I had opts_chunk$set(cache = T)
at the beginning of my Rmd.
Solution was to set false
knitr::opts_chunk$set(cache = F)
Hi @mgei @andrewmaclachlan I am coming up with the same issue building a bookdown book of multiple .rmds, one of which contains mapview functions. I've set cache = F at the beginning of the respective .rmd, but am still getting the same error. I have also tried setting cache = F in each seperate .rmd, or merging all chunks together into one .rmd file, but am getting the same error each time. So far I could only build the book, when removing the respective mapview code. If I knit the same .rmd with rmarkdown as a html document, it does work with or without cache = F ... Any suggestions?
Hi @BennyWag ! As this issue is pretty old and the discussion pretty long, I think it would be benificial to ask the question from start with your issue; Can you open a new issue with a detail example of your use case, or a question in RStudio Community so that it is easier to help ? You can link to this one for context. Thanks !
Hi @cderv, sure I will do that. Will need to get together a reproducible example first.
Hi @BennyWag
Have you tried:
Otherwise put a reproducible example up and i'll help if i can.
In my case it works leaving knitr::opts_chunk$set(cache = TRUE), but knitting from outside Rstudio in a fresh session of Rgui.exe: rmarkdown::render("MRI_700.Rmd", "html_document").
This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary.
Any ideas?