rstudio / packrat

Packrat is a dependency management system for R
http://rstudio.github.io/packrat/
401 stars 89 forks source link

Error when fetching sources #610

Closed isaactpetersen closed 4 years ago

isaactpetersen commented 4 years ago

Thanks for developing the wonderful packrat package. I'm using packrat version 0.5.0 in R 3.6.2 on a cluster. I get the following error when using packrat::snapshot():

Error in snapshotSources(project, activeRepos(project), allRecordsFlat) :
  Errors occurred when fetching source files:
Error : Command failed (1)

Failed to run system command:

        '/opt/ssoft/apps/2020.1/linux-centos7-sandybridge/gcc-9.2.0/r-3.6.2-qzhhzyx/rlib/R/bin/R' --vanilla CMD build '/Users/itpetersen/R/x86_64-pc-linux-gnu-library/3.6/RcppEigen' --no-manual --no-resave-data --no-build-vignettes

The command failed with output:
* checking for file '/Users/itpetersen/R/x86_64-pc-linux-gnu-library/3.6/RcppEigen/DESCRIPTION' ... OK
* preparing 'RcppEigen':
* checking DESCRIPTION meta-information ... OK
Warning in file(con, "r") :
  cannot open file 'man': No such file or directory
 ERROR
computing Rd index failed:cannot open the connection
Error : Command failed (1)

Failed to run system command:

        '/opt/ssoft/apps/2020.1/linux-centos7-sandybridge/gcc-9.2.0/r-3.6.2-qzhhzyx/rlib/R/bin/R' --vanilla CMD build '/Users/itpetersen/R/x86_64-pc-linux-gnu-library/3.6/RcppEigen' --no-manual --no-resave-data --no-build-vignettes

Here's the traceback:

4: stop("Errors occurred when fetching source files:\n", errors)
3: snapshotSources(project, activeRepos(project), allRecordsFlat)
2: snapshotImpl(project, available, lib.loc, dry.run, ignore.stale = ignore.stale,
       prompt = prompt && !dry.run, snapshot.sources = snapshot.sources,
       infer.dependencies = infer.dependencies)

Thanks in advance!

kevinushey commented 4 years ago

It's very surprising to me that snapshotSources() is attempting to build packages. Could you try something like the following:

install.packages("rlang")
trace(packrat:::system_check, quote(print(rlang::trace_back())))

and print the stack trace you see associated with the failed build call?

isaactpetersen commented 4 years ago

The package installation worked fine. Here's the trace I get from the second command:

> trace(packrat:::system_check, quote(print(rlang::trace_back())))
Tracing function "system_check" in package "packrat (not-exported)"
[1] "system_check"
kevinushey commented 4 years ago

Sorry -- after running that, please attempt to call packrat::snapshot(). You should see extra debug output after that.

isaactpetersen commented 4 years ago

Here's the output when trying packrat::snapshot():

> packrat::snapshot()

Adding these packages to packrat:
                     _
    RcppEigen          0.3.3.7.0
    TeachingDemos      2.12
    boot               1.3-24
    codetools          0.2-16
    crosstalk          1.1.0.1
    fastmap            1.0.1
    htmlwidgets        1.5.1
    httpuv             1.5.4
    later              1.1.0.1
    lazyeval           0.2.2
    lme4               1.1-21
    logspline          2.1.16
    manipulateWidget   0.10.1
    maptools           1.0-1
    miniUI             0.1.1.1
    minqa              1.2.4
    nloptr             1.2.2.1
    png                0.1-7
    promises           1.1.1
    rgl                0.100.54
    shiny              1.4.0.2
    sourcetools        0.1.7
    sp                 1.4-2
    tcltk2             1.2-11
    tkrplot            0.0-24
    webshot            0.5.2
    xtable             1.8-4

Upgrading these packages already present in packrat:
             from      to
    rlang   0.4.5   0.4.7

