wahani / modules

Modules in R

Home Page:https://cran.r-project.org/package=modules

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Managing Different Package Versions Between Modules

superRhero4 opened this issue · comments

I have an app that will access modules that us the same packages but different versions, and have written code that will change the libPath between each of these modules to point to the package manager of whatever project the chosen module is part of.

However, for some reason, the package versions from the previous module are not being washed away on the switch...they are lingering and, therefore, the chosen module picks them up without getting those in the new libPath.

Thank you for taking the time to report this. For the sake of completeness, here is what I wrote via mail:

It would be helpful if you can provide some code, so I can see what you are doing. From what I have understood so far, it sounds like you try to access the same package in two different versions in the same R session. I am not sure how R will handle that; if R can handle that.

There is a function called loadNamespace in base. It accepts the path to your lib and may be helpful to figure this out. A namespace, as far as I know, is loaded only once in a session. And a package, I believe, is uniquely identified by its name. So calling that function twice with a different argument for lib may not have an effect. Probably you have to unload and detach the package first, before you can load that other version. Unload and detach are on the same man page. Sometimes unloading will not work cleanly, in that case restarting the session is usually the goto option.

The modules package does not change any of that. It just adds a couple of things on top of it. I guess a module will just pick up the loaded namespace and do what it's asked to do. If you do a lot of loading and unloading, that will get pretty inefficient though.

Pls provide some code, so we can have a closer look at what is happening.

@superRhero4 were you able to figure a way out? I would be willing to give more feedback; but I would need to see some code.

Closed due to inactivity. Feel free to reopen, if the issue comes up again.