Skip to content

[WIP] Lock files#4550

Closed
psibi wants to merge 78 commits intocommercialhaskell:masterfrom
psibi:lock-files
Closed

[WIP] Lock files#4550
psibi wants to merge 78 commits intocommercialhaskell:masterfrom
psibi:lock-files

Conversation

@psibi
Copy link
Copy Markdown
Member

@psibi psibi commented Jan 30, 2019

Note: Documentation fixes for https://docs.haskellstack.org/en/stable/ should target the "stable" branch, not master.

Please include the following checklist in your PR:

  • Any changes that could be relevant to users have been recorded in the ChangeLog.md
  • The documentation has been updated, if necessary.

Please also shortly describe how you tested your change. Bonus points for added tests!

@psibi psibi changed the title Lock files [WIP] Lock files Jan 30, 2019
Copy link
Copy Markdown
Contributor

@qrilka qrilka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to discuss some details in a call

Comment thread src/test/Stack/LockSpec.hs Outdated
let cfInfo = CFIHash cabalHash (Just cabalSize)
packageIdRev = PackageIdentifierRevision name version cfInfo
pprintExtra (name, (version, BlobKey _ _)) =
let packageIdRev = PackageIdentifierRevision name version CFILatest
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you explain this change? Why do we use CFILatest when we have a particular blob key?

Copy link
Copy Markdown
Member Author

@psibi psibi Mar 1, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is for the suggestions part. Without this, if a package is not in the snapshot - The stack build tool will recommend it to be added like this:

  * Recommended action: try adding the following to your extra-deps in /home/sibi/github/tldr-hs2/stack.yaml:

string-quote-0.0.1@sha256:7d91a0ba1be44b2443497c92f2f027cd4580453b893f8b5ebf061e1d85befaf3

With the above change, it will recommend it like this:

  * Recommended action: try adding the following to your extra-deps in /home/sibi/github/tldr-hs2/stack.yaml:

string-quote-0.0.1

The reason I made that change was because of Michael's comment in the issue:

... the original stack.yaml can be even more lightweight than it is today, e.g. including the @rev:0 information there will no longer be necessary at all.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But why not change the suggestion properly instead? This change above complicates the logic a bit an gives no hints about reasons

Comment thread src/Stack/Config.hs
, isLockFileOutdated
, loadPackageLockFile
, loadSnapshotLayerLockFile
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need such a large multiline import list? Why not just everything from Stack.Lock? Also it doesn't look great when not aligned with other imports in the module

Comment thread src/Stack/Config.hs
cachedCompletePackageLocation :: (HasPantryConfig env, HasLogFunc env, HasProcessContext env) => Map RawPackageLocation PackageLocation
-> RawPackageLocation
-> RIO env PackageLocation
cachedCompletePackageLocation cachePackages rp@(RPLImmutable rpli) = do
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor naming suggestion: what about s/cachePackages/cachedLocations/?

Comment thread src/Stack/Config.hs
case item of
Nothing -> do
pl <- completePackageLocation rpli
pure $ PLImmutable pl
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe in 1 line as PLImmutable <$> completePackageLocation rpli?

Comment thread src/Stack/Lock.hs
(\x -> "Lock file package removed: " <> display x)
(chRemoved change)
mapM_ logDebug addedStr
mapM_ logDebug deletedStr
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about

forM_ (chRemoved change) $ \p ->
  logDebug $ "Lock file package removed: " <> display p

Imo it's much more readable - e.g. 2 lines instead of 5

Comment thread src/Stack/Lock.hs

loadSnapshotFile ::
Path Abs File -> Path Abs Dir -> IO [RawPackageLocationImmutable]
loadSnapshotFile path rootDir = do
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still see the same custom parsing, do I miss something?

Comment thread src/Stack/Lock.hs
value

loadPackageLockFile :: Path Abs File -> IO LockFile
loadPackageLockFile lockFile = do
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

project lock?

Comment thread subs/pantry/src/Pantry.hs
=> Map RawPackageLocationImmutable PackageLocationImmutable
-> RawPackageLocationImmutable
-> RIO env PackageLocationImmutable
cachedSnapshotCompletePackageLocation cachePackages rpli = do
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

duplicated in cachedCompletePackageLocation?

Comment thread src/Stack/Config.hs
if lockFileOutdated
then do
logDebug "Lock file is outdated or isn't present"
generatePackageLockFile stackYamlFP
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in generatePackageLockFile you complete locations when it's needed, why can't we just reuse that information and not to go through FS to get it?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and not to go through FS

We go through the FS to read the lock file to see if we can avoid doing completePackageLocation and rather reuse the information from the lock file. Is there a reason you don't want to go through FS ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see no reasons not to reuse already completed locations without going through FS

@snoyberg
Copy link
Copy Markdown
Contributor

Closing in favor of #4746

@snoyberg snoyberg closed this Apr 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants