Closed bagasbgy closed 5 years ago
Here is the first step for debugging: make a copy of your website project (i.e. make a backup), delete all Rmd files (file.remove(list.files(, '[.]Rmd$', recursive = TRUE, full.names = TRUE))
), and blogdown::serve_site()
. If the error disappears, there must be something wrong in a certain Rmd, and blogdown is unlikely to be the culprit.
Thanks @yihui for the suggestion, but already tried it, still, had no luck:
03:29:04 > file.remove(list.files(, '[.]Rmd$', recursive = TRUE, full.names = TRUE))
[1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
03:29:06 > blogdown::serve_site()
Building sites … WARN 2019/02/07 03:29:15 Data for key 'font_size_small' in path 'hugo-academic/fonts/default.toml' is overridden by higher precedence data already in the data tree
WARN 2019/02/07 03:29:15 Data for key 'name' in path 'hugo-academic/fonts/default.toml' is overridden by higher precedence data already in the data tree
WARN 2019/02/07 03:29:15 Data for key 'google_fonts' in path 'hugo-academic/fonts/default.toml' is overridden by higher precedence data already in the data tree
WARN 2019/02/07 03:29:15 Data for key 'heading_font' in path 'hugo-academic/fonts/default.toml' is overridden by higher precedence data already in the data tree
WARN 2019/02/07 03:29:15 Data for key 'body_font' in path 'hugo-academic/fonts/default.toml' is overridden by higher precedence data already in the data tree
WARN 2019/02/07 03:29:15 Data for key 'nav_font' in path 'hugo-academic/fonts/default.toml' is overridden by higher precedence data already in the data tree
WARN 2019/02/07 03:29:15 Data for key 'mono_font' in path 'hugo-academic/fonts/default.toml' is overridden by higher precedence data already in the data tree
WARN 2019/02/07 03:29:15 Data for key 'font_size' in path 'hugo-academic/fonts/default.toml' is overridden by higher precedence data already in the data tree
| EN
+------------------+----+
Pages | 41
Paginator pages | 0
Non-page files | 14
Static files | 16
Processed images | 3
Aliases | 15
Sitemaps | 1
Cleaned | 0
Total in 1478 ms
Error in as.vector(x, "character") :
cannot coerce type 'environment' to vector of type 'character'
I'm sorry I forgot to tell you that build_site()
run successfully--even with all of my .Rmd
s. I also tried to install devel version of servr
, and still got the error.
So any suggestion to debug why serve_site()
got that error?
Does traceback()
tell you anything? Can you also try to use the CRAN versions of later and httpuv (remember to restart R)?
Well, after installing the CRAN versions of later
and httpuv
, it works again!
This is the output from traceback()
when it still got an error, maybe it could helps:
10:31:41 > traceback()
11: as.character.default(X[[i]], ...)
10: FUN(X[[i]], ...)
9: lapply(list(...), as.character)
8: .makeMessage(..., domain = domain, appendLF = appendLF)
7: message("To stop the server, run servr::daemon_stop(\"", server,
"\")", " or restart your R session")
6: daemon_hint(id)
5: res$start_server(app)
4: dynamic_site(dir, ..., build = watch_dir(watch, pattern = pattern,
all_files = all_files, handler = handler))
3: servr::httw(site.dir = pdir, baseurl = baseurl, handler = function(...) {
files = c(...)
files = files[substr(files, 1, n) != pdir]
if (length(grep("(_?layouts?|static)/|[.](toml|yaml)$", files)) ||
length(grep(md_pattern, files)))
build_site(TRUE)
}, dir = ".", ...)
2: serve(...)
1: blogdown::serve_site()
Thank you so much @yihui !
That was very helpful. I just fixed the issue in servr. If you use the dev version of httpuv, you'll have to use the dev version of servr, too. Thanks!
@yihui - got the same problem. Even after remotes::install_github('rstudio/blogdown')
and
(file.remove(list.files(, '[.R]md$', recursive = TRUE, full.names = TRUE)))
, blogdown::serve_site()
gives:
Error in as.vector(x, "character") :
cannot coerce type 'environment' to vector of type 'character'
and the the output from traceback()
:
11: as.character.default(X[[i]], ...)
10: FUN(X[[i]], ...)
9: lapply(list(...), as.character)
8: .makeMessage(..., domain = domain, appendLF = appendLF)
7: message("To stop the server, run servr::daemon_stop(\"", server,
"\")", " or restart your R session")
6: daemon_hint(id)
5: res$start_server(app)
4: dynamic_site(dir, ..., build = watch_dir(watch, pattern = pattern,
all_files = all_files, handler = handler))
3: servr::httw(site.dir = pdir, baseurl = baseurl, handler = function(...) {
files = c(...)
files = files[substr(files, 1, n) != pdir]
if (length(grep("(_?layouts?|static)/|[.](toml|yaml)$", files)) ||
length(grep(md_pattern, files)))
build_site(TRUE)
}, dir = ".", ...)
2: serve(...)
1: blogdown::serve_site()
The same website worked two month ago. Please, help.
@mdozmorov When in doubt, upgrade. And restart R. If the problem persists, please read the issue guide and provide the necessary information: https://github.com/rstudio/blogdown/blob/master/.github/ISSUE_TEMPLATE.md
Thank you, @yihui, updating R and packages helped. This issue extending the list of solved ones at https://yihui.name/en/2017/05/when-in-doubt-upgrade/
@mdozmorov Perfect. Thanks for letting me know! :)
When running
serve_site()
, I get an error like this:Error in as.vector(x, "character"): cannot coerce type 'environment' to vector of type 'character'
The problem is I can't get more information about the error from the message, so I can't track where I got wrong.
Previously, It is running well on my desktop. Just got this error after not blogging for a while.
If this is helping, this is my blog repo: https://github.com/bagasbgy/blog. And this is my
sessionInfo()
: