Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Reload .cabal files when they are modified#4630

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
fendor merged 1 commit intomasterfromfix/reload-cabal-files
Aug 9, 2025

Conversation

@fendor
Copy link
Collaborator

@fendorfendor commentedJun 9, 2025
edited
Loading

Partially addresses#4236

It doesn't work withsessionLoadingmultipleComponents becausehie-bios doesn't give us the correct cradle dependencies.

A workaround is to declare the cradle dependencies in thehie.yaml. We need to fix this in hie-bios proper, but it is no longer an HLS bug.

vladimirlogachev and cloudyluna reacted with thumbs up emoji
@fendorfendor requested a review fromwz1000 as acode ownerJune 9, 2025 10:24
@fendorfendorforce-pushed thefix/reload-cabal-files branch 3 times, most recently from4bd3727 tob9250a5CompareJune 9, 2025 12:14
cfps'<- liftIO$ filterM (IO.doesFileExist. fromNormalizedFilePath) (concatMap targetLocations all_targets)
void$ shakeEnqueue extras$ mkDelayedAction"InitialLoad"Debug$ void$do
mmt<- usesGetModificationTime cfps'
mmt<- usesGetPhysicalModificationTime cfps'
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't understand how ignoring version in the VFS help us here🤔

Copy link
CollaboratorAuthor

Choose a reason for hiding this comment

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

Because cabal only works with the physical file system. If the VFS changes, then cabal simply can't perform a reload, ascabal repl will still observe the same.cabal file. That's why we only want to invalidate the shake session, if the.cabal file on disk has been modified.

Further, let's have a look atgetModificationTimeImpl:

getModificationTimeImpl::Bool->NormalizedFilePath->Action (MaybeBS.ByteString, ([FileDiagnostic],MaybeFileVersion))getModificationTimeImpl missingFileDiags file=dolet file'= fromNormalizedFilePath filelet wrap time= (Just$LBS.toStrict$B.encode$toRational time, ([],Just$ModificationTime time))    mbVf<- getVirtualFile filecase mbVfofJust (virtualFileVersion-> ver)->do            alwaysRerunpure (Just$LBS.toStrict$B.encode ver, ([],Just$VFSVersion ver))Nothing->do            isWF<- use_AddWatchedFile fileif isWFthen-- the file is watched so we can rely on FileWatched notifications,-- but also need a dependency on IsFileOfInterest to reinstall-- alwaysRerun when the file becomes VFS                    void (use_IsFileOfInterest file)elseif isInterface filethen-- interface files are tracked specially using the closed world assumptionpure()else-- in all other cases we will need to freshly check the file system                        alwaysRerun...

First, we don't care about theisInterface file check. Then, if the file isn't open in the VFS, we will never rerun this rule, unless theIsFileOfInterest rule is marked dirty, which it never will for.cabal files.

In my understanding,isWF will beTrue for.cabal files.

Copy link
Collaborator

@soulomoonsoulomoonJun 13, 2025
edited
Loading

Choose a reason for hiding this comment

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

Thanks for the explanation, much clear to me now.

@soulomoon
Copy link
Collaborator

soulomoon commentedJun 13, 2025
edited
Loading

Just some more interesting thoughts, do you think we can make GetModificationTime rule use GetPhysicalModificationTime rule in the end to remove some duplicated file time query?

@fendor
Copy link
CollaboratorAuthor

fendor commentedJun 13, 2025
edited
Loading

I am not sure, maybe. The whole file watcher architecture requires a thorough overhaul, it feels very brittle.

@soulomoon
Copy link
Collaborator

soulomoon commentedJun 16, 2025
edited
Loading

The whole file watcher architecture requires a thorough overhaul, it feels very brittle.

Indeed, are you planning to do it in this PR or open a seperate one for it?

@fendor
Copy link
CollaboratorAuthor

I am not sure 😅

Probably in a follow-up, maybe we should merge this as is and hope for the best.

@fendorfendorforce-pushed thefix/reload-cabal-files branch fromb9250a5 to07759eeCompareJune 16, 2025 14:14
unless (null new_deps||not checkProject)$do
cfps'<- liftIO$ filterM (IO.doesFileExist. fromNormalizedFilePath) (concatMap targetLocations all_targets)
void$ shakeEnqueue extras$ mkDelayedAction"InitialLoad"Debug$ void$do
mmt<- usesGetModificationTime cfps'
Copy link
Collaborator

@soulomoonsoulomoonJun 17, 2025
edited
Loading

Choose a reason for hiding this comment

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

If I am not mistaken,GetPhysicalModificationTime is for.cabal files?
andcfps' are mostly.hs file locations, and we are type checking those files here.

But I do not really know how we handle.cabal file in HLS and where we callGetModificationTime for.cabal files.

Copy link
CollaboratorAuthor

Choose a reason for hiding this comment

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

Good catch, this is wrong, it should beGetModificationTime

@fendorfendorforce-pushed thefix/reload-cabal-files branch from07759ee to81ee813CompareJune 20, 2025 13:14
Copy link
Collaborator

@soulomoonsoulomoon left a comment

Choose a reason for hiding this comment

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

LGTM, better if we have a some test to capture this change.

@fendorfendorforce-pushed thefix/reload-cabal-files branch from81ee813 to9806087CompareJuly 9, 2025 16:42
@fendorfendorforce-pushed thefix/reload-cabal-files branch 2 times, most recently from03ffe6f to7212959CompareAugust 8, 2025 15:36
@fendor
Copy link
CollaboratorAuthor

fendor commentedAug 8, 2025
edited
Loading

Finally with a regression test! This was a pain to write and I think I discovered another bug. Should be good to merge now.

EDIT: strictly speaking, I still need to add a test that the reload-logic works even when the.cabal file is not open, and we are not using thehls-cabal-plugin... I manually tested that it works.

soulomoon reacted with thumbs up emoji

@fendorfendorforce-pushed thefix/reload-cabal-files branch from7212959 to1782380CompareAugust 8, 2025 18:24
@fendorfendor merged commitd18697c intomasterAug 9, 2025
48 of 50 checks passed
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@soulomoonsoulomoonsoulomoon approved these changes

@wz1000wz1000Awaiting requested review from wz1000wz1000 is a code owner

@michaelpjmichaelpjAwaiting requested review from michaelpjmichaelpj is a code owner

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants

@fendor@soulomoon

[8]ページ先頭

©2009-2025 Movatter.jp