Closed wolftune closed 8 years ago
On per-project basis, it's possible to achieve this right now, since local sandbox is prepended to search path. Long story short, if you have a .cabal-sanbox
in your project directory, you can install a relevant version of ghc-mod in there, and .cabal-sandbox/bin
will be prepended to your PATH automatically. Not sure if it makes much sense with stack though.
Are you saying that this is something specifically that haskell-ghc-mod does? It knows to add .cabal-sandbox/bin to the path it uses regardless of system path settings?
So if a similar generalizable option for .stack-work was available it would work comparably?
FWIW, the executable could be copied to a .cabal-sandbox/bin directory as a workaround even if there's not any actual use of cabal sandboxes. The only issue would be needing to remember to update it since Stack wouldn't do that automatically.
Yes, that's pretty much what I said.
I'm not terribly familiar with stack, so I'm not sure on that account.
Yes, copying executables directly is certainly possible, although there might be some caveats regarding library search path with that. Creating symlinks is also a possibility on systems that support those.
That all said, there have been an idea brewing of allowing to use multiple ghc versions with any project, via a straightforward selection dialog, given minimal path setup. That would be tricky to get right, but isn't outside the realm of possibility.
Hey, @wolftune did you figure out a good solution for this?
@hamsterdam nope, everything I do is with the same GHC version so it doesn't matter to me right now, it's just an abstract issue unless someone else has this problem in practice.
@wolftune thanks for the prompt response.
Have you gotten atom-haskell to work with stack at all?
Yeah, I totally have ide-haskell in Atom working with Stack for the core functions like completion and types and everything
@wolftune Would you mind sharing how you have it configured?
It works for me in the global project if I add:
~/.stack/programs/x86_64-osx/ghc-7.10.2/bin/ghc
to Addtional Path Directories~/.local/bin/ghc-mod
to Ghc Mod Pathbut otherwise, when in a non-global project I get:
ghc-mod: cabal: readCreateProcess: runInteractiveProcess: exec: does not exist (No such file or directory)
@hamsterdam if you have ~/.local/bin in your .profile PATH (or in .bashrc and start atom from bash), you don't need to specify that path. Also, you don't need the additional path directories set.
I think that error you have is because you have a dist/ directory in your project that might have been made by running something that built with cabal. You have to remove that
Nope, not the issue. It's a clean stack project. Thanks for the tips, though.
@hamsterdam Try to add all folders from PATH in your .bash_profile
file to the Additional Path Directories
field in haskell-ghc-mod
settings. I've had the same issue https://github.com/atom-haskell/haskell-ghc-mod/issues/65 and it solved the problem.
Thanks @welf. I tried that and got the same error that someone else did in #65.
So, well, as far as I can tell from skimming through referencing issues, it seems this should be basically renamed to "get PATH from stack". v1.6.0 does that, so various tricks with 'Additional Path Directories', stack exec atom
etc should not be needed provided everything is set up correctly. See also https://github.com/atom-haskell/haskell-ghc-mod/wiki/Using-with-stack
Feel free to create new issues if something doesn't work or you have suggestions.
Note that v1.6.0 might break existing setups using .cabal-sandbox/bin
hack. Sorry about that.
@lierdakil maybe I'm missing something, but with ghc-mod installed my project's cabal sandbox, as long as the plugin is set to look in cabal sandboxes, I shouldn't need to do anything special for my sandboxed libs to resolve, right? (The plugin will find the path based on atom's 'project folder', or should I need to start atom from within the project directory?) Is this what you mentioned about breaking the .cabal-sandbox/bin hack?
EDIT ... Hmm, I have no idea what I did, but it seems to be working now, maybe it was a rogue .cabal file I had in the project folder
@shanemikel, glad to hear you resolved it. My comment didn't have anything to do with resolving libraries, those are resolved by ghc-mod (usually correctly). This issue only relates to PATH environment variable (which controls where to look for executables).
Since Stack supports having projects on the same system use multiple versions of GHC, it would be ideal for haskell-ghc-mod to recognize somehow which ghc-mod to use for a given project.
Perhaps a dot file in the project directory could be used to pass info to haskell-ghc-mod? I'm not sure what other approach could make sense.
The process as I imagine it would be this, in the project directory:
stack build ghc-mod
thenstack exec which ghc-mod
will output the full path to the ghc-mod built for that project. Then, that path can be somehow used by haskell-ghc-mod when using the particular project and could vary when working on a different project, depending on if they use a different GHC etc.Note ghc-mod must be 5.4 or later for Stack, and I think that will be in LTS-3.6, so for any older projects using older snapshots, ghc-mod-5.4.0.0 (or some later version) will have to be added to stack.yaml*