Skip to content

install.packages and dependencies=TRUE

9 messages · Gábor Csárdi, Duncan Murdoch, Brian Ripley

#
Dear all,

I am trying to install a private package, with its dependencies. However, both

install.packages("sand_1.0.tar.gz", dependencies=TRUE, repos=NULL,
type="source")

and

install.packages("sand_1.0.tar.gz", dependencies="Suggests",
repos=NULL, type="source")

fail to install suggested packages:
[1] "network, sna, ape, ergm, mixer, vioplot, ROCR, fdrtool, huge"

Based on the docs, I got the (obviously wrong) impression, that it was
possible to install suggested packages. From ?install.packages,
dependencies argument:

          ?TRUE? means to use ?c("Depends", "Imports", "LinkingTo",
          "Suggests")? for ?pkgs? and ?c("Depends", "Imports",
          "LinkingTo")? for added dependencies: this installs all the
          packages needed to run ?pkgs?, their examples, tests and
          vignettes (if the package author specified them correctly).
Error in library(ergm) : there is no package called ?ergm?
Error in library(huge) : there is no package called ?huge?

What am I doing wrong, and more importantly, what is the correct way
to install _all_ dependencies of a package?

Thanks, Best,
Gabor
#
Answer to myself. 'dependencies' are

Not used if ?repos = NULL?.

Sorry for the noise.

Gabor
On Tue, Dec 17, 2013 at 11:26 AM, G?bor Cs?rdi <csardi.gabor at gmail.com> wrote:
#
On 17/12/2013 11:26 AM, G?bor Cs?rdi wrote:
The problem is with repos=NULL (i.e. a local install).  Since none of 
those dependencies are local, they aren't found and won't be installed.

I imagine some package has a function that does what you want, but I 
don't know it.  It wouldn't be hard to put one together as follows:

1.  install your package without its dependencies.
2.  use tools::package_dependencies() to find the (non-recursive) 
dependencies.
3.  install those, with their dependencies.

You could add a step to filter the list in 2 so that you don't 
re-install something that is already there.

Duncan Murdoch
#
Thanks!

Btw, install() from the devtools package can do this in theory, but
not in practice, because of a bug (it silently ignores "Suggests").
This is fixed in their github version.

Just to add something useful here.

Gabor

On Tue, Dec 17, 2013 at 11:36 AM, Duncan Murdoch
<murdoch.duncan at gmail.com> wrote:
#
[...]
This does not seem to work if the package had 'Depends' or 'Imports'
as well. What is the correct way to install a local package, so that
its dependencies are pulled from CRAN?
This does not seem to work, because the dependencies are only checked on CRAN.
In summary, it is not quite trivial to do this correctly, if you look
at devtools:::install_deps and and devtools:::parse_deps, it is not 10
lines of code.

Anyway, I can just take the code from devtools or use their unreleased version.

Thanks again,
Gabor

[...]
#
So apparently not as simple as I thought it would be.  So I'll tell you 
what I actually do:

I have a number of packages under development, some on CRAN, some not.  
I also work in multiple builds of R pretty frequently, so I like to 
install all my packages and commonly used ones from other people.  So I 
put together a little script that I can run that will install or update 
a list of about 20 packages.  Here it is, with the names deleted.

# Script to install current versions of commonly used packages

installed <- rownames(installed.packages())
old <- old.packages()

oldoptions <- options(repos = 
c(CRAN="http://probability.ca/cran",CRANextra="http://www.stats.ox.ac.uk/pub/RWin"))
pkgs <-    ------ a character vector of packages on CRAN ------
oldPkgs <- old[intersect(pkgs, rownames(old)),,drop=FALSE]
if (length(oldPkgs))
   update.packages(oldPkgs = oldPkgs)
pkgs <- setdiff(pkgs, installed)
if (length(pkgs))
   install.packages(pkgs, dep=c("Depends", "Imports"))

options(repos = c(options("repos"), 
"R-forge"="http://R-Forge.R-project.org"))
pkgs <- ------ packages to install from R-forge ------
oldPkgs <- old[intersect(pkgs, rownames(old)),,drop=FALSE]
if (length(oldPkgs))
   update.packages(oldPkgs = oldPkgs)
pkgs <- setdiff("patchDVI", installed)
if (length(pkgs))
   install.packages(pkgs)

MyR <- ------ the source directory where I keep my own packages ------
pkgs <- ------ packages to install from local source ------
pkgs <- setdiff(pkgs, installed)
if (length(pkgs))
   install.packages(file.path(MyR, pkgs), type="source", repos=NULL)

options(oldoptions)
#
The obvious idea to set up a local repository works.  It takes 5 mins at 
most.
On 17/12/2013 18:08, Duncan Murdoch wrote:

  
    
#
On 13-12-17 1:18 PM, Prof Brian Ripley wrote:
That makes a lot of sense to do on Unix-alikes, but less so on Windows. 
  A local repository of tarballs needs to be in src/contrib below the 
URL of the repository.  On Unix setting that up as a soft link to the 
real location would be trivial, but on Windows you'd probably want that 
to be the only path to the files, and that's not very convenient when 
you're already used to keeping them elsewhere.

Duncan Murdoch
#
On 17/12/2013 22:02, Duncan Murdoch wrote:
On Linux/OS X/Solaris I do use a soft link.

I have used junctions on Windows.  (I know they do not always work on 
Windows, but they do on the Win 7 systems I use.)