1

I am trying to build R packages locally simply to standardize my code for my own benefit. I've no intention to post on CRAN or GitHub. What I would like to do is import packages I've already developed into a new package I'm developing.

For example:

  • call the first package pack_a and the second package pack_b.
  • pack_a does not have any dependencies and installs without any issues.
  • pack_b is dependent on pack_a so pack_a is referenced in the DESCRIPTION file of pack_b under the imports tag.

The problem I'm facing is that when I install pack_b (using devtools::install()) the following error comes up:

Skipping 1 unavailable package: pack_a

After looking through the code of devtools on GitHub it appears that it is looking on CRAN for the required packages using available.packages(). Of course my pack_a is not on CRAN so it fails to find it and then pack_b fails to install. I was hoping it would first check if pack_a is already installed in my default library and therefore not even try to re-install it.

So my question comes down to:

How do I specify where to find pack_a on my local drive when installing pack_b? And if that's not possible is there a switch to turn off installation of required packages during install?

A similar question was asked before and I'm not entirely sure but I think one of the suggestions was to add your local path to the repos argument of install.packages(). This did not work for me however.

Previous similar question: R package which imports SparkR (not on CRAN)

Any guidance would be much appreciated.

Community
  • 1
  • 1
Yabasa
  • 93
  • 1
  • 1
  • 8
  • If you want to use `repos` arg to your local directory you need to create expected dir structure, [drat](https://github.com/eddelbuettel/drat) package will help you with it. – jangorecki Apr 29 '16 at 01:27
  • Are you able to reproduce the problem using `utils::install.packages`? – jangorecki Apr 29 '16 at 01:29
  • @jangorecki, thanks for the pointer to drat. This will be useful for the future. It turns my issue had nothing to do with dependencies but in fact was because i had a file with the same name as my package saved in my library (not sure how it got there...) so feeling kind of stupid for asking the question now... – Yabasa May 06 '16 at 19:36

1 Answers1

1

I'm not entirely sure why you are having this issue without more details, as I do exactly as you describe for my own packages (both also not on CRAN) and have no issues.

Having said that, a simple solution if you know for sure that pack_a is installed before you install pack_b is to run:

devtools::install(dependencies = FALSE)
Luke W. Johnston
  • 954
  • 9
  • 17
  • Thanks for the response. If in fact the reason it was failing was the dependency issue this would be the correct answer so i'll accept it. In actual fact i was wrongly attributing that warning as the reason it was failing to install. It was actually failing because i had a file in my library with the same name as my package, therefore it couldn't create a new directory with the same name. I should have done more investigation before asking the question but thanks anyway, good to know this for future reference. – Yabasa May 06 '16 at 19:26
  • @Yabasa, when you say "a file in my library with the same name as my package", do you mean a directory? And was the name `pack_a` or `pack_b`? I'm getting the same `Skipping 1 unavailable package: local_packages_already_installed` error. Trying to figure out if I have the same cause of the error. Thanks. – Josh Jun 19 '19 at 12:26
  • 1
    @Josh It was a file and it was called pack_a. I'm not sure how it got there but i must have accidentally created it at some point. – Yabasa Aug 29 '19 at 13:47
  • Thanks. Was the pack_a file in your main R lib location (C:\Program Files\R\R-3.6.1\library on my Windows machine), or a local/personal (sorry, not sure of the terminology) library? I get the same error, though my installation succeeds. – Josh Aug 29 '19 at 17:22