0

I am trying to knit a Store-Metrics.Rmd file so as to generate the reports in a webpage. The code is fine. When I run it, I can see the dashboard but when I try to knit so as to push it through the webpage, I get the following error:

Line 135: Error in file(con, "w"): cannot open the connection
Calls:<Anonymous...block_cache-><Anonymous> ->write_utf8 ->writelines -?file
In addition: Warning message:
In file(con."w")"
   cannot open file 'Store-Metrics_cache/html/_packages':Permission denied
Execution halted.

The folder Store-Metrics_cache exists. It is located in the following:

/srv/shiny-server/Store/Store_report/Store-Metrics_cache

I checked line 135 and this is what it looks like

{r, echo=False, warning=False, message=False, cache=TRUE, cache.extra=file.info("srv/shiny-server/Store/Store_Report/Storedata.RData")$mtime}
CurrentMonthStatistics("Tota")
LastYearGraph("Total")

Any help on how I could get the dashboard to load unto the webpage would be greatly appreciated.

Thank you

I first tried to get my working directory. I ran getwd() and it gave me "/"

I also ran the .libPaths() and the results are below

"/home/john/R/X86_64-pc-linux-library/4.1"
"/usr/local/lib/R/site-library"
"/usr/lib/R/site-library"
"/usr/lib/R/library

I also went to the global options to check the directory there and it shows the following:

Default working directory(when not in a project):   
~/R

I also cleared Knitr Cache, restarted R studio then re-run the codes and knit to tml_document:default but I still get the same error.

Phil
  • 7,287
  • 3
  • 36
  • 66
De Guen
  • 1
  • 1
  • Tough to help because we can't reproduce your problem as presented. The `CurrentMonthStatistics()` and `LastYearGraph()` functions are custom and we don't know what is inside of them. Do you happen to have a `install.packages()` line in either of them? – Phil May 15 '23 at 15:53
  • My apologies for the lack of additional information. All the installed.packages() are located in "/home/John/x86_64-pc-linux-gnu-library/4.1 (R Studio was updated from 3.6 to 4.1) and all the packages were reinstalled for version 4.1 – De Guen May 15 '23 at 16:17
  • The issue is that the file 'Store-Metrics_cache/html/_packages cannot be opened. It says Permission denied. When i run file.exists("/srv/Store/Store_report/Store-Metrics_cache"), it says False but the folder does exist. It is the correct path and the output is store in that folder. – De Guen May 15 '23 at 16:53
  • 2
    The issue is not whether the path exists, but whether the app has permission to access it. – Phil May 15 '23 at 16:58
  • I agree with you. Do you think a restriction might be the cause? – De Guen May 16 '23 at 17:31
  • I do, but I'm not knowledgeable enough in the domain to help further. – Phil May 16 '23 at 18:10

0 Answers0