SublimeHaskell icon indicating copy to clipboard operation
SublimeHaskell copied to clipboard

Problems with stack based haskell setup.

Open flip111 opened this issue 8 years ago • 21 comments

I switched from haskell-platform to using stack. And for general utilities like stack-run and stylish-haskell (amongst others) i try to install them into the global project. I have a few issues now with SublimeHaskell coming from this setup.

I use a simple stack template where source files are stored in src. When i open the source file and choose build it can not find the cabal file (which is in the parent directory). Same problem for other commands looking for the cabal file.

When i choose stylish it says it can not find stylish-haskell. When i go to the command line and type stylish-haskell --help it works.

When i run ghci, it says ghci is not found. I can only start ghci with using stack ghci for which i made an alias in my shell ghci. This will run ghci loading the project, or running from global-project if run outside a directory.

When i run load, it says it can not find cabal. I never use cabal anymore, i switched to stack, maybe under the hood stack has cabal installed somewhere, but i don't know how this works.

by the way, for load stack ghci can be used and for ghci stack exec ghci can be used

auto fix. This just seems to be running endlessly (indicated by dots in the sublime status bar). Doesn't seem to do anything at the moment.

browse declaration: same problem as autofix

eval selection: doesn't seem to do anything (not even a progress indicator or status message).

The rest of the options i will try later.

flip111 avatar Mar 22 '16 13:03 flip111

Thanks! I'll get into when i have some time

mvoidex avatar Mar 22 '16 14:03 mvoidex

I solved the ghci problem by changing all ...cmd=["ghci"]... to cmd=["stack","exec","ghci"] in repl.py. Hope that helps!

JimAmuro avatar Apr 22 '16 01:04 JimAmuro

a few commands i had to run to get more stuff working

stack install hsdev --resolver=nightly-2016-03-21
stack install stylish-haskell
stack install hashtags
stack install codex
stack install ghc-mod
stack install --resolver=nightly hdevtools

Preferences -> Package Settings -> SublimeHaskell -> Settings - User

{
    "enable_hdevtools": false,
    "enable_hsdev": true,

  // Extra directories to be added to the front of the PATH environment variable.
  // Specify this for using custom ghc, cabal, and ghc-mod
  // Example: /home/user/.cabal/bin
  "add_to_PATH": [
    "/home/flip111/.local/bin"
  ]
}

@JimAmuro i got 2 repl.py which one are you talking about?

./.config/sublime-text-3/Packages/SublimeREPL/repls/repl.py
./.config/sublime-text-3/Packages/SublimeHaskell/repl.py

flip111 avatar Apr 22 '16 18:04 flip111

@flip111 The second one, which belongs to SublimeHaskell.

JimAmuro avatar Apr 22 '16 19:04 JimAmuro

Now i'm getting this message

SublimeHaskell: hsdev version is incorrect: 0.1.8.2
Required version: >= 0.2.0.0 and < 0.2.1.0
Update it by running 'cabal update' and 'cabal install hsdev'

i also tried to install hsdev again with lts-5.14

Then later i tried with lts-5.18 but then i get this

--  Failure when adding dependencies:    
      hdocs: needed (>=0.5.0), 0.4.4.2 found (latest applicable is 0.5.0.0)
      simple-log: needed (>=0.4.0), 0.3.4 found (latest applicable is 0.4.0)
    needed for package hsdev-0.2.0.0

flip111 avatar May 27 '16 21:05 flip111

Seems, that packages were excluded until they can be built with ghc 8. I'll create pull request.

mvoidex avatar May 27 '16 21:05 mvoidex

@flip111 try lts-6.0. It works for me.

JimAmuro avatar May 27 '16 21:05 JimAmuro

https://github.com/fpco/stackage/pull/1503

mvoidex avatar May 27 '16 21:05 mvoidex

@JimAmuro with lts-6.0

--  Failure when adding dependencies:
      simple-log: needed (>=0.4.0), 0.3.4 found (latest applicable is 0.4.0)
    needed for package hsdev-0.2.0.0

flip111 avatar May 28 '16 12:05 flip111

@flip111 Sorry, I have no idea. I did nothing but put lts-6.0 into resolver in stack.yaml.

JimAmuro avatar May 28 '16 13:05 JimAmuro

@flip111, it's strange lts-6.0 have simple-log-0.4.0 Maybe add it as extra-deps?

mvoidex avatar May 28 '16 17:05 mvoidex

that did it, thanks for support guys. However original issue remains.

@mvoidex let me know when you want me to investigate again which functions work and which dont. Anyway the haskell tools should be installed now properly ^^

flip111 avatar May 28 '16 20:05 flip111

@flip111, ok :)

