I have created an R package (not yet on CRAN) and sent it to a colleague (as a .zip file).
Unfortunately, they were unable to properly build/install it without R throwing an error.
The error received was:
Error: Command failed (1)
In addition: Warning message:
The following packages are referenced using Rcpp::depends attributes however are not listed in the Depends, Imports or LinkingTo fields of the package DESCRIPTION file: RcppProgress
To create the package, I used the RcppArmadillo.package.skeleton() function in R v. 3.4.3.
I works for me, but not for my colleague.
My method in building/installing is:
build("package name") # creates a .tar.gz file
install("package name")
Would simply sending the .tar.gz file to my colleague and simply running install() work?
Here is the DESCRIPTION file:
Package: HACSim
Type: Package
Title: Iterative simulation of species haplotype accumulation curves
Version: 1.0
Date: 2018-04-06
Author: Jarrett Phillips
Maintainer: Jarrett Phillips
Description: Iterative simulation of species haplotype accumulation curves for assessment of sampling completeness
License: GPL (>= 3)
NeedsCompilation: Yes
Imports: ape (>= 5.0),
boot (>= 1.3-20),
investr (>= 1.4.0),
mgcv (>= 1.8-23),
pegas (>= 0.10),
Rcpp (>= 0.12.16),
scam (>= 1.2-2)
LinkingTo: Rcpp,
RcppArmadillo
and NAMESPACE
useDynLib(HACSim, .registration=TRUE)
importFrom(Rcpp, evalCpp)
importFrom(ape, base.freq)
importFrom(ape, read.dna)
importFrom(boot, boot)
importFrom(boot, boot.ci)
importFrom(investr, predFit)
importFrom(MASS, mvrnorm)
importFrom(mgcv, gam)
importFrom(mgcv, gam.check)
importFrom(mgcv, predict.gam)
importFrom(pegas, haplotype)
importFrom(rootSolve, uniroot.all)
importFrom(rootSolve, multiroot)
importFrom(scam, scam)
importFrom(scam, scam.check)
importFrom(scam, predict.scam)
exportPattern("^[[:alpha:]]+")
The error is
The following packages are referenced using Rcpp::depends attributes \
however are not listed in the Depends, Imports or LinkingTo fields of\
the package DESCRIPTION file: RcppProgress
which seems plausible given what you now posted for DESCRIPTION and NAMESPACE.
So here is what I would do:
Create the package using the skeleton generator as you have. Extend as neeed as you have. Then ...
Run R CMD build mypackage then
Run R CME check mypackage_1.2.3.tar.gz
This should give you a clear idea as to whether your sources are in good shape. After that, you can create a binary or zip or ... which your colleague should be able to utilise.
Edit: And you should of course grep for RcppProgress upon which you may indeed have an undeclared dependency.
Related
I have a private package stored locally (and version-controlled via SVN). To install the package, I am asking the user to SVN-update his/her package directory, then setwd() on the directory, and then devtools::install().
This package imports many CRAN packages, which are not stored locally. These imported packages are not auto-installing during the installation, which produces the error message Dependency package foo not available. The user must manually install install.packages('foo'), then try again, only to get Dependency package bar not available, ad nauseam, even though foo and bar are among my Imports:
Details:
My DESCRIPTION file looks like:
Package: apackage
Type: Package
Title: Package to Do Stuff
Version: 1.11111
Date: 2017-03-02
Author: C8H10N4O2
Maintainer: C8H10N4O2<C8H10N4O2#example.com>
Description: Package that does many useful things
License: file LICENSE
Depends:
R (>= 3.3.0)
Imports:
bit64 (>= 0.9.5),
data.table (>= 1.9.6),
extrafont (>= 0.17),
foreach(>= 1.4.3),
ggplot2 (>= 2.0.0),
gbm (>= 2.1),
grid (>= 3.2.3),
gridExtra (>= 2.0.0),
httr (>= 1.1.0),
readxl (>= 0.1.1),
scales (>= 0.4.0),
xlsx (>= 0.5.7)
LazyData: true
RoxygenNote: 5.0.1
Suggests: testthat (>= 0.9.1)
But upon invoking check() or load_all() I still get the error:
Error in (function (dep_name, dep_ver = NA, dep_compare = NA) :
Dependency package gridExtra not available.
And then my user has to install.packages('gridExtra'), and then he/she gets another dependency not available error.
What I have tried:
According to R packages:
Imports: packages listed here must be present for your package to
work. In fact, any time your package is installed, those packages
will, if not already present, be installed on your computer
(devtools::load_all() also checks that the packages are installed).
I also checked Writing R Extensions but couldn't find anything else on this topic.
Am I correct that these packages should be auto-installing, and what should I do to ensure that they auto-install?
I recognize that the problem is not fully reproducible, but I can't link to my repo, so I'm happy to provide any additional details.
**versions**
R 3.4.0, platform = x86_64-w64-mingw32
devtools 1.13.1
You are reinventing packaging with R. I advise against. You could just drat to create a repository. This is tried and true and works.
And this deployment aspect, for both production of local packages as well as their use and installation is entirely orthogonal to where you keep sources. Don't mistake a source code repository for code distribution mechanism.
In sum, using drat locally along with local GitHub Enterprise instance has worked swimmingly for us at work, and drat in general is in fairly widespread use.
(Usual disclaimers as I am the one who started drat, but I had the good fortune of a bunch of contributors too.)
I am attempting to prepare a package for submission to the CRAN. In my DESCRIPTION file I include non-CRAN packages in the Depends and Suggests arguments. To tell R where to find the non-CRAN packages, I include the Additional_repositories argument; and I include an .onLoad function at the top of my program (i.e., in 'zzz.R'). I am able to build and check (--as-cran) in RStudio with zero warnings, notes or errors so long as all the Depends and Suggests packages are present. I then use devtools::build() to create a .tar.gz file locally.
To test for a successful local install, I remove the non-CRAN packages from my computer and attempt to install the .tar.gz file that I created. I then get the message:
ERROR: dependency 'smwrQW' is not available for package 'baytrends'
I've read through the
R package dependencies not installed from Additional_repositories
Include non-CRAN package in CRAN package
http://thecoatlessprofessor.com/programming/r-data-packages-in-external-data-repositories-using-the-additional_repositories-field/
How should I deal with "package 'xxx' is not available (for R version x.y.z)" warning?
Unfortunately, the above error continues. I'm confident of the url I'm using since the below install.package line works when run independently
install.packages('smwrQW',repos=c("http://owi.usgs.gov/R"),dependencies = TRUE)
The applicable bits of the DESCRIPTION and zzz.R file are below:
DESCRIPTION:
Date: 2017-03-15
Depends:
R (>= 3.2.0),
lubridate,
mgcv,
smwrQW
License: GPL-3
LazyData: TRUE
RoxygenNote: 6.0.1
Suggests:
dataRetrieval,
devtools,
fitdistrplus,
knitr,
nlme,
pander,
plyr,
rmarkdown,
smwrBase,
smwrGraphs,
smwrStats,
testthat
Additional_repositories: http://owi.usgs.gov/R
VignetteBuilder: knitr
zzz.R:
.onLoad <- function(libname = find.package("baytrends"), pkgname = "baytrends"){
repos = getOption("repos")
repos["USGS"] = "http://owi.usgs.gov/R"
options(repos = repos)
invisible(repos)
# declaration of global variables (https://stackoverflow.com/questions/9439256)
if(getRversion() >= "2.15.1")
utils::globalVariables(c("begin", "methodsList"))
invisible()
}
.onAttach <- function(libname = find.package("baytrends"), pkgname = "baytrends"){
packageStartupMessage("This software program is preliminary or provisional and is subject to revision. ")
}
You cannot have packages from non-standard repos in Depends: or Imports:.
You can have them in Suggests:
Several packages do this; one you could look at is hurricaneexposure which uses this to make a 'too-large-for-CRAN' data package hurricanexposuredata available from a repository created via drat.
So you must move the smwrQR package to Suggests: and then test for it.
Brooke and I have a draft paper (under review) on this which we could send you if you drop us line -- it details all this more than the short answer could.
Recently my package on R-Forge failed to build on windows, not linux. Apparently packages kknn and trimTrees are not available. I cannot figure out why or why these two packages are different from randomForest or rgl which installs automatically. I have tried to include package names in description file in Depends-field and/or in Imports-field. Nothing works...
If installing my package from r-forge repos, with randomForest and trimTrees package removed, first mentioned will install automatically second will fail and have to be installed manually first. Why is this?
I have already read the this answer
thanks alot, Soren
description file:
Package: forestFloor
Type: Package
Title: forestFloor
Version: 1.4
Date: 2015-05-19
Author: Soeren Havelund Welling
Maintainer: Soeren Havelund Welling <SOWE#DTU.DK>
Depends: R (>= 3.0.0), randomForest, trimTrees, rgl, kknn
Suggests:
Description: Visualizes Random Forrest with feature contributions.
SystemRequirements: OpenGL, GLU Library, zlib
License: GPL-2
Imports: Rcpp (>= 0.11.3), randomForest, trimTrees, rgl, kknn
LinkingTo: Rcpp
namespace
useDynLib(forestFloor)
importFrom(Rcpp, evalCpp)
importFrom(randomForest, randomForest)
importFrom(trimTrees, cinbag)
import(rgl)
import(kknn)
S3method(plot,forestFloor)
S3method(print,forestFloor)
export(forestFloor,
plot.forestFloor,
print.forestFloor,
box.outliers,
recTree,
vec.plot,
convolute_ff,
convolute_ff2,
convolute_grid,
show3d_new,
fcol,
randomForest,
plot3d,
kknn,
persp3d)
-----------log file from r forge ----------
using log directory 'R:/run/building/build_2015-05-19-12-04/RF_PKG_CHECK/PKGS/forestFloor.Rcheck'
using R version 3.2.0 Patched (2015-05-16 r68378)
using platform: x86_64-w64-mingw32 (64-bit)
using session charset: ISO8859-1
using option '--as-cran'
checking for file 'forestFloor/DESCRIPTION' ... OK
checking extension type ... Package
this is package 'forestFloor' version '1.4'
checking CRAN incoming feasibility ... NOTE
Maintainer: 'Soeren Havelund Welling '
New submission
The Title field is just the package name: provide a real title.
* checking package namespace information ... OK
* checking package dependencies ... ERROR
No repository set, so cyclic dependency check skipped
Packages required but not available: 'trimTrees' 'kknn'
See section 'The DESCRIPTION file' in the 'Writing R Extensions'
manual.
* DONE
Status: 1 ERROR, 1 NOTE
See
'R:/run/building/build_2015-05-19-12-04/RF_PKG_CHECK/PKGS/forestFloor.Rcheck/00check.log'
for details.
Run time: 6.77 seconds.
It turned out to be a current rForge server issue when it updated to R 3.2. The problem can for now be fixed manually by contacting admin. They're working on general fix also.
link to bug tracker
I'm using knitr to build an R package vignette. This process worked before R 3.0, but I haven't been able to rebuild the package under R 3.1.1.
When I try R CMD build I get an error message:
R CMD build Causata
* checking for file ‘Causata/DESCRIPTION’ ... OK
* preparing ‘Causata’:
* checking DESCRIPTION meta-information ... OK
* installing the package to build vignettes
* creating vignettes ...
ERROR Error in loadVignetteBuilder(vigns$pkgdir) :
vignette builder 'knitr' not found Calls: <Anonymous> -> loadVignetteBuilder
In addition:
Warning message: In tools::buildVignettes(dir = ".", tangle = TRUE) :
Files named as vignettes but with no recognized vignette engine:
‘vignettes/Causata-vignette.rnw’ (Is a VignetteBuilder field missing?)
Execution halted
My vignette file has a VignetteEngine call -- here are the first three lines:
% !Rnw weave = knitr
%\VignetteEngine{knitr::knitr}
%\VignetteIndexEntry{Model training and export}
My package description file includes a VignetteBuilder field:
VignetteBuilder: knitr
I think I'm following the instructions for Rnw vignettes, so I'm baffled by the error message I'm seeing.
Incidentally, if I try to build the vignette directly then everything seems to work perfectly. This command generates the vignette PDF:
tools::buildVignettes(dir=".", tangle=TRUE)
My trouble seems to be only with R CMD build. Why won't the build work?
Here's my complete package DESCRIPTION file for reference:
Package: Causata
Type: Package
Title: Analysis utilities for binary classification and Causata users.
Version: 5.0-1
Date: 2014-10-09
Author: Justin Hemann, David Barker, Suzanne Weller, Jason McFall
Maintainer: Justin Hemann <justin.hemann#nice.com>
Description: The Causata package provides utilities for
extracting data from the Causata application, training regression / classification
models, and exporting models as PMML for scoring.
Depends: R (>= 2.15.1)
Imports: XML, R.utils, rjson, RCurl, stringr, yaml, boot, foreach, data.table, glmnet, ggplot2, methods
Suggests: knitr, doMC, testthat, pROC, RODBC, RMySQL
VignetteBuilder: knitr
License: GPL
LazyLoad: yes
URL: www.nice.com
According to the feedback of Josh O'Brien, I guess you might have the same issue as him. If you want to add some custom library paths, I'd recommend you to do it in ~/.Renviron using the environment variable R_LIBS_USER, instead of defining the library paths in ~/.Rprofile or Rprofile.site. The latter seems to be ignored by R CMD build and R CMD check.
Or you can add Sys.setenv(R_LIBS_USER="/my/r-package/dir/") to ~/.Rprofile.
Hi I am following the tutorial here from Hilary and here from Hadley Wickham trying to create a dummy package.
However, my package need some external dependencies XML and RCurl in this case, when I run the command document, it will complain that:
> setwd('/home/datafireball/projects/Rprojects/rgetout/rgetout')
> document()
Error: could not find function "document"
> library(devtools)
> document()
Updating rgetout documentation
Loading rgetout
Loading required namespace: XML
Error in (function (dep_name, dep_ver = NA, dep_compare = NA) :
Dependency package XML not available.
>
Here is my DESCRIPTION file.
Package: rgetout
Title: A R package to get all the outlinks for a given URL
Version: 0.1
Authors#R: "Eric Cartman <Eric.Cartman#gmail.com> [aut, cre]"
Description: This package is intended to include as much web extraction functionality as much as possible. It starts with one function. getout will extract
all the outlinks for a given URL with a user-agent that you can customize.
Depends: R (>= 3.0.2)
Imports:
XML,
RCurl
License: MIT
LazyData: true
Here is the source code github repo if you want to get more info.
If you are having problems with this, even when you have the packages installed and loaded, I suggest you to do the following.
Delete the Imports: and Suggests: entries of your DESCRIPTION file.
Make sure you have usethis working by doing library(usethis)
Now start adding the libraries to your DESCRIPTION file, by running the following command on your console: usethis::use_package("dplyr") for any Imports: you need. Repeat this step for every library that is required.
In my case, dplyr was the one refusing to load. You can decide where the package will be located by doing: usethis::use_package("dplyr", "Suggests").
It is assumed that you will have the required tools / dependencies for developing a package when you are
doing so.
utils::install.packages has a dependencies argument that will attempt to install uninstalled packages on which a package depends / (in whichever way they are dependent (suggests/ depends/linkingTo).
devtools::install_github will perform similarly.
Installing a package and documenting it as a component of development are quiet different activities
.