Re: [Rd] Rscript fails with some packages (for example, h5)

2017-12-26 Thread Sun Yijiang
Hi Dirk, Thanks for the solution. Now I know the work-arounds, but still don't quite get it. Why does R_DEFAULT_PACKAGES has anything to do with library(methods)? If library(h5) works, it should just work, not depend on an environment variable. Rscript is not consistent with R, that's my confus

Re: [Rd] Rscript fails with some packages (for example, h5)

2017-12-26 Thread Dirk Eddelbuettel
On 26 December 2017 at 22:14, Sun Yijiang wrote: | Thanks for the solution. Now I know the work-arounds, but still don't | quite get it. Why does R_DEFAULT_PACKAGES has anything to do with | library(methods)? Because it governs which packages are loaded by default. And while R also loads 'metho

Re: [Rd] Rscript fails with some packages (for example, h5)

2017-12-26 Thread Dirk Eddelbuettel
On 26 December 2017 at 15:24, Sun Yijiang wrote: | After looking into C source code, I found that Rscript by default fills | environment variable R_DEFAULT_PACKAGES with | "datasets,utils,grDevices,graphics,stats", and it somehow fails some | package like h5. | | The problem here is, not setting

[Rd] Rscript fails with some packages (for example, h5)

2017-12-26 Thread Sun Yijiang
Consider this script (with h5 installed): $ cat test.R library(h5) name <- tempfile() f <- h5file(name) file.remove(name) $ Rscript test.R Error in initialize(value, ...) : cannot use object of class "character" in new(): class "H5File" does not extend that class Calls: h5file -> new -> initia