When building R package, devtools::check() throw 'Permission Denied' error - r

Over the past years, I built a R package and regularly updated it in Windows 7 Enterprise. Everything was working fine until November 2017 when the company upgraded my desktop. I got a brand new machine with windows 10. As 'permission' issue is kind of common, so I as usual installed R, Rstudio, Rtools into a folder I have write access. But when I tried to build the package in Rstudio, I got the below error:
==> devtools::check()
Updating RCfun documentation
Loading RCfun
Setting env vars --------------------------------------------------------------
CFLAGS : -Wall -pedantic
CXXFLAGS: -Wall -pedantic
Building RCfun ----------------------------------------------------------------
"C:/R/R-34~1.2/bin/x64/R" --no-site-file --no-environ --no-save --no-restore \
--quiet CMD build "Z:\_R\R_package\RCfun" --no-resave-data --no-manual
* checking for file 'Z:\_R\R_package\RCfun/DESCRIPTION' ... OK
* preparing 'RCfun':
* checking DESCRIPTION meta-information ... OK
* checking for LF line-endings in source and make files and shell scripts
* checking for empty or unneeded directories
* looking to see if a 'data/datalist' file should be added
* building 'RCfun_0.1.1.tar.gz'
Warning in gzfile(tarfile, "wb", compression = compression_level) :
cannot open compressed file 'C:/Windows/System32/RCfun_0.1.1.tar.gz',
probable reason 'Permission denied'
Error in gzfile(tarfile, "wb", compression = compression_level) :
cannot open the connection
Execution halted
Error: Command failed (1)
Execution halted
Exited with status 1.
Clearly, I don't have access to the folder 'C:/Windows/System32/'. I can't change that and I am aware of that, so I installed R related stuff all in a folder I have access to. But the question is, why it still attempts to write the file RCfun_0.1.1.tar.gz into the folder 'C:/Windows/System32/' when building the package? Where can I change/overwrite that behavior?
I have searched for answers from time to time for the past a couple of month, but got no luck. I found something similar in this thread:
permission denied error while building/checking R package on WIndows
but it doesn't solve my case.
I know it must be related to some system path that directs to this folder 'C:/Windows/System32/'. I tried Sys.setenv(PATH=) to remove that folder. I'm not sure if that's the correct way, but it doesn't help anyway. Is there a way that I can catch where it goes wrong? Thanks.

Related

rhub compilation warning on Ubuntu 16.04

We are developing an R package that contains compiled code (using Rcpp). We check the package builds on rhub (to test builds on multiple platforms) with check_for_cran() function.
For Ubuntu 16.04, we get the following warning
* checking compilation flags used ... WARNING
Compilation used the following non-portable flag(s):
'-Wdate-time' '-Werror-format-security' '-Wformat'
We currently do not have a Makevars file in the src sub directory. To suppress the warnings, we added the -Wall flag in the Makevars file, which results in the following warning
* checking compilation flags in Makevars ... WARNING
Variables overriding user/site settings:
CFLAGS: -Wall
We tried multiple settings of Makevars, but could not get rid of these warnings. We would appreciate any help.
For submission on cran, we need to be able to build the package without any warnings.

Error in installing car package in R

