-
Notifications
You must be signed in to change notification settings - Fork 691
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
Sandbox commands should temporarily add .cabal-sandbox/bin to PATH #1120
Comments
BTW: The existing implementation for |
I haven't looked at any code, but I think if it works to just pass a modified environment when forking the process, then this would be preferable. |
Since we don't have a Shell monad yet, this will be much more intrusive than just calling |
I removed the dependency on
Do you know which systems don't support |
Hm, not sure. I think the type is also different on some systems. |
This is how
|
Yes, I think you are right. Only |
Here is what Git uses: https://github.com/git/git/blob/master/compat/setenv.c The only "ugly" thing with this implementation is that it leaks memory, but I think this is of no practical importance. |
I'm a bit uncomfortable adding with adding things to the system path and not removing them again (see my comment on the pull request). What if some non-sandbox code that runs some time later during the cabal process' lifetime executes some other command? That command might now look for binaries in the wrong place. |
@tibbe OK, I'll fix that. |
Fixed. |
Git is LGPL, so, IIUC, we can't just copy their code. |
I think that code is broken. AFAIK, Personally, I'd always write tests to ensure that my code behaves as expected. |
Yes.
Why? |
@23Skidoo Oh, sorry. I really missed the withSandboxBinDirOnSearchPath :: FilePath -> IO a -> IO a
withSandboxBinDirOnSearchPath sandboxDir action = bracket addBinDir (setEnv "PATH") (const action)
where
addBinDir :: IO ()
addBinDir = do
let sandboxBin = sandboxDir </> "bin"
oldPath <- getEnv "PATH"
let newPath = sandboxBin ++ (searchPathSeparator:oldPath)
setEnv "PATH" newPath
return oldPath This does not have the exact same semantics, though. The result is different if |
Yes, that's why I implemented it this way. |
@23Skidoo But shouldn't that be |
@sol Nice catch, thanks! |
@23Skidoo My point was really about testing. Once you have a proper testing infrastructure in place writing a test for that function takes almost no time, guarantees correctness and spares you from wrong accusations ;). |
Some libraries (e.g.
wx
) use custom preprocessors during the build process. When such libraries are installed into the sandbox, the build fails because the required executables are missing.We will need to add a cross-platform
setEnv
toCompat
, because it's missing fromSystem.Environment
. We can use an existing implementation by @sol, which he proposed for inclusion inbase
.The text was updated successfully, but these errors were encountered: