Skip to content

"stack script" support or workarounds? #1064

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

Closed
ethercrow opened this issue Oct 10, 2019 · 6 comments
Closed

"stack script" support or workarounds? #1064

ethercrow opened this issue Oct 10, 2019 · 6 comments

Comments

@ethercrow
Copy link

I have some scripts written using stack script interpreter, which conveniently takes care of installing packages my scripts depend on. Understandably, ghcide is not aware of this, but maybe I can do something to make it aware?

Is writing a hie.yaml something I need here? Didn't have to do that yet for other, non-script projects.

This is how it looks currently:
Screenshot 2019-10-10 at 09 50 15

@cocreature
Copy link
Contributor

Does stack script have a way to load the script into ghci? That should make it fairly easy to add support for this to hie-bios which we use to setup the GHC environment.

@hazelweakly
Copy link

@cocreature stack script does indeed support the ability to load something into ghci. Full details here

Relevant snippet:

A script (with program omitted):

#!/usr/bin/env stack
{- stack
  script
  --resolver lts-8.2
  --package turtle
-}

As far as i can tell, this is the equivalent to load it up into ghci:

#!/usr/bin/env stack
{- stack
     --resolver lts-8.2
     --install-ghc
     exec ghci
     --package turtle
-}

With stack script, the resolver should already be there (not that I think ghcide actually needs it?) And the ghcide already knows where ghc is or it wouldn't be running in the first place. So it seems like figuring out how to shove things into GHCi automatically shouldn't be too difficult? Famous last words, of course.

@andys8
Copy link
Collaborator

andys8 commented Jun 14, 2020

I was also looking into this. Another related problem is using ghcide with "standalone" haskell configuration files with xmonad or xmobar. It'll complain about missing packages, too. If stack scripts would work, it might be a workaround for this issue, too.

For now my "workaround" is to add package.yaml and stack.yaml with all dependencies to make ghcide happy.

@fendor
Copy link
Collaborator

fendor commented Jun 14, 2020

Stack scripts work in a "hacky" way.
You have to add an explicit hie.yaml file with the contents:

cradle:
  stack:
    component: "File.hs" # your local stack script

Works fine for loading and modifying the stack script.
However, if you modify the script section, these changes wont be detected, e.g. you have to restart ghcide/hls.

The reason this works is that you can do stack repl File.hs and the session is loaded correctly.

@jneira
Copy link
Member

jneira commented Sep 15, 2020

related: haskell/hie-bios#217

@jneira
Copy link
Member

jneira commented Dec 29, 2020

closinf in favour of #111

@jneira jneira closed this as completed Dec 29, 2020
@pepeiborra pepeiborra transferred this issue from haskell/ghcide Jan 1, 2021
eunikolsky added a commit to eunikolsky/kitya that referenced this issue May 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants