[Rcpp-devel] Access package installed into user library

Dirk Eddelbuettel edd at debian.org
Fri Dec 4 13:16:39 CET 2015


On 4 December 2015 at 12:31, Thomas Lin Pedersen wrote:
| Hi
| 
| While testing my package on an Amazon cloud instance using the Bioconductor AMI
| (https://www.bioconductor.org/help/bioconductor-cloud-ami/) I ran into the
| following problem I had not encountered on my work computer (A Mac OS X).
| 
| I have a C++ function that makes use of functionality in the igraph package, so
| to access this I have the following in my function:
| 
| Environment igraph("package:igraph");
| Function neighbors = igraph["neighbors”];
| 
| This worked fine on my work machine but gave the following error when tried on
| the Amazon instance:
| 
| 
| Error: cannot convert to environment
| 
| 
| I was able to reduce the error into trying to get access to a package
| environment that is installed outside the core package library. The instances
| created using the Bioconductor AMI have the following package storage
| structure:
| 
| 
| > .libPaths()
| [1] "/home/ubuntu/R-libs"      "/usr/local/lib/R/library"
| 
| 
| Any package residing in usr/local/lib/R/library will be loaded into the
| environment fine, while any package in /home/ubuntu/R-libs will throw the
| error.

So maybe don't install into /home/ubuntu/R-libs ?

There are no hardcoded path in Rcpp. This strikes me as a run-time config
(and hence not an Rcpp question for this list).

Dirk
 
| Minimal example:
| 
| library(Rcpp)
| 
| cppFunction('
|   void testFail() {
|     Environment testEnv("package:boot");
|   }
| ')
| 
| cppFunction('
|   void testSucces() {
|     Environment testEnv("package:stats");
|   }
| ')
| 
| testFail() # Will give error
| testSucces() # Will work
| 
| The session:
| 
| R version 3.2.2 (2015-08-14)
| Platform: x86_64-pc-linux-gnu (64-bit)
| Running under: Ubuntu 14.04.2 LTS
| 
| locale:
|  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8
|  [4] LC_COLLATE=en_US.UTF-8     LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8
|  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                  LC_ADDRESS=C
| [10] LC_TELEPHONE=C             LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
| 
| attached base packages:
| [1] stats     graphics  grDevices utils     datasets  methods   base
| 
| other attached packages:
| [1] Rcpp_0.12.1          BiocInstaller_1.20.0
| 
| loaded via a namespace (and not attached):
| [1] tools_3.2.2
| 
| 
| Best
| 
| Thomas Lin Pedersen
| 
| _______________________________________________
| Rcpp-devel mailing list
| Rcpp-devel at lists.r-forge.r-project.org
| https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

-- 
http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org


More information about the Rcpp-devel mailing list