12

Since stack v2, stack produces a stack.yaml.lock file.

Should this file be committed to source control, like stack.yaml? Or should it be .gitignored?

On the one hand it's generated content and isn't source, on the other hand it contains hashes of the dependencies from Hackage so it is necessary for a safe reproducible build..

yairchu
  • 23,680
  • 7
  • 69
  • 109

2 Answers2

13

Yes. This is part of the reason that lock files exist: reproducible builds.

These files can be stored in source control Users on other machines can reuse these lock files and get identical build plans given that the used local packages and local snapshots are the same on those machines

https://docs.haskellstack.org/en/stable/lock_files/#lock-files

Dan Burton
  • 53,238
  • 27
  • 117
  • 198
2

It should be checked in - not doing so invalidates the whole purpose of the file (as is usual with .lock files)

Georgi Lyubenov
  • 366
  • 1
  • 5
  • 3
    Thanks! Note that your answer assumes familiarity with the usual for .lock files. But if I knew what the usual was, I probably wouldn't be asking.. – yairchu Nov 04 '20 at 22:13
  • 1
    Also, there have long been lock files with a very different purpose https://en.wikipedia.org/wiki/File_locking#Lock_files. Kind of a weird comment. – arya Mar 31 '22 at 21:13