While installing "car" package in Rstudio in Ubuntu, I faced an error saying that dependencies "nloptr","lme4" and one more, are not installed.
So I started installing "nloptr" but I faced this error-
configure: Need to download and build NLopt
trying URL 'http://ab-initio.mit.edu/nlopt/nlopt-2.4.2.tar.gz'
Error in download.file(url = "http://ab-initio.mit.edu/nlopt/nlopt-
2.4.2.tar.gz", :
cannot open URL 'http://ab-initio.mit.edu/nlopt/nlopt-2.4.2.tar.gz'
Execution halted
/bin/tar: This does not look like a tar archive
gzip: stdin: unexpected end of file
/bin/tar: Child returned status 1
/bin/tar: Error is not recoverable: exiting now
Warning message:
In untar(tarfile = "nlopt-2.4.2.tar.gz") :
'/bin/tar -xf 'nlopt-2.4.2.tar.gz'' returned error code 2
configure: Starting to install library to
/tmp/RtmpSeLv7g/R.INSTALL18a67910d582/nloptr/nlopt-2.4.2
./configure: line 3325: cd: nlopt-2.4.2: No such file or directory
System hangs after last line and when I restart after some time, "nloptr" is not installed and hence I am unable to install "car" package.
Please help me. Thanks in advance.
I was encountering the same problem under R (pure R 3.2.3 on Linux Debian). I was first blocked by another issue during the same installation : the installation process failed to lock directory ~/.../R/x86_64.../3.2 and suggested to remove ~/.../R/x86_64.../3.2/00LOCK-nloptr . I did it, restart the car package installation, and then it blocked at the same point: it needs nlopt.h.
So, I installed libnlopt-dev (sudo apt-get install libnlopt-dev) and re-restart the car installation ... and then it worked.
Ok, this is under linux, but perhaps should you try to focus on installing something about NLOPT under windows.
Good luck.

Checking a R package in RStudio: Error 'file' doesn't exist (working directory does not adapt to project)

I want to check a package I have written. When I click on the Check button in RStudio, I receive the following message:
==> devtools::check(document = FALSE)
Setting env vars --------------------------------------------------------------
CFLAGS : -Wall -pedantic
CXXFLAGS: -Wall -pedantic
Building BBkUtils -------------------------------------------------------------
"C:/PROGRA~1/R/bin/x64/R" --no-site-file --no-environ --no-save --no-restore \
--quiet CMD build "U:\Eigene Dateien\R\BBkUtils" --no-resave-data \
--no-manual
* checking for file 'U:\Eigene Dateien\R\BBkUtils/DESCRIPTION' ... OK
* preparing 'BBkUtils':
* checking DESCRIPTION meta-information ... OK
* checking for LF line-endings in source and make files
* checking for empty or unneeded directories
* building 'BBkUtils_0.1.0.tar.gz'
Setting env vars --------------------------------------------------------------
_R_CHECK_CRAN_INCOMING_ : FALSE
_R_CHECK_FORCE_SUGGESTS_: FALSE
Checking BBkUtils -------------------------------------------------------------
"C:/PROGRA~1/R/bin/x64/R" --no-site-file --no-environ --no-save --no-restore \
--quiet CMD check \
"C:\Users\s1504gl\AppData\Local\Temp\RtmpSyMuXs/BBkUtils_0.1.0.tar.gz" \
--as-cran --timings --no-manual
Warning: 'C:\Users\s1504gl\AppData\Local\Temp\RtmpSyMuXs/BBkUtils_0.1.0.tar.gz' is neither a file nor directory, skipping
Error: Check failed: 'U:\Eigene Dateien\R/BBkUtils.Rcheck' doesn't exist
Execution halted
Exited with status 1.
This behaviour does not change if I start devtools::check() from the R console.
Interestingly, I can build the package without any issues (without checking it before). This also becomes clear from the message above. But for some reason, the package cannot be found in the mentioned temporary folder (which really does not exist as it is stated in the message).
During the checking, the .tar.gz file is created one folder level above the project root. Can I somehow tell devtools::check() where to look for the .tar.gz file?
Edit 1: Problem with working directory
I figured that the working directory does not adapt to the project. I remains U:\Eigene Dateien\R even though it should be U:\Eigene Dateien\R\BBkUtils. This happens in all my projects. Any suggestions on that?
Edit 2: How the project was created
Initially, I created the project using the New Project Wizard. Afterwards, I moved the project to another folder. But I do not think, this caused the problem since I observe the same error when I create a new package using the wizard.
I also tried to reset the project root to the correct folder, but the notion Project root in the project options remained.
I finally got the information from my colleage that there was a function .First in the file C:\Program Files\R\etc\Rprofile.site which was setting the working directory to U:\Eigene Dateien\R.
Removing the corresponding line and restarting R fixed my problem.

Installing R Interface for Ipopt

I have exactly the same problem as the poster here, unfortunately no solution is provided on that link.
I built and installed IPOPT (version 3.12.6) on Windows 7 (64bit) with Cygwin, but I cannot seem to get the R interface to work. All commands (configure, make, make install, make test) were executed without error.
When I try to build the R interface from RStudio, I tried using both the code in the "build" folder as well as the code in the main directory. I get the following errors:
`>install.packages("C:/cygwin64/home/Ipopt-3.12.6/build/Ipopt/contrib/RInterface",
repos=NULL, type="source")
Error:
cygwin64/home/Ipopt-3.12.6/build/Ipopt/contrib/RInterface/DESCRIPTION'
Not using the build directory:
`>install.packages("C:/cygwin64/home/Ipopt-3.12.6/Ipopt/contrib/RInterface", repos=NULL, type="source")
Error:
installing source package 'ipoptr' ...
** libs
*** arch - i386 Warning: running command 'make -f "Makevars.win" -f "C:/Users/~1/DOCUME~1/R/R-33~1.1/etc/i386/Makeconf" -f
"C:/Users/~1/DOCUME~1/R/R-33~1.1/share/make/winshlib.mk"
SHLIB_LDFLAGS='$(SHLIB_CXXLDFLAGS)' SHLIB_LD='$(SHLIB_CXXLD)'
SHLIB="ipoptr.dll" ' had status 127 ERROR: compilation failed for
package 'ipoptr'
* removing 'C:/Users/Documents/R/R-3.3.1/library/ipoptr' Warning in install.packages : running command
'"C:/Users/~1/DOCUME~1/R/R-33~1.1/bin/x64/R" CMD INSTALL -l
"C:\Users\Documents\R\R-3.3.1\library"
"C:/cygwin64/home/Ipopt-3.12.6/Ipopt/contrib/RInterface"' had status 1
Warning in install.packages : installation of package
‘C:/cygwin64/home/Ipopt-3.12.6/Ipopt/contrib/RInterface’ had non-zero
exit status
Does anyone know what I could do to resolve this?
EDIT: After installing RTools and adding it to my PATH I get ipoptr.cpp:22:34: fatal error: IpIpoptApplication.hpp: No such file or directory
#include "IpIpoptApplication.hpp", i.e. it seems that ipoptr.cpp cannot find IpIpoptApplication.hpp (which is in a subdirectory of the build folder) and later on in the error still the same Warning: running command 'make -f "Makevars.win" -f ' had status 2.... Copying this file over to the location of ipoptr.cpp moves the error one file further to another similar file that it cannot find. I suspect it cannot find these files because of something being wrong with my makevars.win file (I suspect that that's the file that should point to the currently missing files). Does anyone have an idea what this could be?
EDIT 2: Might it have to do with the comment here indicating that in some cases LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$IPOPTDIR/build/lib should be set? How do I do this? Should this be done in R or cygwin?

Installing ggbiplot from github

I'm trying to install development version of ggbiplotfrom Github. During installation I'm getting the following error message:
library(devtools)
install_github("ggbiplot", "vqv")
Installing github repo(s) ggbiplot/master from vqv
Installing ggbiplot.zip from https://github.com/vqv/ggbiplot/zipball
Installing ggbiplot
* checking for file 'C:\Users\Muhammad Yaseen\AppData\Local\Temp\Rtmpsx4n5u\vqv-ggbiplot-2623d7c/DESCRIPTION' ... OK
* preparing 'ggbiplot':
* checking DESCRIPTION meta-information ... OK
* checking for LF line-endings in source and make files
* checking for empty or unneeded directories
* looking to see if a 'data/datalist' file should be added
* building 'ggbiplot_0.5.tar.gz'
cygwin warning:
MS-DOS style path detected: C:/Users/MUHAMM~1/AppData/Local/Temp/Rtmpsx4n5u/ggbiplot_0.5.tar.gz
Preferred POSIX equivalent is: /cygdrive/c/Users/MUHAMM~1/AppData/Local/Temp/Rtmpsx4n5u/ggbiplot_0.5.tar.gz
CYGWIN environment variable option "nodosfilewarning" turns off this warning.
Consult the user's guide for more details about POSIX paths:
http://cygwin.com/cygwin-ug-net/using.html#using-pathnames
Warning: invalid package 'Yaseen/R/win-library/2.14'
Error: ERROR: cannot cd to directory 'C:/Users/Muhammad'
Error: Command failed (1)
In addition: Warning message:
running command '"C:/PROGRA~1/R/R-214~1.2/bin/i386/R" CMD INSTALL C:\Users\MUHAMM~1\AppData\Local\Temp\Rtmpsx4n5u/ggbiplot_0.5.tar.gz --library=C:/Users/Muhammad Yaseen/R/win-library/2.14' had status 1
Any idea to figure out this problem. Thanks in advance for your help and time.
Edit
After downloading from Github, also tried
install.packages("vqv-ggbiplot-2623d7c.tar.gz", repos=NULL, type="source")
which produced this error message
Installing package(s) into ‘C:/Users/Muhammad Yaseen/R/win-library/2.14’
(as ‘lib’ is unspecified)
Error in untar2(tarfile, files, list, exdir) : unsupported entry type 'g'
Warning messages:
1: running command 'C:/PROGRA~1/R/R-214~1.2/bin/i386/R CMD INSTALL -l "C:/Users/Muhammad Yaseen/R/win-library/2.14" "vqv-ggbiplot-2623d7c.tar.gz"' had status 1
2: In install.packages("vqv-ggbiplot-2623d7c.tar.gz", repos = NULL, :
installation of package ‘vqv-ggbiplot-2623d7c.tar.gz’ had non-zero exit status
It's because your Rlib path has a space in it: C:/Users/Muhammad Yasseen/R/win-library/2.14.
See how in the first error log the warning message was
running command '"C:/PROGRA~1/R/R-214~1.2/bin/i386/R" CMD INSTALL
C:\Users\MUHAMM~1\AppData\Local\Temp\Rtmpsx4n5u/ggbiplot_0.5.tar.gz
--library=C:/Users/Muhammad Yaseen/R/win-library/2.14'
had status 1
In particular, the --library=C:/Users/Muhammad Yaseen/R/win-library/2.14.
This should be --library="C:/Users/Muhammad Yaseen/R/win-library/2.14" to deal with the space.
Using install.packages takes care of the quotes for you - see how your second warning message (when you used install.packages) was
running command 'C:/PROGRA~1/R/R-214~1.2/bin/i386/R CMD INSTALL
-l "C:/Users/Muhammad Yaseen/R/win-library/2.14"
"vqv-ggbiplot-2623d7c.tar.gz"' had status 1
The -l "C:/Users/Muhammad Yasseen/R/win-library/2.14" has quote marks around it, so you don't get the same error.
I had a quick look at the install-github sources, and it constructs the R CMD INSTALL command via:
paste("CMD INSTALL ", built_path, " --library=", .libPaths()[1], sep="")
See how it doesn't surround .libPaths()[1] by double quotes in case of spaces? I'd guess that's your problem.
As to a fix - there seems to be an error using install.packages() on a tar file generated by git (as reported here). So, you can either:
change your R library location to somewhere without spaces
unzip the .tar.gz file (I don't know what software does this on Windows) and install from the extracted directories rather than the .tar.gz.
You can't unzip the .tar.gz because it cleans up that file quicker than you can grab it (I've watched it appear and get deleted again). Correct me if I'm wrong, but I also can't get devtools from github for teh same reason :S

Resources