commercialhaskell / stack

The Haskell Tool Stack
http://haskellstack.org
BSD 3-Clause "New" or "Revised" License
3.98k stars 842 forks source link

Record in a snapshot what was used to create its hash #5437

Open dpwiz opened 3 years ago

dpwiz commented 3 years ago

I would like to know, for debugging custom snapshots, what information went into particular hash.

The situation goes like this: 1) I build project and make snapshot read-only for next builds of the same stuff. 2) I build another project off the same local snapshot 3) Stack tries to start from scratch and I would like to know why.

There is stack ls snapshots that gives hashes, but there's no way to find out what's "inside". Or, in my case, what's changed.

qrilka commented 3 years ago

Implicit snapshots which are one of the main things introduced in Stack 2 take into account not only (ordinary?) snapshots (aka resolvers) but also any other immutable packages. I suppose the doc and the section should answer most of your questions

dpwiz commented 3 years ago

While having docs is nice, having the actual values somewhere in snapshot directory would be even nicer.

Extra-nice, if it would result in the same hash, but I expect it would hurt readability.

qrilka commented 3 years ago

Having actual values of what?

qrilka commented 3 years ago

And how do you want to get the same hash? Maybe I'm wrong but it sounds like you didn't read he doc I'm referencing and my comment above as well

dpwiz commented 3 years ago

I can see the compiler in the path, but not the other things that went into hash. Maybe they are somewhere in the snapshot directory, I just don't know where.

qrilka commented 3 years ago

@dpwiz not all of them come from a snapshot - that's exactly what I was talking about. E.g. if you have an extra-dep that also is an immutable dependency. Global or "boot" packages come with GHC so those are determined by your GHC. To get package dependencies you could use e.g. stack ls.

qrilka commented 3 years ago

If you want to know more details you could see them in the source code - https://github.com/commercialhaskell/stack/blob/065af79fc205e3008808e592976fcfcfea886b47/src/Stack/Build/Source.hs#L118

In principle stack ls snapshots with the introduction of implicit snapshots in Stack 2 makes not so much sense but it's not clear what to replace it with.

dpwiz commented 3 years ago

Yep. Let's put those into snapshot directory:

cat $(stack path --snapshot-install-root)/sourcemap.yaml
compiler-path: ...
compiler-info: ...
boot-ghc-opts: ...
immutable-deps:
...

I can contribute the code.

qrilka commented 3 years ago

What about showing that on demand instead? Such a file doesn't look to be required in most cases.

dpwiz commented 3 years ago

Sometimes it is too late to "demand" this. Doing forensics would be much easier if the file would be prepared in its native environment. Attempting to reconstruct it could be an exercise in futility if this is the problem you actually want to investigate.