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

Some execution functions lookup files incorrectly #2489

Closed
Blaisorblade opened this Issue Aug 14, 2016 · 2 comments

Comments

Projects
None yet
3 participants
@Blaisorblade
Collaborator

Blaisorblade commented Aug 14, 2016

To reproduce:

  1. Add to the PATH a non-executable git file
  2. Watch stack try and fail to execute that file, if needed when fetching.
$ > ~/.local/bin/git
$ ls -l ~/.local/bin/git
-rw-r--r--+ 1 pgiarrusso staff 0 Aug 14 11:22 /Users/pgiarrusso/.local/bin/git
$ stack build --dry-run
/Users/pgiarrusso/.local/bin/git: streamingProcess: runInteractiveProcess: exec: permission denied (Permission denied)
$ stack upgrade
Fetching package index .../Users/pgiarrusso/.local/bin/git: createProcess: runInteractiveProcess: exec: permission denied (Permission denied)

For the failure to occur on build, the package needs git dependencies, for instance:

resolver: lts-6.6

packages:
- '.'
- location:
    git: https://github.com/agda/agda
    commit: e3472d7c1441c0d6db66be9e094e9dbcb7c33735

I noticed this by chance while debugging #2241. I can't remove Git from OS X 10.11, but I tried shadowing it with a failing one and made a mistake.

The bug is thankfully not in the process package. Nor is stack itself doing the lookup—the bug is somewhere between System.Process.Read and its supporting libraries. BTW, System.Process.Read appears confusing to me.

$ stack runghc ./runProcess.hs
git version 2.9.0
First git done
git version 2.9.0

runProcess.hs:

import System.IO
import System.Process

args = ["--version"]
main = do
  (_, _, _, ph) <- createProcess (proc "git" args)
  ec <- waitForProcess ph
  hPutStrLn stderr "First git done"
  ph <- runProcess "git" args Nothing Nothing Nothing Nothing Nothing
  ec <- waitForProcess ph
  return ()
@Blaisorblade

This comment has been minimized.

Collaborator

Blaisorblade commented Aug 14, 2016

BTW, all that was on OS X, I haven't rechecked on Linux yet.

@Blaisorblade

This comment has been minimized.

Collaborator

Blaisorblade commented Aug 14, 2016

Ah, I had missed stack's findExecutable, the bug must be there!

Blaisorblade added a commit that referenced this issue Aug 14, 2016

Check executability in exec lookup (#2489)
Fix #2489. Nothing guarantees that files in the PATH are executable, and
Unix utilities handle this just fine.

@Blaisorblade Blaisorblade self-assigned this Aug 14, 2016

@mgsloan mgsloan added this to the P2: Should milestone Aug 15, 2016

@borsboom borsboom removed the in progress label Aug 16, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment