Roxygen getting cannot open file/permission denied/execution halted - r

So I've been trying to build and load a package and have been getting this error
devtools::document(roclets=c('rd', 'collate', 'namespace'))
Updating stat290.ass2 documentation
Loading stat290.ass2
Error in file(con, "r") : cannot open the connection
Calls: suppressPackageStartupMessages ... topic_add_examples -> read_lines -> <Anonymous> -> file
In addition: Warning message:
In file(con, "r") :
cannot open file 'C:\Users\blah\Desktop\stat290.ass2': Permission denied
Execution halted
Exited with status 1.
I've seen these posts as reference: Roxygen Warning "cannot open the connection" "Permission Denied", https://github.com/klutometis/roxygen/issues/766, but they say the error has been patched out. I have tried deleting and re-installing both devtools and roxygen2, but have not had any luck

I resolved this issue by removing the #return and #example in my roxygen2 comments at the header of the function as I did not write anything in for them. It appears that if you put a #XXX you need to fill in the information next to it, otherwise the key is missing the value and it bombs.
I got he idea from the error topic_add_examples -> read_lines -> since it appeared it was trying to read the comments next to my #example but I didn't have any.

Related

Error while checking the R package created

I was running the check for my package that I have created when I got this error due to some example file that has been created outside my package directory which has been created due to the vignette I have created because while checking when R was reading the vignette, it got this error and I tried to delete the folder that has been created outside my package directory but I am not able to. Here is the error that is shown while checking the package:
E checking examples ... Running examples in 'ikpack-Ex.R' failed
Warning in file(con, "r") :
cannot open file 'ikpack-Ex.Rout': Permission denied Error in file(con, "r") : cannot open the connection Execution halted
Any kind of help related to this is appreciated.

R - Installation of shiny fails after upgrade to 4.0.2

I upgraded to R 4.0.2 today, and also updated my copy of RStudio. While I've been updating my packages I've found that shiny won't install. Whenever I try to install shiny I get the following message...
Error in as.list.environment(base::getNamespace("shiny"), all.names = TRUE) :
lazy-load database 'H:/My Documents/R/win-library/4.0/shiny/R/shiny.rdb' is corrupt
Calls: <Anonymous> ... withCallingHandlers -> <Anonymous> -> <Anonymous> -> as.list.environment
Execution halted
*** arch - x64
Error in as.list.environment(base::getNamespace("shiny"), all.names = TRUE) :
lazy-load database 'H:/My Documents/R/win-library/4.0/shiny/R/shiny.rdb' is corrupt
Calls: <Anonymous> ... withCallingHandlers -> <Anonymous> -> <Anonymous> -> as.list.environment
Execution halted
ERROR: loading failed for 'i386', 'x64'
* removing 'H:/My Documents/R/win-library/4.0/shiny'
Warning in install.packages :
installation of package ‘shiny’ had non-zero exit status
I get this error regardless of whether I just type "install.packages('shiny')" and peace out or if I download the tar.gz and try to install from a local directory. The same error happens when I specify to download an older version of shiny, so I'm pretty sure it's not a problem with the file I'm trying to install. Restarting RStudio does nothing, which is the only advice I could find online for shiny installation problems.
Has anyone else had any problems with installing shiny since upgrading to the newest version of R? Any workarounds?

Warning in install.packages 'path' is not writable R

I am unable to install any package due to the error mentioned in the title.
I attempt to run the following package :
install.packages("tseries")
However, I then receive the error:
Warning in install.packages 'lib = "C:/Users/santi/OneDrive/Documents/R"' is not writable :
Afterwards, I receive the following pop message:
I proceed to click "yes" bu then I get the following error:
Warning in install.packages cannot create dir 'C:\Users\santi\OneDrive\Documents\R\win-library\3.5\file64444b1a3a3b', reason 'No such file or directory'
I want to be clear that I am using my personal computer and all my settings are set to administrator and I have set all my premissions to my account to "Allow"

ggplotly won't work or re-install - is there a way to deinstall it?

I am having a problem I think I may be able to solve my if I could deinstall 'ggplotly' before attempting to reinstall it.
Here's what happened:
Code that worked fine when an instructor demoed it, failed when I tried it at home. It was R Markdown. Investigating the problem code cell line by line, the problem was centered around ggplot2 (which uses ggplotly). Code and error messages are provided below. In the code "graph" was a ggplot2 facet_wrap() that was supposed to pass into ggplotly.
Here is the excerpt from my console of the problem and a failed attempt to fix it by re-installing:
> ggplotly(graph)
Error in dev_fun(tmpPlotFile, width = deviceWidth, height = deviceHeight) :
unable to start png() device
> ggplotly(graph)
Error in RStudioGD() :
Shadow graphics device error: r error 4 (R code execution error)
In addition: Warning messages:
1: In grDevices:::png("C:/Users/User/AppData/Local/Temp/Rtmp0ar20f/3b613ba7d0ce4228bc937aee7cfcb112.png", :
unable to open file 'C:/Users/User/AppData/Local/Temp/Rtmp0ar20f/3b613ba7d0ce4228bc937aee7cfcb112.png' for writing
2: In grDevices:::png("C:/Users/User/AppData/Local/Temp/Rtmp0ar20f/3b613ba7d0ce4228bc937aee7cfcb112.png", :
opening device failed
> install.packages("plotly")
Error in install.packages : Updating loaded packages
Error in gzfile(file, mode) : cannot open the connection
In addition: Warning message:
In gzfile(file, mode) :
cannot open compressed file 'C:\Users\User\AppData\Local\Temp\Rtmp0ar20f/libloc_190_4464fd2b.rds', probable reason 'No such file or directory
As per comments on this thread, a package can be de-installed with remove.packages. As per the original problem on this post, de-installing and re-installing cleared it, but for completeness, here are all the precautions I took to improve the chances of this working:
removed the package as indicated
re-initialized RStudio (exited without saving the workspace and re-entered it)
By default, it remembered some of my environment so I clicked the broom icon to clear out all variables and data from memory
re-installed the package
re-loaded the original R file and tested to make sure all worked as expected.
This is what I saw in the console with de-installing and re-installing in contrast to the messages shown on the original post:
During de-installation:
> remove.packages("plotly")
Removing package from ‘C:/ProgramFilesCoders/R/R-3.3.2/library’
(as ‘lib’ is unspecified)
Error in gzfile(file, mode) : cannot open the connection
In addition: Warning message:
In gzfile(file, mode) :
cannot open compressed file 'C:\Users\User\AppData\Local\Temp\Rtmp0ar20f/libloc_190_4464fd2b.rds', probable reason 'No such file or directory'
During re-installation:
> install.packages("plotly")
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.3/plotly_4.5.6.zip'
Content type 'application/zip' length 817502 bytes (798 KB)
downloaded 798 KB
package ‘plotly’ successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:\Users\User\AppData\Local\Temp\RtmpGco6OK\downloaded_packages

roxygen2 4.0.1 fails when man/figures is present

In an R package, I have a figure (jpeg) located under man/figures, which is added to a Rd file with,
\if{html}{\figure{supplydemand.jpg}{Supply-demand}}
\if{latex}{\figure{supplydemand}{Supply-demand}}
After updating to roxygen2 4.0.1, I get the error:
==> roxygen2::roxygenize('.', roclets=c('rd', 'collate', 'namespace'))
Error in file(con, "r") : cannot open the connection
Calls: suppressPackageStartupMessages ... <Anonymous> -> first_time -> vapply -> FUN -> readLines -> file
In addition: Warning message:
In file(con, "r") : cannot open file './man/figures': Permission denied
Execution halted
Exited with status 1.
If I remove the code to insert the figure, I still get this error. Only when I remove the subdir man/figures does roxygen2 work OK.
I assume this is a bug in roxygen2 or is there a workaround?

Resources