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]
}
Related
I am getting a circular dependency error for my R package when running CHECK:
checking package dependencies ... ERROR
There is circular dependency in the installation order:
One or more packages in
then a long list of packages.
However, my Depends category in DESCRIPTION is very minimal:
Depends: methods, R (>= 3.5.0), magrittr
And all other referenced packages are in either Imports or Suggests. One package I have in Imports also lists my package in their Imports, but I did not think that would lead to a dependency issue. I don't think any of the other packages I have in DESCRIPTION list mine in theirs.
I've searched quite a bit online but found no relevant solutions. Any ideas? Thanks in advance for the advice.
Session info:
R version 4.0.5 (2021-03-31)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Big Sur 10.16
Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib
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 base
loaded via a namespace (and not attached):
[1] compiler_4.0.5 tools_4.0.5 tinytex_0.31 xfun_0.28
Depends and imports both require a dependency. The main difference is that imports doesn't add items to the user's search path. See here or here. You can't list a package under your "imports" that lists you under their "imports" -- that part is the same as "depends." Packages use functions from packages all the time, but the sharing is just one-way.
One possible work-around is copying the function (with permission from the other package author) into your own package.
Another option that I've seen used by other packages is to move shared logic to a separate helper package and then both packages can Import that helper package.
Finally, if it's a function you don't really need you can move it to suggests and then check if that package is installed only when you need the function and can throw an error if not.
TL;DR
Unable to install any package from GitHub, System Error 267
I've newly setup R (v4.1), Rstudio and just installed devtools.
I also additionally installed Rtools40 and added it to my path (global environment)
Rtools seems to work properly as validated with: Sys.which("make") & maketools::rtools_find() (output below)
Problem
I am unable to install any package from GitHub, e.g. rstudio/gt. The error is nearly identical for any GitHub Package, allways stating system error 267
devtools::install_github("rstudio/gt")
Downloading GitHub repo rstudio/gt#HEAD
Error: Failed to install 'gt' from GitHub:
create process 'C:/PROGRA~1/R/R-41~1.0/bin/x64/Rcmd.exe' (system error 267, Der Verzeichnisname ist ungültig.
) #win/processx.c:1040 (processx_exec
Update
As suggested I reinstalled R 4.1.0 to the most simple folde possible C:/R/
The error ist still the same despite now lacking tildes ~
devtools::install_github("rstudio/gt")
Downloading GitHub repo rstudio/gt#HEAD
Error: Failed to install 'gt' from GitHub:
create process 'C:/R/bin/x64/Rcmd.exe' (system error 267, Der Verzeichnisname ist ungültig.
) #win/processx.c:1040 (processx_exec)
Update 2:
Changed the .libPaths to a folder without any special characters
.libPaths( c( "D:/tmp" , .libPaths() ) )
.libPaths()
[1] "D:/tmp" "C:/Users/Björn/Documents/R/win-library/4.1"
[3] "C:/R/library"
Error is still the same
Update 3:
I updated some packages, and checked the version of packageVersion('processx')= 3.5.2
install.packages("testthat")
install.packages("pkgload")
install.packages("devtools")
install.packages("remote")
Content of Sys.getenv
Sys.getenv('Path')
[1] "C:\\rtools40\\usr\\bin;C:\\R\\bin\\x64;C:\\rtools40\\usr\\bin;C:\\rtools40\\mingw64\\bin;
Diagnostics
Session Info
> sessionInfo()
R version 4.1.0 (2021-05-18)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19042)
Matrix products: default
locale:
[1] LC_COLLATE=German_Germany.1252 LC_CTYPE=German_Germany.1252 LC_MONETARY=German_Germany.1252
[4] LC_NUMERIC=C LC_TIME=German_Germany.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
Rtools successful installed / setup
Sys.which("make")
make
"C:\\rtools40\\usr\\bin\\make.exe"
maketools::rtools_find()
$version
[1] ‘4.0’
$compiler
[1] "gcc 8.3.0"
$api
[1] ‘8’
$PATH
[1] "C:\\rtools40\\usr\\bin"
$BINPREF
[1] "C:/rtools40/mingw$(WIN)/bin/"
$available
[1] TRUE
$compatible
[1] TRUE
The standalone mode of the remotes package solved the issue for me,
as suggested by the maintainer of processx (Gábor Csárdi) here
devtools::install_github() only calls remotes::install_github().
However, for the remotes, there is the option to be exectued in standalone mode
Source: Cran
Standalone mode
remotes will use the curl, git2r and pkgbuild packages if they are
installed to provide faster implementations for some aspects of the
install process. However if you are using remotes to install or update
these packages (or their reverse dependencies) using them during
installation may fail (particularly on Windows).
If you set the environment variable R_REMOTES_STANDALONE="true" (e.g.
in R Sys.setenv(R_REMOTES_STANDALONE="true")) you can force remotes to
operate in standalone mode and use only its internal R
implementations. This will allow successful installation of these
packages
With the following lines of code, gt was finally successfull installed from github.
Sys.setenv(R_REMOTES_STANDALONE="true")
remotes::install_github("rstudio/gt")
Thanks all the commentators for your help!
Update October / 2021
To avoid having to do these steps (Set in standanlone mode, and install with remotes) over and over again everytime you want to install a new package from github another convenient workaround is to just rollback to the previous version of processx as adviced by #rempsy in the github issue:
install.packages("pacman")
pacman::p_del(processx)
# Installing previous verison 3.5.1
install.packages("https://cran.r-project.org/src/contrib/Archive/processx/processx_3.5.1.tar.gz", repos=NULL, type="source")
After the rollback of processx to version 3.5.1, devtools::install_github() works as expected, e.g.
devtools::install_github("rstudio/gt")
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
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)