Fetching sources for RcppEigen (0.3.3.7.0) ... Tracing system_check(r_path, options, c(r_env_vars(), env_vars), ...) on entry
     █
  1. └─packrat::snapshot()
  2.   └─packrat:::snapshotImpl(...)
  3.     └─packrat:::snapshotSources(project, activeRepos(project), allRecordsFlat)
  4.       └─base::lapply(...)
  5.         └─packrat:::FUN(X[[i]], ...)
  6.           ├─base::try(...)
  7.           │ └─base::tryCatch(...)
  8.           │   └─base:::tryCatchList(expr, classes, parentenv, handlers)
  9.           │     └─base:::tryCatchOne(expr, names, parentenv, handlers[[1L]])
 10.           │       └─base:::doTryCatch(return(expr), name, parentenv, handler)
 11.           └─packrat:::getSourceForPkgRecord(...)
 12.             └─(function() {...
 13.               └─packrat:::build(...)
 14.                 ├─packrat:::with_libpaths(...)
 15.                 │ └─base::force(code)
 16.                 └─packrat:::R(cmd, path, quiet = quiet)
 17.                   ├─packrat:::in_dir(...)
 18.                   │ └─base::force(code)
 19.                   └─packrat:::system_check(...)
Fetching sources for rlang (0.4.7) ... OK (CRAN current)
Fetching sources for RcppEigen (0.3.3.7.0) ... Tracing system_check(r_path, options, c(r_env_vars(), env_vars), ...) on entry
     █
  1. └─packrat::snapshot()
  2.   └─packrat:::snapshotImpl(...)
  3.     └─packrat:::snapshotSources(project, activeRepos(project), allRecordsFlat)
  4.       └─base::lapply(...)
  5.         └─packrat:::FUN(X[[i]], ...)
  6.           ├─base::try(...)
  7.           │ └─base::tryCatch(...)
  8.           │   └─base:::tryCatchList(expr, classes, parentenv, handlers)
  9.           │     └─base:::tryCatchOne(expr, names, parentenv, handlers[[1L]])
 10.           │       └─base:::doTryCatch(return(expr), name, parentenv, handler)
 11.           └─packrat:::getSourceForPkgRecord(...)
 12.             └─(function() {...
 13.               └─packrat:::build(...)
 14.                 ├─packrat:::with_libpaths(...)
 15.                 │ └─base::force(code)
 16.                 └─packrat:::R(cmd, path, quiet = quiet)
 17.                   ├─packrat:::in_dir(...)
 18.                   │ └─base::force(code)
 19.                   └─packrat:::system_check(...)
Error in snapshotSources(project, activeRepos(project), allRecordsFlat) :
  Errors occurred when fetching source files:
Error : Command failed (1)

Failed to run system command:

        '/opt/ssoft/apps/2020.1/linux-centos7-sandybridge/gcc-9.2.0/r-3.6.2-qzhhzyx/rlib/R/bin/R' --vanilla CMD build '/Users/itpetersen/R/x86_64-pc-linux-gnu-library/3.6/RcppEigen' --no-manual --no-resave-data --no-build-vignettes

The command failed with output:
* checking for file '/Users/itpetersen/R/x86_64-pc-linux-gnu-library/3.6/RcppEigen/DESCRIPTION' ... OK
* preparing 'RcppEigen':
* checking DESCRIPTION meta-information ... OK
Warning in file(con, "r") :
  cannot open file 'man': No such file or directory
 ERROR
computing Rd index failed:cannot open the connection
Error : Command failed (1)

Failed to run system command:

        '/opt/ssoft/apps/2020.1/linux-centos7-sandybridge/gcc-9.2.0/r-3.6.2-qzhhzyx/rlib/R/bin/R' --vanilla CMD build '/Users/itpetersen/R/x86_64-pc-linux-gnu-library/3.6/RcppEigen' --no-manual --no-resave-data --no-build-vignettes

The command failed with outpu
> traceback()
4: stop("Errors occurred when fetching source files:\n", errors)
3: snapshotSources(project, activeRepos(project), allRecordsFlat)
2: snapshotImpl(project, available, lib.loc, dry.run, ignore.stale = ignore.stale,
       prompt = prompt && !dry.run, snapshot.sources = snapshot.sources,
       infer.dependencies = infer.dependencies)
kevinushey commented 4 years ago

Thanks -- I think I better understand what's going on now.

It looks like Packrat is treating your library directory as a "source" for installed packages, and is trying to build RcppEigen from "sources" as contained in that directory. That attempt is failing, because binaries are installed in the library paths, not sources.

I think the simplest fix would be to use:

packrat::snapshot(snapshot.sources = FALSE)

to tell Packrat to create the lockfile without attempting to pre-gather source package tarballs.

isaactpetersen commented 4 years ago

That worked, thank you! I'm new to packrat, so I greatly appreciate your help and your development of the package.