mvoidex avatar May 29 '16 20:05 mvoidex

little update ...

stack install hasktags hsdev stylish-haskell codex

All installed no problem with lts-6.4

SublimeHaskell did not found tools in path (even though they are available from terminal). Had to modify configuration file.

Got this warning, even though hdevtools was deprecated

SublimeHaskell: hdevtools was not found!
It's used for 'symbol info' and type inference
Install it with 'cabal install hdevtools',
or adjust the 'add_to_PATH' setting for a custom location.
'enable_hdevtools' automatically set to False in the User settings.

Applied patch from @JimAmuro

test functionality

program:

main = putStrLn "hello world"

without project

on save, shows nice box

Errors: 0, Warnings: 1, Hints: 0

/home/flip111/haskell/hello.hs: line 1, column 1:
  Warning: Top-level binding with no type signature: main :: IO (
  • Reports .cabal file could not be found: Build, Clean, Configure, Install, Rebuild, Test
  • Check: gives same box as on save
  • Hayoo: ask for string and gives back information
  • just says OK in the status bar below: Lint, autocheck
  • Run: nothing to run
  • Stylish: doesn't do anything, possibly because the file is already formatted the right way??
  • Browse declaration: shows a list, after selecting an item just says OK in status bar (weird)
  • Browse module, shows a lot of stuff (is this from the prelude?)
  • Doesn't seem to be doing anything: Eval selection, Insert type, Show type, Show types, go to declaration, go to module, expand selection to expression
  • find declaration, search declarations everywhere: opens up box, maybe program is too small to test it properly
  • Reinspect all: inspector not connected
  • apply to selection: opens box ask for stuff then doesn't do anything
  • check & lint: gives error about deprecated ghc-mod
SublimeHaskell: ghc-mod was not found!
It is used for LANGUAGE and import autocompletions and type inference.
Try adjusting the 'add_to_PATH' setting.
You can also turn this off using the 'enable_ghc_mod' setting.
  • show symbol info: first says no symbol selected then keeps status bar at Search 'main' (had to restart sublimetext to clear the status bar

not tested:

  • go to next/previous error
  • insert import for symbol
  • .. rest in list

I noticed not all commands are described in the wiki so not sure what everything is suppose to do.

flip111 avatar Jun 23 '16 15:06 flip111

I wonder if it'd be a lot of work to allow the use of intero instead of hsdev in SublimeHaskell?

Intero is designed to be used with stack and works really. I hate to admit that I've gone back to Emacs for Haskell development because of my satisfaction with intero and my inability to get ST3 and SublimeHaskell to work in my stack projects.

nurpax avatar Jan 05 '17 20:01 nurpax

This is also an alternative http://www.stephendiehl.com/posts/vim_2016.html i haven't tried it though

flip111 avatar Jan 05 '17 20:01 flip111

@flip111 But that's about vim? I'm an old time Emacs user, so going to Emacs from ST3 is only a minor annoyance.

I might be interested in taking a crack at integrating intero into SublimeHaskell in case no one else is doing that. It might not be a lot of work.

nurpax avatar Jan 05 '17 20:01 nurpax

I'm not sure what most of the SublimeHaskell functions are suppose to do even. So not sure how intero would fit in...

Maybe long term a solution could support https://github.com/Microsoft/language-server-protocol so that it the wheel doesn't need to be reinvented for every editor. Rust is doing that and it seems like a nice idea.

I find the learning curve of emacs and vim too steep. And the prospect of needing to fiddle with config files for hours to customize the way i want it is also not attractive. Sublime text is cross platform and is fast. Atom looks nice but it's just too slow in my opinion.

flip111 avatar Jan 05 '17 21:01 flip111

@flip111, @nurpax: Is the current 2.0.x SublimeHaskell release any better or more usable?

Current development priority for me is upgrading the syntax highlighting definitions to ST3. Longer term, since the backends are now refactored out of the main code as separate objects, integrating new backends such as intero or haskell_ide_engine are now possible.

bscottm avatar Oct 05 '17 17:10 bscottm

@bscottm Sorry, I haven't tried SublimeHaskell since I posted my comment here. I switched to Ghcid and just run that in a separate shell window. It's not as nice as having this integrated into my editor, but nothing seems to be Ghcid in reliability. (It's really the first IDE-style tool for Haskell that I've never had any issues with.)

nurpax avatar Oct 06 '17 06:10 nurpax

@nurpax: SublimeHaskell 2.0.x uses ghc-mod legacy-interactive. It's not as simple as ghcid, obviously, but it does reduce the cost of reloading/scanning when source code changes.

bscottm avatar Oct 11 '17 21:10 bscottm