Skip to content

[Rcpp-devel] How to detach a package completely

3 messages · Cipollini Fabrizio, Dirk Eddelbuettel

#
Dear everybody
I apologize whether this question has been already answered but I read the
documentation and I surfed the web without solving my issue.
For testing purposes, I need frequently
***to detach the previous version and attach a more recent built without
leaving the R session***.

I'm able to do this with the command
detach(name = "Hello", unload = TRUE, force = TRUE)
if I include in the source package a
zzz.R file
with the function
.onUnload <- function(libpath = NULL)
{
  library.dynam.unload("Hello", libpath)
}
("Hello" is the name of the package I used for testing)

However, if "Hello" links and imports "Rcpp" (and an import(Rcpp) directive
is included in NAMESPACE) all this stuff does not work, in the sense that
even detaching and building a new version of "Hello", the previous one is
attached.
On the other side, if I quit R and I open another session, the last version
of "Hello" is attached successfully.

I experimented different ways to solve the issue without any success.
Any help would be appreciated. I include my sessionInfo() below.

Best regards
Fabrizio Cipollini
R version 3.1.1 (2014-07-10)
Platform: x86_64-pc-linux-gnu (64-bit)

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
LC_TIME=custom.UTF-8       LC_COLLATE=en_US.UTF-8
LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8    LC_PAPER=en_US.UTF-8

 [8] LC_NAME=C                  LC_ADDRESS=C               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] Hello_2014.08-1

loaded via a namespace (and not attached):
[1] Rcpp_0.11.2
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20140830/f94c5760/attachment.html>
#
On 30 August 2014 at 09:14, Cipollini Fabrizio wrote:
| From time to time, I use R to develop my own packages.
| For testing purposes, I need frequently?
| ***to detach the previous version and attach a more recent built without
| leaving the R session***.

This has nothing to do with Rcpp.  

The most reliable way is to ... start fresh sessions. 

For which littler and Rscript are useful, so I something like the following
all the time: to test a given package, I load it (option -l or --packages,
takes a comma-sep. list) and exectute a function to test (option -e, or
--eval) via littler's r:

  edd at max:~$ r -l RcppZiggurat -e 'print(zrnorm(5))'
  [1] -1.1409054  0.8759027 -0.1969075 -0.1245053  0.2695581
  edd at max:~$ 

Next time I run this I know I have a fresh session.  RStudio reloads the
current session, and package, for you too.

Dirk
#
Dear Dirk
On Sat, Aug 30, 2014 at 1:46 PM, Dirk Eddelbuettel <edd at debian.org> wrote:

            
I figured that but since I tested only Rcpp, I searched the support of Rcpp
experts before any other ...
For which littler and Rscript are useful, so I something like the following
Ok. I take the point.

Thanks for your help and you terrific job with R.

Fabrizio Cipollini
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20140830/5aa75f6b/attachment.html>