I am using the multicore package in R for parallelizing my code. However, if the tcltk package is loaded, forking processes with the multicore package will cause R to hang indefinitely. So I want to prevent tcltk from ever loading. I want an immediate error if any package tries to load it as a dependency. Is this possible?
Alternatively, can I unload a package after it has been loaded?
If immediately detaching the package after it's been attached is a good enough solution, then try something like the following:
If (as seems likely) the very act of loading & attaching the package is causing the problem, you might also pursue a strategy like the one sketched out in the comments to your question. Namely:
"C:/R/Library/dummy/"
..libPaths
by executing.libPaths(c("C:/R/Library/dummy/", .libPaths()))
.Then, if any package attempts to load tcltk, it will first look for packages in
"C:/R/Library/dummy/"
, and, finding one of that name, will load it for a moment (before it's immediately detached by the hook described above).Another way to avoid loading a particular package as a dependency is, based on the assumption that none of the functions you require depend on that package, would be to reference the functions you need using their namespace:
This way, you don't need to load the package with your function, and you don't inadvertently load the problem package.