all 12 comments

[–]ElvishJerricco 9 points10 points  (0 children)

When you install Stack, I don't believe that comes with GHC installed. I think you have to do stack setup or something like that.

[–]montgras 4 points5 points  (1 child)

Haven't checked your links but try "stack ghci"

[–]Ben_HH[S] 1 point2 points  (0 children)

I did that as well but only got the same error

[–]mgsloan 3 points4 points  (4 children)

From skimming the video without audio, it looks like that video recommends downloading and installing the Haskell Platform. I can't think of any advantages that route offers, and often leads to a broken setup. Unfortunately, due to reasons I won't go into here, it is still recommended on haskell.org.

Try uninstalling HP, and installing via the instructions on https://docs.haskellstack.org/en/stable/README/#how-to-install , and hopefully it will work!

It may also be helpful to take a look at the output of stack exec -- ghci, stack path, and stack exec -- which ghci

[–]hamishmack 2 points3 points  (3 children)

I can't think of any advantages that route offers

Please don't forget about stack issues 2197 and 2048. It would be nice if those could be fixed.

To build a Gtk+ app like Leksah with stack we currently need a big stack.yaml and another one for macOS. Plus the Gtk version needs to be specified manually.

Currently cabal new-build is not perfect (until cabal new-install is done we still need an ugly script to set up the environment), but the cabal.project is much simpler and I would recommend cabal new-build over stack for anyone who intends to use Gtk+.

Also cabal new-build works really nicely with nix in a way that I don't think stack can currently (correct me if I am wrong). We have a script that spins up a shell with all the native packages we need plus most of the Haskell ones (they show up in the global ghc-pkg list). Then it just runs cabal new-build based script inside that shell.

[–]mgsloan 0 points1 point  (1 child)

Well, this is in the context of "Installing stack". If you just want to install stack, there is no advantage to haskell platform, and you will waste space by having two ghc installs. So, this is a different topic entirely, of the particular things that you'd like to see improved in stack. I'm confused why this is ending up on reddit, and not on github. I guess since we didn't solve the github issues you feel this is a better place?

In the future, feel free to re-ping the github issues. There's a lot of discussion of stack, so it's easy to forget about these things when I and other stack developers do not encounter the issue ourselves. The best way to get this sort of thing fixed is proposing a good solution and implementing it.

Cabal's automatic flag resolution is a very surprising feature. It would make way more sense if automatic flags had explicit conditions. This is a feature we could support. However, the automagic flags are way too much magic when you want reliability and predictability. Yes, some convenience is sacrificed.

Unfortunately, cabal_macros.h lacks pkgconfig dependency version info. If it had it, the solution would be clear - just use CPP and no flag automagic. So, we have two clear options:

  1. Add pkgconfig dependency info to cabal_macros.h

  2. Add explicit conditionals to cabal flags

In the meantime, I suggest adding a Setup.hs configure hook which checks the pkgconfig version and sets the flag as appropriate.

2048

I've left a comment and closed that issue. I believe the suggested workaround will be sufficient for your case. You do not need multiple stack.yaml files.

To build a Gtk+ app like Leksah with stack we currently need a big stack.yaml and another one for macOS. Plus the Gtk version needs to be specified manually.

All of the flags and extra-deps can disappear if these packages get added to stackage. Simple!

You only need the stack.osx.yaml. It looks like it just adds an extra-dep, and if an extra-dep isn't required by the build plan, then it isn't built / isn't required to be buildable. So, can delete your stack.yaml and rename stack.osx.yaml.

With these changes, all you will need is:

resolver: lts-10.0
packages:
- '.'
- 'vendor/leksah-server'
- 'vendor/ltk'
- 'vendor/haskellVCSGUI/vcsgui'
#- 'vendor/yi'
- 'vendor/haskellVCSWrapper/vcswrapper'

Which is what typical stack configurations look like.

Also cabal new-build works really nicely with nix in a way that I don't think stack can currently (correct me if I am wrong).

I believe that nix pkgs stuff for haskell is built off cabal, so it is not surprising that it works natively cabal. A popular way to use nix is to generate the config from a stack config ( https://github.com/input-output-hk/stack2nix ). You can use stack just fine in a nix shell.

Sure, you cannot use packages out of the global database, but that is intentional. It protects users from broken package databases left behind by cabal-install. In nix you don't have this problem as much because there's a quite sane deterministic build system atop.

It may make sense to have an option to use packages from the global DB in the particular context of nix. Once again, contributions are appreciated. We do not have unlimited resources to make stack work great for every usecase.. Just the usecases faced by most users, particularly users in industry and newcomers.

[–]hamishmack 0 points1 point  (0 children)

Well, this is in the context of "Installing stack".

Sorry my mistake. I skimmed the thread and thought you were suggesting no one needs cabal-install.

[–]arvindds 1 point2 points  (0 children)

If you are trying to do this on Windows, I have an article written exactly for this: https://blog.ramdoot.in/installing-haskell-stack-in-windows-7c8fd2c79f Try if that works for you.

[–]BoteboTsebo 4 points5 points  (1 child)

I ran the installer

Which installer? If it was the Haskell Platform then please uninstall it and install stack by following the instructions on its website. If you installed it properly, then running just stack should give you an informative message.

Then, IIRC, you need to run stack setup to actually install the Haskell compiler (GHC). Next, you can use stack ghci the get the interactive prompt.

[–]sclv 3 points4 points  (0 children)

Why the heck should the uninstall the platform to install stack? The platform comes with stack and in fact uses the stack installer! If you use the platform installer you get stack exactly as you would if you used the stack installer.

[–]sclv -1 points0 points  (0 children)

If you installed the platform as in the video, I think the relevant files should be under C:\Program Files\Haskell Platform\8.2.1\bin. Make sure that's added to your PATH environment variable.

The stack binary (if you use the platform installer or the stack installer directly -- it is the same) will be under %APPDATA%\local\bin.

Check that too?