Repository navigation
Closed
Description
Hey,
I'm using a specific commit of hmatrix, and I randomly get this error when trying to build:
Failed to reset to commit 42a88fbcb6bd1d2c4dc18fae5e962bd34fb316a1, deleting and re-cloning.
I guess it might be caused in new versions as I was using the same stack.yaml file on my macOS before, and it worked perfectly.
stack.yaml
flags: {}
extra-package-dbs: []
packages:
- ../sibe
- location:
git: [email protected]:albertoruiz/hmatrix.git
commit: 42a88fbcb6bd1d2c4dc18fae5e962bd34fb316a1
subdirs:
- packages/base
- '.'
extra-deps:
- Chart-1.8
- Chart-cairo-1.8
- ansi-wl-pprint-0.6.7.3
- stemmer-0.5.2
- unix-2.7.1.0
- ansi-terminal-0.6.2.3
- ncurses-0.2.16
- random-1.1
resolver: lts-6.13Verbose output
$ stack build --verbose
Version 1.1.3, Git revision 63f203d7886801c9ec3c303db0c459f08687a3c8 x86_64 hpack-0.14.0
2016-09-03 14:54:26.853372: [debug] Checking for project config at: /home/mahdi/documents/workshop/flappy-rl/stack.yaml
@(Stack/Config.hs:828:9)
2016-09-03 14:54:26.853570: [debug] Loading project config file stack.yaml
@(Stack/Config.hs:846:13)
2016-09-03 14:54:26.854866: [debug] Checking whether stack was built with libgmp4
@(Stack/Config.hs:332:5)
2016-09-03 14:54:26.855067: [debug] Run process: /usr/bin/ldd /home/mahdi/.local/bin/stack
@(System/Process/Read.hs:277:3)
2016-09-03 14:54:26.863476: [debug] Process finished in 8 ms: /usr/bin/ldd /home/mahdi/.local/bin/stack
@(System/Process/Read.hs:277:3)
2016-09-03 14:54:26.863671: [debug] Stack was not built with libgmp4
@(Stack/Config.hs:336:14)
2016-09-03 14:54:26.863759: [debug] Trying to decode /home/mahdi/.stack/build-plan-cache/x86_64-linux/lts-6.13.cache
@(Data/Store/VersionTagged.hs:68:5)
2016-09-03 14:54:26.871585: [debug] Success decoding /home/mahdi/.stack/build-plan-cache/x86_64-linux/lts-6.13.cache
@(Data/Store/VersionTagged.hs:72:13)
2016-09-03 14:54:26.874927: [debug] Getting system compiler version
@(Stack/Setup.hs:350:17)
2016-09-03 14:54:26.875076: [debug] Run process: /usr/bin/ghc --info
@(System/Process/Read.hs:277:3)
2016-09-03 14:54:26.914747: [debug] Process finished in 39 ms: /usr/bin/ghc --info
@(System/Process/Read.hs:277:3)
2016-09-03 14:54:26.916594: [debug] Getting global package database location
@(Stack/GhcPkg.hs:54:5)
2016-09-03 14:54:26.916718: [debug] Run process: /home/mahdi/.stack/programs/x86_64-linux/ghc-7.10.3/bin/ghc-pkg --no-user-package-db list --global
@(System/Process/Read.hs:277:3)
2016-09-03 14:54:26.917029: [debug] Asking GHC for its version
@(Stack/Setup/Installed.hs:101:13)
2016-09-03 14:54:26.917148: [debug] Run process: /home/mahdi/.stack/programs/x86_64-linux/ghc-7.10.3/bin/ghc --numeric-version
@(System/Process/Read.hs:277:3)
2016-09-03 14:54:26.917805: [debug] Getting Cabal package version
@(Stack/GhcPkg.hs:171:5)
2016-09-03 14:54:26.917946: [debug] Run process: /home/mahdi/.stack/programs/x86_64-linux/ghc-7.10.3/bin/ghc-pkg --no-user-package-db field --simple-output Cabal version
@(System/Process/Read.hs:277:3)
2016-09-03 14:54:26.938871: [debug] Process finished in 22 ms: /home/mahdi/.stack/programs/x86_64-linux/ghc-7.10.3/bin/ghc-pkg --no-user-package-db list --global
@(System/Process/Read.hs:277:3)
2016-09-03 14:54:26.939705: [debug] Process finished in 21 ms: /home/mahdi/.stack/programs/x86_64-linux/ghc-7.10.3/bin/ghc-pkg --no-user-package-db field --simple-output Cabal version
@(System/Process/Read.hs:277:3)
2016-09-03 14:54:26.940009: [debug] Process finished in 22 ms: /home/mahdi/.stack/programs/x86_64-linux/ghc-7.10.3/bin/ghc --numeric-version
@(System/Process/Read.hs:277:3)
2016-09-03 14:54:26.940088: [debug] Resolving package entries
@(Stack/Setup.hs:232:5)
2016-09-03 14:54:26.940614: [debug] Creating process: /usr/bin/git clone --recursive [email protected]:albertoruiz/hmatrix.git /home/mahdi/documents/workshop/flappy-rl/.stack-work/downloaded/Uc3OLtiS5s09
@(System/Process/Run.hs:103:5)
Cloning into '/home/mahdi/documents/workshop/flappy-rl/.stack-work/downloaded/Uc3OLtiS5s09'...
Enter passphrase for key '/home/mahdi/.ssh/id_rsa':
remote: Counting objects: 9586, done.
remote: Total 9586 (delta 0), reused 0 (delta 0), pack-reused 9586
Receiving objects: 100% (9586/9586), 2.86 MiB | 117.00 KiB/s, done.
fatal: unable to open /home/mahdi/documents/workshop/flappy-rl/.stack-work/downloaded/Uc3OLtiS5s09/.git/objects/pack/tmp_pack_uaQiyn: No such file or directory
fatal: index-pack failed
Process exited with ExitFailure 128: /usr/bin/git clone --recursive [email protected]:albertoruiz/hmatrix.git /home/mahdi/documents/workshop/flappy-rl/.stack-work/downloaded/Uc3OLtiS5s09
The last error after re-cloning is also random, sometimes re-cloning works, sometimes errors.
Stack version
$ stack --version
Version 1.1.3, Git revision 63f203d7886801c9ec3c303db0c459f08687a3c8 x86_64 hpack-0.14.0
Method of installation
pacman -S stack and stack upgrade
Metadata
Metadata
Assignees
Labels
No labels
Activity
Blaisorblade commentedon Sep 5, 2016
The underlying failure happens in git. This might be due to stack invoking git in an unsupported scenario (not sure which it could be), or to a git misconfiguration/bug/.... Do you have a change to investigate?
Questions:
mdibaiee commentedon Sep 6, 2016
@Blaisorblade: I'll try the steps once I get the issue again (I don't know the steps to reproduce, I get them randomly) 👍
jonascarpay commentedon Oct 25, 2016
I am getting this error fairly consistently (almost every build) with the following yaml (and other projects with extra deps from git, but not as consistently):
A hopefully related issue is that changing a single line in my project source often causes stack to recompile all extra dependencies. If you think this is the same issue, I'd be happy to supply any information I can.
mdibaiee commentedon Oct 25, 2016
I switched to Linux a little after I reported this bug and I haven't had this anymore and I can't help on this issue anymore. Sorry about that.
mgsloan commentedon Oct 25, 2016
I suspect this has to do with git versions. Which version of git are y'all using? I have version 2.7.4
Blaisorblade commentedon Oct 26, 2016
@mgsloan we might want to add the git version to logs on git failures (especially with
stack --verbose, or maybe not even) so we get it automatically in bug reports.Blaisorblade commentedon Oct 26, 2016
@jonascarpay I think correct Git URLs here should end in .git, e.g.
https://github.com/AccelerateHS/accelerate.gitinstead of justhttps://github.com/AccelerateHS/accelerate(and so on for other projects). GitHub does some magic to not require this but I don't know how robust it is. So, beyond the git version, can you make sure adding.gitto the end of the these Git URLs?jonascarpay commentedon Oct 29, 2016
This the output taken from two
stack build --verbose, in the first of which I get aFailed to reset to commit, followed by aExitFailure 128. The second build completes without problems.@mgsloan I'm on 2.10.1, the version from homebrew
@Blaisorblade Appending .git might have made the error somewhat rarer, but I'm not sure. I don't recall getting the
ExitFailure 128before, could this be related? I'll do some more testing after the weekend.Blaisorblade commentedon Oct 29, 2016
So it's hard to tell what's going on, especially without multiple traces to see what's in common and what isn't. Here's a few (somewhat desperate) hypotheses.
git resetseems to work fine with submodules in the second run).Is there any chance there's a permission problem involved—somehow git can't write to the repo, so that removing and cloning it helps? Is anything touching the downloaded repo, except git as invoked by stack? (I've surely written my share of cron scripts doing funky stuff with permissions). Are you accessing the repo as a different user sometimes?
This might well be instead a bug in stack itself, but I lack the faintest hypothesis—except if some race condition when executing processes were happening—but this seems pretty absurd in this code (I remember some undiagnosed symptoms in strange cases, but that was while building packages concurrently, IIRC, not fetching them)...
jonascarpay commentedon Nov 1, 2016
So I had some time on my hands and did some testing. I created a number of empty stack projects from the
simpletemplate. One (calledtest) had all the others (calledextradep[1-6]) as extra git dependencies, like this. I triggered the error by repeatedly adding or removing a single line intest/src/Main.hsand runningstack build. Here are some of the things I found, I hope they can provide some clue as to what is happening:stack clean && stack build'.'in stack.yaml. More specifically, when an error is reported I only ever seeFailed to reset to commit [commit of first listed package]. For the stack.yaml linked above that givesFailed to reset to commit eb19e515002fd8e5853f90802682604af6505df8. Changing the order of the packages changes the error.git resetnever fails.This is the verbose build output of a successful build: http://pastebin.com/raw/afjEjFLX. There are some ignored exceptions, is that normal?
Failing build: http://pastebin.com/raw/btNUAV4u
If there's anything else you'd like to have me try, let me know
mgsloan commentedon Nov 7, 2016
One thing to note is that you can get this message simply when changing the commit to something that has not yet been pulled. Doesn't quite match the description here, but may be related. See #2762
This may also be related to #2748
kgadek commentedon Nov 22, 2016
Hmm, I got into the same issue on my playground project after this change: kgadek:novelist@dc009a31be
I've noticed that (full log at the bottom):
runhaskellinvocation just failsCloning into& worksOS X 10.11.6, git 2.10.2, stack 1.2.0. Ping me if you need any debugging.
kgadek commentedon Nov 22, 2016
I have a suspect: race condition. My vim is heavily plugged, some
stack execintoghc-mod,hlinton each save, i.e. at the same time.How do you think, putting a simple lock around Stack/Config.hs: cloneAndExtract could fix this?
Blaisorblade commentedon Nov 23, 2016
@kgadek We've been wondering about race conditions for forever, but have been unable to confirm. But you're saying you suspect a race condition between different stack processes? I know there are locking mechanisms for that, but I don't think they're simple.
Also, what's the
stack execcommand line?stack execdoes not necessarily fetch sources... (unless you use for instance--package Xto ask it to buildX).kgadek commentedon Nov 23, 2016
Yes, I suspect 2+
stackprocesses race condition. I replacedgitbinary with a little bash script appending some output to some log file and the output was mixed.As far as I know, this is a solved problem assuming a sane filesystem (lock-files).
I don't run
stack execdirectly, I usestack runhaskell.Wondering how could I confirm this thesis. Add
withLockFilearound that call and try to reproduce? (PoC: use one lockfile per.stack-work. Final solution: one lockfile per each downloadedpackagerepo)Blaisorblade commentedon Nov 23, 2016
Could you also get their parent hierarchy? That should be easy with
psorpstreeand would probably tell us if those git processes were started by the samestackprocess or by different ones, what are their command lines, and so on.Re lockfiles I stand corrected—I assumed "simple lock" could only mean a threading thing. (I've also long conjectured there's some race condition in a single stack process). I'm not the most qualified to answer, but your idea certainly sounds clearly worth a try.
Locking the whole
.stack-workfor everything modifying it might even be a long-term solution (I've done stupid stuff like #2797), though we don't want to do too much locking.I suspect the same comment applies:
runhaskellwithout--packageshouldn't be building anything per se, which is why I'm asking. But given yourgitexperiment, it's likely something is racing.kgadek commentedon Nov 23, 2016
I've already done exactly what you're asking :) More precisely:
mv /usr/local/bin/git{,_orig}and the following the new/usr/local/bin/git. Please forgive me hardcoding the PID 3784, my shell uses git for prompt, wanted to filter that out.Part of the output (full log is 8k+ lines, though the pattern reoccurring):
Not sure if it's relevant, but I use neovim with following config: https://github.com/kgadek/neovim-config
I'll write/try writing locks tomorrow, will see if it helps.
PS. Shall I use gists for such snippets?
Blaisorblade commentedon Nov 24, 2016
Kudos for the find!
Without having proof-read the shell script and assuming you're navigating the "ppid chain", amazing findings I see there and I pass on to @mgsloan:
stack path). While I was a 100% wrong above, this still looks like a bug although I'm less sure than withstack path..stack-work) is certainly a good idea.A bit a matter of taste — if you posted the full log, sure. This one is borderline but I'm happy it was inline.
mgsloan commentedon Nov 27, 2016
Interesting! I've split off #2811 and also pushed a fix. So now
stack pathandstack execwon't cause packages to get cloned / reset. Does this resolve the issue?Go back to old approach to managing git / hg repos #1620 #2561
mgsloan commentedon Nov 27, 2016
I've also pushed a commit which goes back to the old approach. This means that instead of doing frequent
git reset, it will just do an initial clone + reset each time the commit is changed.kgadek commentedon Dec 11, 2016
With current stack (
Version 1.3.1, Git revision 164cb5529623c35249b7146d0bb8aaa66c502ecd), afterstack setup(previously I was using system one; re # 2221), I can't reproduce the issue 😄 Thanks!jonascarpay commentedon Dec 12, 2016
Same here, thank you!
mgsloan commentedon Dec 17, 2016
Great, closing!