-
Notifications
You must be signed in to change notification settings - Fork 844
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Show resolver being used when stack ghci
is invoked outside of a project directory
#4521
Show resolver being used when stack ghci
is invoked outside of a project directory
#4521
Conversation
src/Stack/Ghci.hs
Outdated
when (null localTargets && isNothing mfileTargets) $ | ||
|
||
when (null localTargets && isNothing mfileTargets) $ do | ||
let project = fst $ fromJust mproject |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even if there is no currently known way for this to be Nothing
, there could possibly be a way now or in the future, and the error thrown by fromJust
is pretty frustratingly vague.
How about instead, for the Nothing
case, using something like error "Invariant violated: no project"
. One nice thing about using error
is that it will show where in stack's code the error occurred.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, ignoring the Nothing
case is pretty ugly. I was thinking about this some more and decided to try something else: simply not print the resolver version if the project is Nothing
. Would this work? I can do the error
instead, but it's basically the same thing I had before, except it has a more useful error message.
The code related to resolvers and snapshots has changed quite a bit since I last looked, so I can't give direct guidance. However, it seems like |
@mgsloan thanks for your review! I was digging through the |
@wafelj Welcome! Yeah I also dug around Looks to me like |
stack ghci
is invoked outside of a project directorystack ghci
is invoked outside of a project directory
@mgsloan @wafelj there was a large refactoring in #4412 and now Stack doesn' use |
@mgsloan @qrilka thanks. I looked into that and changed the code - now it passes the name from Also, two questions:
|
|
Sounds like a good idea to me. |
@qrilka changed to read name directly from BuildConfig and changed the field to smwSnapshotName. Also changed output to snapshot instead of resolver. Looks good? |
Fix for #3651.
Approach: read
Project
fromConfig
, getSnapshotLocation
and compiler info from it and use that to get resolver using theloadResolver
function. To my understanding it is theoretically possible that there is no project information in config (it's wrapped inMaybe
). But I'm assuming this never actually happens because if I try to delete the~/.stack/global-project/stack.yaml
, a new one is recreated whenstack ghci
is run again. This is why I assumed it's safe to usefromJust
. If there is a better approach, I'd love to hear about it.Disclaimer: I'm new to Haskell and to stack, and this is my first open-source contribution. Any feedback is most appreciated!