For my company, we have a repository for internally created packages at an internally hosted location. It is accessible while we are on our network, but inaccessible while we're off it.
We have an internal package that forces standards and configuration and contains a function that builds an internal profile at the project, user, or system level (So we can quickly configure their system to select packages from CRAN and the local along with a number of other settings)
the .Rprofile that's generated contains (among other things) the following:
repos <- getOption('repos')
repos["cloud"] <- "https://cloud.r-project.org"
repos['internal'] <- 'http://path/to/repo/'
options(repos = repos)
This works great when we're in the network, but outside of the network, install.packages still checks that internal repo (regardless of the order of the repos).
This leads to very long waits for timeouts.
I'm trying to find a way to either:
Include the repo conditionally
Reduce the timeout of install.packages
options(timeout = 10) appears to have no effect.
If it will quickly determine that the repo is unavailable, I think there won't be too much of a drop in user experience, but as it stands right now, it will take 2-3 mins to finally reject that repo.
EDIT: All other things being equal, setting the above options should reproduce the timeout issue, unless http://path/to/repo exists.
But in case this is a platform issue with options(timeout = X), this is my session info:
> sessionInfo()
R version 3.3.3 (2017-03-06)
Platform: x86_64-apple-darwin16.4.0 (64-bit)
Running under: macOS Sierra 10.12.3
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods
[7] base
loaded via a namespace (and not attached):
[1] tools_3.3.3
Related
I am trying to install package performance development version with devtools but am getting this error:
> devtools::install_github("easystats/performance")
Downloading GitHub repo easystats/performance#HEAD
Error: Failed to install 'performance' from GitHub:
create process 'C:/PROGRA~1/R/R-40~1.3/bin/x64/Rcmd.exe' (system error 267, The directory name is invalid.
) #win/processx.c:1040 (processx_exec)
Same thing with alternative remotes command:
> remotes::install_github("easystats/performance")
Downloading GitHub repo easystats/performance#HEAD
Error: Failed to install 'performance' from GitHub:
create process 'C:/PROGRA~1/R/R-40~1.3/bin/x64/Rcmd.exe' (system error 267, The directory name is invalid.
) #win/processx.c:1040 (processx_exec)
Edit: Note that I am getting the same error no matter what package I've tried to install through devtools (e.g., cardiomoon/processR or r-lib/crayon). This started to happen suddenly a few weeks ago yet never had this issue before. So it seems not related to the package but to something else.
So I tried changing my default library to the simplest ever location that doesn't have any special characters or require any admin rights, with those instructions. I can confirm that C:/Rpackages is now indeed my default library path, and that it is first (on the left):
> .libPaths()
[1] "C:/Rpackages" "C:/Program Files/R/R-4.0.3/library"
However, I am still getting the same error. The weird thing is that the error still seems to refer to the second library path rather than the first one, which seems off to me. From the help documentation, I don't see how to specify the library location explicitly for neither devtools nor remotes. Also interesting, notice that the error seems to mention R-40~1.3 instead of R-4.0.3 as it should(?). Might this be the issue? Then how to fix?
I also tried reinstalling devtools and remotes, to no avail.
Yet, it works if I install the regular CRAN version:
> install.packages("performance")
Installing package into ‘C:/Rpackages’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.0/performance_0.7.2.zip'
Content type 'application/zip' length 2487172 bytes (2.4 MB)
downloaded 2.4 MB
package ‘performance’ successfully unpacked and MD5 sums checked
Here my session info if useful:
> sessionInfo()
R version 4.0.3 (2020-10-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19042)
Matrix products: default
locale:
[1] LC_COLLATE=English_Canada.1252 LC_CTYPE=English_Canada.1252
[3] LC_MONETARY=English_Canada.1252 LC_NUMERIC=C
[5] LC_TIME=English_Canada.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_4.0.3 tools_4.0.3 yaml_2.2.1
The issue was with the processx package and the development version has since received a fix (in version v3.5.3). Please see the following discussion for more info: https://github.com/r-lib/processx/issues/313
I have an issue with the library path of R. Maybe the answer is out there already, but I was not able to find it. I am using R together with RStudio Version 1.1.456. All my additional libraries used to be in a directory dir1 <- \\SHARE\TOOLS_OLD$\R-3.5.1 which I append with .libPaths(dir1). In this setup, everything works as expected.
The problem occured after I copied all the libraries in directory \\SHARE\TOOLS_OLD$\R-3.5.1 to a new location \\NAS\TOOLSNEW$\R-3.5.1. I did not update the R version and I want to keep all the package versions the same such that I have exactly the same setup as before. That is why I did not reinstall the packages in the new location.
When I open a new R session and run the three lines of code
dir2 <- \\NAS\TOOLSNEW$\R-3.5.1
.libPaths(dir2)
.libPaths()
I get the correct output of .libPaths()
[1] "\\\\NAS/TOOLSNEW$/R-3.5.1" "C:/Apps/R-3.5.1/library"
but R also throws an error:
Error: invalid version specification ‘NA’
In addition: Warning message:
In utils:::packageDescription(packageName, fields = "Version") :
no package 'knitr' was found
Apparently some packages remember the original location where they were installed. Is there a way to copy packages to a new location without reinstalling them? If that is not possible, is there an easy (i.e. non-manual) way to reinstall my package tree without upgrading any of the packages (including the dependencies) i.e. defining the version of each package?
Thanks for your help!
PS: Here is my session info, just in case.
R version 3.5.1 (2018-07-02)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
Matrix products: default
locale:
[1] LC_COLLATE=German_Switzerland.1252 LC_CTYPE=German_Switzerland.1252
LC_MONETARY=German_Switzerland.1252 LC_NUMERIC=C
[5] LC_TIME=German_Switzerland.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_3.5.1 tools_3.5.1 yaml_2.2.0
The problem can have many causes, e.g. there might be some dependencies which are lost by copying the package folder or that the registry entries don't match anymore, but I'm guessing here. When you copy packages from older versions you have to run update.packages (but this might update any package to the currently available version, which you don't want). Check out the R-FAQ and this Stackoverflow question.
You can install packages of a certain version with the devtools package.
install.packages("devtools")
require(devtools)
install_version(somePackage, version = neededVersion)
How I did it was I created a data.frame of all the required packages with the corresponding version number, like
> requiredPkgs
Package Version
condformat "condformat" "0.9.0"
DT "DT" "0.17"
formattable "formattable" "0.2.1"
ggplot2 "ggplot2" "3.3.3"
ggthemes "ggthemes" "4.2.4"
htmlTable "htmlTable" "2.1.0"
and then installed them in a loop
for(iPkg in requiredPkgs) {
install_version(iPkg[1], version = iPkg[2]
}
I have an issue that is stumping me and am looking for some help. I just upgraded to R 4.0 and am trying to reinstall packages. This produces the following warning messages:
Warning: failed to download mirrors file (internet routines cannot be loaded); using local file 'C:/PROGRA~1/R/R-40~1.0/doc/CRAN_mirrors.csv'
Warning: unable to access index for repository https://cran.uni-muenster.de/src/contrib:
internet routines cannot be loaded
Warning: unable to access index for repository https://cran.uni-muenster.de/bin/windows/contrib/4.0:
internet routines cannot be loaded
Warning messages:
1: In download.file(url, destfile = f, quiet = TRUE) :
unable to load shared object 'C:/PROGRA~1/R/R-40~1.0/modules/x64/internet.dll':
LoadLibrary failure: Access is denied.
2: package ‘dplyr’ is not available (for R version 4.0.)
Note, the LoadLibrary failure is not always present. Additionally, when I look for help on a function (e.g. ?download.file), I get the following error message:
starting httpd help server ...Error in startDynamicHelp(TRUE) : internet routines cannot be loaded
So, it seems like there is a general issue with R connecting to the internet, but I'm not sure how to go about fixing this. This happens in both RStudio (which is fully updated) and in the base RGui; additionally, I do have access and permissions to read/write in the C:/PROGRA~1/R/R-40~1.0/modules/x64/ folder. Any help here would be much appreciated!
Edit:
Posting my sessionInfo() in case that is helpful:
> sessionInfo()
R version 4.0.0 (2020-04-24)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18362)
Matrix products: default
Random number generation:
RNG: Mersenne-Twister
Normal: Inversion
Sample: Rounding
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_4.0.0 tools_4.0.0
Edit 2: I have done some more digging and the 32-bit version of R works just fine, while the 64-bit does not.
i had the same issue when updated to R 4.0.2 64-bit and ran in RStudio 1.4.xxx which reported internet routine not loaded. my work cylance protect antivirus quarantined internet.dll file under modules\x64\internet.dll. I reported to my IT today. they said that this dll file is asking which antivirus installed in my machine. so, my IT was concerned. my IT will ask cylance.
My IT advised me not to download R 402 from cran where it was infected.
i copied that dll from my another pc where R 363 installed and put there.
but cylance antivirus quarantined again.
so i bring my covid analysis file home and am doing with my home R 402.
I checked downloaded R 402 and internet.dll with my windows defender = all clean
the most probable cause = my IT security perceived threat from internet.dll
wondering what others are thinking about it.
I also discussed with my IT director for having r package mirror server so i can download without going to the internet.
cheers.
Install RStudio and R Version With help of IT Team.
Download New Version of R from CRAN
Copy an internet.dll file (which Size should be Up to 5MB) from Existing Version Installed by IT Team on Your System
C:\Program Files\R\R-4.0.3\modules\x64 and
Paste it to C:\Users\MyUser\Documents\R\R-4.1.2\modules\x64 folder of New version
Then Restart RStudio you will not get any error
also you can install any packages
Do not need to make changes into any File like Rprofile and Renv
Or any other Options() Functions
Note: The File Path may be different in your System
After opening R Studio the following Error-message appears:
This error also always appears in the end when I am trying to install or load packages:
Error: invalid version specification ‘NA’
In addition: Warning message:
In utils:::packageDescription(packageName, fields = "Version") :
no package 'knitr' was found
Some maybe helpful facts:
> sessionInfo()
R version 3.5.1 (2018-07-02)
Platform: i386-w64-mingw32/i386 (32-bit)
Running under: Windows >= 8 x64 (build 9200)
Matrix products: default
locale:
[1] LC_COLLATE=German_Germany.1252 LC_CTYPE=German_Germany.1252 LC_MONETARY=German_Germany.1252 LC_NUMERIC=C
[5] LC_TIME=German_Germany.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_3.5.1 tools_3.5.1
I am working on a company laptop without admin-rights, why I have set my library path manually to the following writable folders:
> .libPaths()
[1] "\\\\HOME.COMPANYNAME/USERNAME$/Files/R/win-library/3.5"
[2] "\\\\HOME.COMPANYNAME/USERNAME$/Files/R/R-3.5.1/library"
The second .libPath() was created automatically some weeks after the first.
I cannot manually delete both .libPaths from my laptop due to missing admin-rights.
I also tried to remove the libraries as recommended in several posts
with:
R_LIBS=C:/Program Files/R/R-2.15.2/library
Nevertheless, the .libPaths stayed the same after this:
> .libPaths()
[1] "\\\\HOME.COMPANYNAME/USERNAME$/Files/R/win-library/3.5"
[2] "\\\\HOME.COMPANYNAME/USERNAME$/Files/R/R-3.5.1/library"
I also tried setting a new .libPath on a local folder C:// :
.libPaths("C:\\Users\\USERID\\Desktop\\R")
After that, the first .libPath is replaced by the new local one, while the second .libPath stays the same and I am getting the same error again:
> .libPaths()
[1] "C:/Users/USERID/Desktop/R"
"\\\\HOME.COMPANYNAME/USERNAME$/Files/R/R-3.5.1/library"
Error: invalid version specification ‘NA’
In addition: Warning message:
In utils:::packageDescription(packageName, fields = "Version") :
no package 'knitr' was found
Setting the new .libPath on the local folder C:/ allows me to install and load packages but only temporarly within the R Studio-session:
> install.packages("FDboost")
Installing package into ‘C:/Users/USERID/Desktop/R/R-3.5.1/library’
(as ‘lib’ is unspecified)
After quitting and restarting the R session, the newly defined .libPath on C:/ as well as the installed packages are deleted.
Maybe I have to add the .libPath to the filepath as recommended by #r2evans so that it is saved also after quitting the R session? I did not figure out how to do so...
For the last months, I was able to install and load packages from these two library paths, maybe there was an antivirus update that now makes problems? I did not change any settings but it seems like R cannot find or edit the installed packages anymore.
Deinstalling R or RStudio is not a possible solution, since I need admin rights to reinstall them.
Since other posts did not bring the solution so far, maybe anybody has more ideas?
When I install a package, the prerequisite packages were installed first before the actual package. I get the "unable to move temporary installation" warning for all the prerequisite packages, but no such warning for the actual package. But the package will give error when I load it.
For example, when I install.packages("mlr"), it installed all the dependencies and I got various warnings such as this:
package ‘BBmisc’ successfully unpacked and MD5 sums checked
Warning in install.packages :
unable to move temporary installation ‘D:\Documents\R\win-library\3.2\filef3811142c73\BBmisc’ to ‘D:\Documents\R\win-library\3.2\BBmisc’
I ignored it because it's just a warning. Unfortunately library(mlr) gave me Error: package ‘BBmisc’ required by ‘mlr’ could not be found, so I couldn't ignore it after all.
install.packages("BBmisc") directly didn't produce the warning.
What gives? How can I work through this, short of installing all the dependencies on my own?
In case session info needed:
> sessionInfo()
R version 3.2.2 (2015-08-14)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
locale:
[1] LC_COLLATE=English_Singapore.1252 LC_CTYPE=English_Singapore.1252
[3] LC_MONETARY=English_Singapore.1252 LC_NUMERIC=C
[5] LC_TIME=English_Singapore.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] tools_3.2.2
This problem is caused by the antivirus (most likely) as was suggested by user3710546. If you cannot disable the antivirus a workaround is to enable debugging in the package unzip function with this command:
debug(utils:::unpackPkgZip)
This will then allow you to step through the code (by pressing enter many times). This just makes the function run slower, giving the antivirus software time to complete its scanning of the new files before R wants to copy them.
I found this solution here.
Following way helped for me for windows 10:
I wanted to install shiny package and was getting same error.
I created "shiny" folder inside /library.
I did setwd to this shiny folder.
Then triggered bellow command: install.packages("shiny",destdir="./",lib="./")
It still failed with the same error, but now zips were downloaded in the shiny folder.
There were two zips: httpuv.zip and shiny.zip
I extracted contents of shiny zip into shiny folder and contents of httpuv zip in httpuv folder.
Restarted R studio to be safe. Then triggered library(shiny) and boom, it worked like a charm..!!!
I tried all the solutions suggested here and elsewhere. I'm running Windows 7 in a large company where antivirus etc. is forced.
The solution for me was:
Uninstall R and RStudio
Delete all files (including hidden) that has to do with R
Install R and RStudio as administrator
Run RStudio as administrator
Only downside is a warning when starting RStudio (running as admin).
All updates and installs works perfect.
If you run the below statement right before the install.packages expression then it should install the package:
trace("unpackPkgZip", where=asNamespace("utils"), quote(Sys.sleep(2.5)), at=14L
,print=FALSE)