Is it possible to install a package without installing dependencies?
When run the following command:
install.packages("package",dependencies=FALSE)
if the dependencies are not installed beforehand, isn't it that the installation of the package fails?
My question comes from this post Install a local R package with dependencies from CRAN mirror. Why does it say installing a local package without installing dependencies?
if I set repos=NULL it correctly tries to install the local package
file (as documented), but obviously it does not find the dependencies
packages.
Thanks!
You cannot install and get a package to work without its dependencies. The dependencies= parameter is really an indicator if you would like R to automatically install the dependencies. If set to FALSE, R still stop and warn you so you can decide what you would like to do; if TRUE, R will automatically try to download from your current CRAN repository mirror. With repos=NULL (a local file install) there is nowhere else to look for dependencies so the dependencies= parameter is ignored.
Related
any one can suggest how to use conda in Linux to install R package from github?
Thanks!
According to this: https://github.com/conda/conda/issues/6674
You can create your own conda skeleton of a github derived R-package much as you would for a CRAN package.
Try doing
conda skeleton cran <github_url>
conda build --R=<my_r_version> r-<lower-case-package-name>
Then upload the built conda package to your own anaconda repository.
This will fail if any of the dependencies of the package are absent from the anaconda repos that you have access to. So you might have to conda-build a few other packages along the way.
Alternatively, you could install it directly with devtools::install_github(github_url, dependencies = FALSE). If you do go down this route, please ensure that any conda-available dependencies for the github package are already installed.
If you don't use dependencies = FALSE R will install.packages a bunch of updates. (As far as I can tell) When you install.packages a pre-installed package some_package in a conda env (eg, to update it) and then check conda list <some_package> on your current env, it will show the version that was installed by conda, rather than the updated version.
Edited build command, following #rpanai s suggestion
any one can suggest how to use conda in Linux to install R package from github?
Thanks!
According to this: https://github.com/conda/conda/issues/6674
You can create your own conda skeleton of a github derived R-package much as you would for a CRAN package.
Try doing
conda skeleton cran <github_url>
conda build --R=<my_r_version> r-<lower-case-package-name>
Then upload the built conda package to your own anaconda repository.
This will fail if any of the dependencies of the package are absent from the anaconda repos that you have access to. So you might have to conda-build a few other packages along the way.
Alternatively, you could install it directly with devtools::install_github(github_url, dependencies = FALSE). If you do go down this route, please ensure that any conda-available dependencies for the github package are already installed.
If you don't use dependencies = FALSE R will install.packages a bunch of updates. (As far as I can tell) When you install.packages a pre-installed package some_package in a conda env (eg, to update it) and then check conda list <some_package> on your current env, it will show the version that was installed by conda, rather than the updated version.
Edited build command, following #rpanai s suggestion
I'm running R CMD INSTALL --build package on a windows computer. My package imports a couple of other packages which themselves depend on some more packages. I have all dependencies installed in the local r_libs folder and everything works.
Now sometimes I have the my package source code on a different windows computer. On this computer I don't have all the dependency packages installed.
When I try to use R CMD INSTALL --build package, I get the obvious "ERROR: dependencies 'package a', 'package b', etc, are not available for package".
My question is: Can I build the package using R CMD INSTALL --build without the dependency checks and without removing the Import and Depends entries in the DESCRIPTION file?
After consulting --help, I tried the --no-test-load option but no luck.
I reckon you want to build a .zip binary version of the package on a computer where not all dependencies are installed. And I'm afraid I'll have to disappoint you, as this won't be possible.
Building a binary package is done in two steps: first the package is installed from source (that's why you have to use R CMD INSTALL and then the created binaries are zipped in a convenient format for installation on a windows machine. The dependencies are checked at time of installation from source, and any missing dependencies will throw the error you're facing.
As R needs information from the dependencies at time of installation from source, you can't get around installing them before building the whole thing. This also makes sense. An installed package in R contains a set of .rds files which contain package information in a more convenient format for R. In order to create that information for the NAMESPACE file, it needs to be able to access the packages from which functions are imported. If not, it can't construct the correct information about the namespace.
So your only option is to install the dependencies on the computer you use to build. And if you actually want to use the package on that computer, you'll have to install those dependencies anyway.
More information:
R Internals : https://cran.r-project.org/doc/manuals/r-release/R-ints.html#Package-Structure
Writing R Extensions: https://cran.r-project.org/doc/manuals/r-release/R-exts.html#Package-namespaces
The package is available on this website.
http://cran.r-project.org/src/contrib/Archive/rlandscape/
When I use:
install.packages("rlandscape",
repos = "http://cran.r-project.org/src/contrib/Archive/rlandscape/",
type="source")
I get the following error:
package 'rlandscape' is not available (for R version 3.1.2)
I have tried older versions too but no luck..
The devtools package has a function that can install archived versions. Try:
library("devtools")
install_version("rlandscape",version="1.0",
repos="http://cran.r-project.org")
(You should be able to use repos=getOption("repos")["CRAN"] instead, but it looks like your repos option is slightly messed up, i.e. the URL is missing the http://.)
(The repos argument is necessary to work around what I think is a glitch in install_version, i.e. it assumes that repos is a length-1 character vector.)
This should, I think, also automatically install appropriate dependencies -- although it's a bit of a catch-22 if they are in the CRANextra repository for Windows, since that has to be suppressed in order to get install_version to work ...
It may also be the case that install_version automatically assumes that you want the package and all dependencies installed as source (not binary) installations, in which case you will need to have compilation tools installed. The rlandscape package doesn't actually have any compiled code included, but its dependencies do ...
This is an old (archived) package that is no longer supported. If you really need it, you can install it using R CMD INSTALL but you need also to install all its dependencies manually.
Installing your desired package gave me the following:
>R CMD INSTALL ~/Downloads/rlandscape_1.0.tar.gz
* installing to library ‘/Users/mohamedahmed/Rlibs’
ERROR: dependencies ‘spatstat’, ‘deldir’, ‘gWidgets’, ‘gWidgetsRGtk2’ are not available for package ‘rlandscape’
* removing ‘/Users/mohamedahmed/Rlibs/rlandscape’
I am not sure all dependencies are still available on CRAN, but it seems to be challenging task.
I'm developing a R package that depends on another R package being installed on the users system.
I've added a Depends:pkgname in the DESCRIPTION file and import(pkgname) in the NAMESPACE. What I was hoping this would do is check if pkgname is already installed and if not install.packages(pkgname,repos="CRAN or Rforge or wherever the package is") if not.
However upon attempted installation of my package i get the error:
ERROR: dependency 'pkgname' is not available for package 'mypkg'
Does anyone know how to implement an installation of pkgname, should pkgname not already be on the system?
Many thanks
In the help file of R CMD INSTALL there is no mention of a flag to install additional packages if needed for dependencies. If you submit your package to CRAN, your problems are solved because install.packages then solves any dependencies. install.packages does not support solving dependencies when installing from a local file.
Until you submit to either R-forge or CRAN, I think it will suffice to add a remark to the README file that a few additional packages need to be present. You could even post a snippet of R code containing the needed install.packages command.