-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Installation on custom envs fails due to PATH on .onLoad #619
Comments
pak starts a worker process which inherits the environment from its parent process. If you change the environment in the parent process, the worker process will not know about that. This will be fixed when pak will stop doing installations in a worker process. |
@gaborcsardi sorry didn't understand it very well, thinking in the examples, we are not performing any installation when we change PATH, the only difference is when we load the library, only load, if is loaded before the PATH change, it will fails. |
That would be pretty weird, pak does nothing with the PATH, except that it adds an extra directory to it during installation. I created a package that records the path during installation, and this is what I see:
pak adds the So I don't think there is much I can do here. |
well... is pretty weird this issue...., you can check the example I post above, is step be step to get this problem... I thought is on There is something to remember, this is like internally, if you check PATH, before and after the installation command, will be fine, this only happens inside the installation command... which is weird. My assumption is that |
I am not going to do that, because I don't have a windows container at hand and I won't install conda. I am afraid that you'd need to create a more minimal example, if you are convinced that pak drops the PATH somehow. AFAICT pak does nothing with the PATH, except that the subprocess will inherit it, and the subprocess starts when pak needs it. That way you'd indeed lose local PATH updates in the main process. |
@gaborcsardi Hi, I have updated the description of the issue, I have added a linux version, this time is a lot minimal! as you requested. I was pretty sad yesterday, took me a lot of time find why this happened... two weeks looking on this... and trying to write a good minimal example. From what you says, if pak has a subprocess that starts for example, with a installation, and that process keeps running, is used for further installations and keeps the same env vars, it will miss any change after the first installation, libraries, binaries... which is far from ideal. R also does not allow us some type of custom installations, like after/post scripts to handle things, so some installations would need to prepare some envs to work, we also need to isolate that envs instead of accumulate one over other, to do some installation tests is also useful change env vars. Maybe... a way to update the env vars of the subprocess with the main process could do the trick. |
Yes, that does happen, that was my very first comment. FWIW if you want to set the PATH for R, the best way to do that is in the system or the user environment file. See
in
We could do that I suppose. |
Thx for the fix! @gaborcsardi just to know, is possible to get the full env to the child? with some custom env installations PATH is not the only var that we can touch, and some apps can depends on extra variables. Is too hard do this? or there is more tech issues that complicate that? |
It is not hard to do that, that it does not work. Some of those env vars are set in the subprocess for a purpose, by use, by R or by the OS. We cannot just overwrite all of them with the ones in the parent process. Again, your best bet is to set up the environment before starting R. It is not just pak that does calculations in subprocesses. |
Sadly that can not be done easily, to test packages we can change the envs per package and similar, so there is no "static" env to be added, because some of them are generated in the code.... |
Hi!, this really took long time to find, I was building/installing some libraries while some dependencies was enable from conda/reticulate... some times it worked, others not, really hard to get what was happening!
So here the issue, when we load/call
pak
it will save the actual PATH, which causes if we add a new binary path for a particular installation it will fails because will use the PATH from load.There will be two sections, there is some minor differences, the windows and linux one, the linux one is a lot minimal than the windows one, just because was developed before requested by @gaborcsardi
Linux
Preparation
First we need to prepare a file, this will be called on file installation to test PATH.
Repository to test
I have prepared this one: https://github.com/latot/bugs/tree/pak_path2
The tricky part is in the configuration file:
https://github.com/latot/bugs/blob/f5e0ca722c78d5872033f5bb860bdf9480272cac/configure#L1
Which will call the binary
example
on install, if PATH is fine, then it will works, if not we will get the error.This will fails!
The main difference with windows, would be instead of install something, it will also works with
library(pak)
.This will works!
Windows
Here some steps as example this library to be built needs the Rust compiler, we will enable it from conda:
Some helper functions to handle PATH
Here the tricky part, in this moment if we follow correctly each instruction, we have not executed nor loaded nothing from
pak
.The next statements will works:
While this ones will fail:
So would be good for at least installations check the new PATH if has changed, it can affect some installations.
A workaround, before install something run:
unloadNamespace("pak")
Thx!
The text was updated successfully, but these errors were encountered: