rstudio / blogdown

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

Error: Error building site: open <fiile> Access is denied. #590

Closed mattansb closed 3 years ago

mattansb commented 3 years ago

I am not longer able to build the site with blogdown::serve_site() since V1.0.

I get the following error:

blogdown::build_site()
#> Building sites … Total in 6207 ms
#> Error: Error building site: open C:\Users\USER\Documents\R\blog_netlify\public\posts\IJR.csv: Access is denied.

(I am still able to serve the site.)

The full repo is here for testing: https://github.com/mattansb/blog_netlify

Session info:

> xfun::session_info('blogdown')
R version 4.0.3 (2020-10-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19041), RStudio 1.4.1103

Locale:
  LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252   
  LC_MONETARY=English_United States.1252 LC_NUMERIC=C                          
  LC_TIME=English_United States.1252    
system code page: 1255

Package version:
  base64enc_0.1.3   BH_1.75.0.0       blogdown_1.1.12   bookdown_0.21     digest_0.6.27    
  evaluate_0.14     glue_1.4.2        graphics_4.0.3    grDevices_4.0.3   highr_0.8        
  htmltools_0.5.1.1 httpuv_1.5.5      jsonlite_1.7.2    knitr_1.31        later_1.1.0.1    
  magrittr_2.0.1    markdown_1.1      methods_4.0.3     mime_0.10         promises_1.2.0.1 
  R6_2.5.0          Rcpp_1.0.6        rlang_0.4.10      rmarkdown_2.6     servr_0.21       
  stats_4.0.3       stringi_1.5.3     stringr_1.4.0     tinytex_0.29      tools_4.0.3      
  utils_4.0.3       xfun_0.21         yaml_2.2.1       

Hugo version: 0.55.6

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:

cderv commented 3 years ago

This is a Hugo error it seems. Unfortunately, I can't run your site for other issue with the template - so can't look into myself. Anyway, can you set the verbose option in a clean session ?

blogdown::build_site(args = "--verbose")

Also, was the site built or not ? it seems it was built correctly but you have an error at the end.

Thank you.

mattansb commented 3 years ago

@cderv can it be a Hugo issue if Hugo hasn't been updated? I know it worked in Aug 2020, before updating blogdown.

> blogdown::build_site(args = "--verbose")
INFO 2021/02/16 11:07:13 No translation bundle found for default language "en"
INFO 2021/02/16 11:07:13 Translation func for language en not found, use default.
INFO 2021/02/16 11:07:13 i18n not initialized; if you need string translations, check that you have a bundle in /i18n that matches the site language or the default language.
INFO 2021/02/16 11:07:13 Using config file: 
Building sites … INFO 2021/02/16 11:07:13 syncing static files to C:\Users\USER\Documents\R\blog_netlify\public\
Total in 9269 ms
Error: Error copying static files: chtimes C:\Users\USER\Documents\R\blog_netlify\public\apple-touch-icon-144-precomposed.png: Access is denied.

(Note that the same error is now for a different file..., but the same error about "access".)

Also, was the site built or not ? it seems it was built correctly but you have an error at the end.

It doesn't add any new files to the /public folder, so it seems not (the files currently in /public are from a previous build).

cderv commented 3 years ago

blogdown::build_site is only running for you

hugo -d public --themesDir themes -t "hyde-hyde"

So I believe this is a Hugo error. I don't know if it comes from a Hugo version or not. You can now manage hugo version so may be able to try several: https://blog.rstudio.com/2021/01/18/blogdown-v1.0/#hugo-versioning-system

Error: Error copying static files: chtimes C:\Users\USER\Documents\R\blog_netlify\public\apple-touch-icon-144-precomposed.png: Access is denied.

It seems there is an issue when Hugo tries to copy some static files. Hugo can't access the file (for a reason I don't know).

As your follow your public/ folder on GIT, this would be low risk IMO: You can try delete the current public folder for a clean state and try building new for your source.

It seems Hugo has also a log flag so you can try activate it but it may not be more info that in Console

blogdown::build_site(args = "--logFile=build.log")

I don't really know what can happen here: have you search through https://discourse.gohugo.io/ already ?

mattansb commented 3 years ago

As your follow your public/ folder on GIT, this would be low risk IMO: You can try delete the current public folder for a clean state and try building new for your source.

No - still got the same error :(

I will try on the hugo forum - will update here if I get this resolved.

Thanks!

cderv commented 3 years ago

Just curious: I suppose USER is replaced here or is it the real username on your environment ?

C:\Users\USER\Documents\R\blog_netlify\public\posts\IJR.csv

If so, in your real username do you have a space ? Sometimes space in file paths can cause issues.

Access issues can be caused by antivirus software too. Like files are created, they are analysed by Windows or another program and another third party program tries to move them - it can't because the file is locked so access is denied.

That is juts hints; Hopefully the Hugo community will be able to help you. Keep us posted ! thanks!

mattansb commented 3 years ago

Just curious: I suppose USER is replaced here or is it the real username on your environment ?

Nope, USER is actually my user directory - I was very lazy when setting up this machine 😅

mattansb commented 3 years ago

Okay, it works now. I don't know exactly what made it work, but here are things that happend, chronologically, between it not working and it yes working:

  1. I closed the RProject
  2. I closed Github for Desktop
  3. I opened the RProject
  4. I ran blogdown::build_site()
  5. It failed, but:
  6. My antivirus asked me if hugo.exe was safe (which it never asked before) - I said "uh, duh!"
  7. I ran blogdown::build_site() again.
  8. It worked!

Hope this helps anyone!

cderv commented 3 years ago

My antivirus asked me if hugo.exe was safe (which it never asked before) - I said "uh, duh!"

I think this was the thing blocked you before.

Glad it works now. Thanks for sharing !

mattansb commented 3 years ago

Yeah, me too. Weird that it only popped up after I closed Github for Desktop. Wonder what that's about...