I try to test my package developed on Ubuntu 16.04 with Windows 7. For both platforms I work on R 3.3.1 (but I also test on 3.3.0).
My package is saved on my GitHub repo (https://github.com/charlottesirot/elementR). When I run this command from Ubuntu, no problem happens:
library(devtools)
install_github("charlottesirot/elementR", dependencies = T , force = T)
but with windows 7, I have the following answer:
Downloading GitHub repo charlottesirot/elementR#master from URL
https://api.github.com/repos/charlottesirot/elementR/zipball/master
Installing elementR "C:/PROGRA~1/R/R-33~1.1/bin/i386/R" --no-site-file
--no-environ --no-save --no-restore --quiet CMD \ INSTALL \ "C:/Users/Cha/AppData/Local/Temp/RtmpUX1GVA/devtoolsa907a336b/charlottesirot-elementR-103e064"
\ --library="C:/Users/Cha/Documents/R/win-library/3.3"
--install-tests
installing source package 'elementR' ...
** R
** inst
** preparing package for lazy loading Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) : there is no
package called 'XML' ERROR: lazy loading failed for package 'elementR'
removing 'C:/Users/Cha/Documents/R/win-library/3.3/elementR' Error: Command failed (1)
As I understand, R tries to install the dependencies of my package (e.g. Shiny...) but it does not manage to install the dependencies of the dependencies (e.g. XML from gnumeric package)
Thus I try to manually install XML thinking that perhaps there was a problem with XML and then:
installing source package 'elementR' ...
** R
** inst
** preparing package for lazy loading Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) : there
is no package called 'gtools' ERROR: lazy loading failed for package
'elementR'
removing 'C:/Users/Cha/Documents/R/win-library/3.3/elementR'
I cannot install all the packages manually, it does not make sense !!!
Moreover when I try something less cryptic than my package, thinking that I could makea mistake in my code:
install_github("hadley/ggplot2", force = T)
installing source package 'ggplot2' ...
** R
** data
*** moving datasets to lazyload DB
** inst
** tests
** preparing package for lazy loading Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) : there is no package called 'assertthat' ERROR: lazy loading failed for package 'ggplot2'
removing 'C:/Users/Cha/Documents/R/win-library/3.3/ggplot2'
restoring previous 'C:/Users/Cha/Documents/R/win-library/3.3/ggplot2' Error: Command failed (1
)
I think there is a problem from the install_github ???
What do you think ??
Here is my Namespace:
exportPattern("^[[:alpha:]]+")
importFrom(R6, R6Class)
importFrom(shinyjs, colourInput)
importFrom(shinyjs, delay)
importFrom(shinyjs, useShinyjs)
importFrom(gnumeric, read.gnumeric.sheet)
importFrom(abind, abind)
importFrom(tcltk2, tk2text)
importFrom(gdata, read.xls)
importFrom("readODS", read.ods)
importFrom("grDevices", "bmp", "colorRampPalette", "dev.off", "jpeg",
"png", "rainbow", "tiff")
importFrom("graphics", "abline", "layout", "legend", "mtext", "par",
"plot", "points", "rect", "text", "title")
importFrom("stats", "sd")
importFrom("utils", "read.table", "write.csv", "write.table")
import(shinydashboard, shiny, stringr, lmtest, reader, devtools, tcltk)
For me, it looks ok but what do you think ?
I looked at a lot of article on internet but I only found one message which is exactly the same than my case but it is not enough informative :
Cannot install "flexdashboard package"
I am totally stuck at this point and I would like to have your help regarding this issue.
Thank you verrrrrry much in advance !!
CHa
Recently, I encountered a similar or maybe related issue. As it turned out, there was a bug in devtools install_github, missing the correct installation of dependencies, despite dependecies=TRUE. Have a look at: Does install_github recursively install dependencies? If the problem persists, better contact the authors directly via their github repository.
Plus, I just observed another issue arising after a Windows update, during which permissions seemed to have been altered to download or update packages into personal Win User libraries instead of the "default" R library folder. I suspect devtools seemed consequently lost as to which packages were loaded or available at which versioning. A fresh R reinstallation (i.e., library folder cleansing) solved that issue, but such may not always be convenient.
Related
I'm distributing an R package that requires other packages. If any are missing I get (for example) the following error:
library(whSample)
Error: package or namespace load failed for ‘whSample’ in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]):
there is no package called ‘dplyr’
I have code to check and install dependencies in the whSample package, but R fails before it gets to it when it sees the import(dplyr) in NAMESPACE. Here's the first block of code when the package function is called:
is_installed <- function(mypkg) is.element(mypkg, installed.packages()[,1])
whInstall <- function(pkgNames){
for(pkg in pkgNames){
if(!is_installed(pkg)){
install.packages(pkg, repos="http://lib.stat.cmu.edu/R/CRAN")
}
suppressMessages(suppressWarnings(
library(pkg, character.only=T, quietly=T, verbose=F)))
}
}
whInstall(c("magrittr","tools","purrr","openxlsx","data.table","dplyr","glue"))```
How can I get R to do these checks without running afoul of NAMESPACE?
A short answer is that you can ask people to install with
devtools::install_local("your-package.tar.gz")
What's happening behind the scene is that install.packages ignores the dependencies option when installing from a local file. It somehow assumes that the repository from which your are installing the package should also have the dependent packages. But for local files there is no repository, hence no dependency handling occurs.
When you install the package from a local file, install is going to search for dependencies on the same local path... and won't find them.
To get the CRAN dependecies automatically installed, you can use :
install.packages("devtools")
devtools::install_local("MypackageName.zip")
So I have been hitting my head against the wall for a few days now trying to understand why my machine will not load choroplethrZip. I have tried the recommended installation pathway (with devtools and github) but I keep receiving the error message below:
#install.packages("devtools")
library(devtools)
install_github('arilamstein/choroplethrZip#v1.5.0')
Downloading GitHub repo arilamstein/choroplethrZip#v1.5.0
from URL https://api.github.com/repos/arilamstein/choroplethrZip/zipball/v1.5.0
Installing choroplethrZip
"C:/PROGRA~1/R/R-35~1.0/bin/x64/R" --no-site-file --no-environ --no-save --no-restore --quiet CMD INSTALL \
"C:/Users/dbrennan/AppData/Local/Temp/Rtmp0q4jjY/devtools29fc168c68f5/arilamstein-choroplethrZip-3cbc9f3" \
--library="C:/Users/dbrennan/Documents/R/win-library/3.5" --install-tests
* installing *source* package 'choroplethrZip' ...
** R
** data
** inst
** tests
** byte-compile and prepare package for lazy loading
Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) :
namespace 'choroplethr' 2.2.0 is being loaded, but >= 3.3.0 is required
ERROR: lazy loading failed for package 'choroplethrZip'
* removing 'C:/Users/dbrennan/Documents/R/win-library/3.5/choroplethrZip'
In R CMD INSTALL
Installation failed: Command failed (1)
I have tried restarting r and running the code immediately, as well as restarting the computer itself. I have also tried to read the package zip file into R directly but that has not worked either. Any help would be greatly appreciated.
Buried within the error message is this:
namespace 'choroplethr' 2.2.0 is being loaded, but >= 3.3.0 is required
And in fact, if you look at the DESCRIPTION page of choroplethrZip you will see that it imports "choroplethr (>= 3.3.0)".
Since you only have version 2.2.0 installed, I recommend typing:
update.packages()
which will update all your packages. Then try installing and loading choroplethrZip again.
I had everything working with R and RStudio, but then I moved the folders when cleaning up my computer directories & files. Now I'm getting the error message below.
Should R and RStudio be installed under Program Files or Program Files (x86)? Should I have two libPaths?
install.packages("C:/Users/kevin/Downloads/fpp_0.5.zip", repos = NULL)
## Warning in install.packages :
## package ‘C:/Users/kevin/Downloads/fpp_0.5.zip’
## is not available (for R version 3.0.0)
## Installing package into ‘C:/Users/kevin/Documents/R/win-library/3.0’
## (as ‘lib’ is unspecified)
## package ‘fpp’ successfully unpacked and MD5 sums checked
library("fpp", lib.loc="C:/Users/kevin/Documents/R/win-library/3.0")
Loading required package: forecast
## Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) :
## there is no package called ‘colorspace’
## Error: package ‘forecast’ could not be loaded
When you install the package using the RStudio package installer or directly from CRAN, it doesn't install the dependencies ("fracdiff", "Rcpp", "RcppArmadillo" and "colorspace") and hence, R keeps throwing the load namespace error. Installing the package through, automatically installs all the dependencies and solves this problem.
install.packages("forecast",
repos = c("http://rstudio.org/_packages",
"http://cran.rstudio.com"))
The last time I encountered a very similar problem, I used this code which I got somewhere:
install.packages("package's name", repos=c("http://rstudio.org/_packages", "http://cran.rstudio.com"))
simply put your package's name in the quotation marks.
Hope this helps.
Use this:
install.packages("colorspace", dependencies = TRUE)
I ran into this problem. It turned out that my .Rprofile had calls to a package that was not installed. Removing these lines allowed installation to proceed normally.
I got this error while installing the library 'tidyverse'. Removed the error by upgrading R from v3.4 to v3.6
I was trying to install twitteR, but the install failed, saying I needed httr >0.6 and I only had 0.3.
I tried to update httr. However, I seemed to have to 2 versions simultaneously, and when I used library(twitteR) it still said I had httr 0.3 and needed 0.6 (sorry I don't have the exact error messages anymore, and can't replicate due to the problems below.)
So, I deleted httr with remove.packages('httr') (this was a mistake).
Now I cannot load devtools
> library(devtools)
Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) :
there is no package called ‘httr’
Error: package or namespace load failed for ‘devtools’
or install packages
install.packages('httr')
'''Some lines skipped'''
Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) :
there is no package called ‘httr’
Error: package or namespace load failed for ‘devtools’
Execution halted
I get the same error message as above when trying to install httr from a tarball with R CMD INSTALL.
I'm pretty stuck. Is it time for a clean R install?
And for future reference, how do I update httr?
My best guess -- you have something in your ~/.Rprofile that's attempting to load httr (or a package that uses httr) -- since surely, nothing in base R relies on httr.
I believe install.packages() launches an R sub-process (using the same arguments on load as the current session), which in turn will source that ~/.Rprofile, and cause the errors you are seeing.
If I am correct, one solution would be to move / comment out your ~/.Rprofile and restore it after re-installing httr. Alternatively, launching R with the --vanilla flag (to suppress any site / profile loading) should also help in alleviating the problem.
Running R as R --vanilla fixed the problem.
I could then install httr with
install.packages('httr')
And then loading devtools works and installing twitteR then works as well.
I had everything working with R and RStudio, but then I moved the folders when cleaning up my computer directories & files. Now I'm getting the error message below.
Should R and RStudio be installed under Program Files or Program Files (x86)? Should I have two libPaths?
install.packages("C:/Users/kevin/Downloads/fpp_0.5.zip", repos = NULL)
## Warning in install.packages :
## package ‘C:/Users/kevin/Downloads/fpp_0.5.zip’
## is not available (for R version 3.0.0)
## Installing package into ‘C:/Users/kevin/Documents/R/win-library/3.0’
## (as ‘lib’ is unspecified)
## package ‘fpp’ successfully unpacked and MD5 sums checked
library("fpp", lib.loc="C:/Users/kevin/Documents/R/win-library/3.0")
Loading required package: forecast
## Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) :
## there is no package called ‘colorspace’
## Error: package ‘forecast’ could not be loaded
When you install the package using the RStudio package installer or directly from CRAN, it doesn't install the dependencies ("fracdiff", "Rcpp", "RcppArmadillo" and "colorspace") and hence, R keeps throwing the load namespace error. Installing the package through, automatically installs all the dependencies and solves this problem.
install.packages("forecast",
repos = c("http://rstudio.org/_packages",
"http://cran.rstudio.com"))
The last time I encountered a very similar problem, I used this code which I got somewhere:
install.packages("package's name", repos=c("http://rstudio.org/_packages", "http://cran.rstudio.com"))
simply put your package's name in the quotation marks.
Hope this helps.
Use this:
install.packages("colorspace", dependencies = TRUE)
I ran into this problem. It turned out that my .Rprofile had calls to a package that was not installed. Removing these lines allowed installation to proceed normally.
I got this error while installing the library 'tidyverse'. Removed the error by upgrading R from v3.4 to v3.6