rstudio / blogdown

Create Blogs and Websites with R Markdown
https://pkgs.rstudio.com/blogdown/
1.74k stars 331 forks source link

For error `could not find function "parser"`: fail more gracefully #742

Closed CerebralMastication closed 1 year ago

CerebralMastication commented 1 year ago

it looks like blowdown does not fail gracefully if it fails to find the config file. It's very difficult to track back what's happening but I took a shot at it here:

https://community.rstudio.com/t/blogdown-new-post-addin-returning-error-in-parser-f-could-not-find-function-parser/154427

I still am unsure why my instance is having trouble finding the config file, however. But based on discussion in the thread above I figure this should get at least more helpful error trapping.

Thank you all for maintaining and continuing blowdown

cderv commented 1 year ago

It seems indeed that

Error in parser(f) : could not find function "parser"

comes from https://github.com/rstudio/blogdown/blob/3c5f7d873fa9e56419e5251eed5d57a44c59db75/R/utils.R#L219-L224

And we could fail more gracefully in the (unexpected) case where parser() is not a function.

Regarding why you have this error, I'll look closer.

yihui commented 1 year ago

@CerebralMastication Should be fixed now. Thanks for the report! You can install the development version via

remotes::install_github('rstudio/blogdown')

@cderv Yes, in theory, switch() here should fall back to an (informative) error, but this case should never happen. It happened because of a regex problem in module_paths(), which I just fixed.

cderv commented 1 year ago

Thanks for looking into this !

Yes, in theory, switch() here should fall back to an (informative) error, but this case should never happen. It happened because of a regex problem in module_paths(), which I just fixed.

Yeah I know, it should never happen, but when it happens like here, having a useful error or debug log would have made finding the issue straighforward. I agree though that this is internal and not user facing and should not happen !

Thank you !