Skip to content
This repository was archived by the owner on Oct 7, 2020. It is now read-only.

auto install of cabal on windows is not working #1462

Closed
flip111 opened this issue Nov 18, 2019 · 10 comments
Closed

auto install of cabal on windows is not working #1462

flip111 opened this issue Nov 18, 2019 · 10 comments

Comments

@flip111
Copy link
Contributor

flip111 commented Nov 18, 2019

i followed the documentation to install the data and latest ghc with install.sh and stack. After that vscode tries to run a command which fails. I just pasted this same command in a terminal and it looks like this:

C:\Users\flip111>C:\Users\flip111\haskell\haskell-ide-engine\.stack-work\install\4259daf8\bin\cabal-helper-wrapper.exe "--with-ghc=C:\\Users\\flip111\\AppData\\Local\\Programs\\stack\\x86_64-windows\\ghc-8.6.5\\bin\\ghc.exe" "--with-ghc-pkg=C:\\Users\\flip111\\AppData\\Local\\Programs\\stack\\x86_64-windows\\ghc-8.6.5\\bin\\ghc-pkg.exe" "--with-cabal=cabal" "v1-style" "C:\\Users\\flip111\\haskell\\pcre2" "C:\\Users\\flip111\\haskell\\pcre2\\.stack-work\\dist\\e626a42b" "package-db-stack" "flags" "compiler-version" "ghc-merged-pkg-options" "config-flags" "non-default-config-flags" "ghc-src-options" "ghc-pkg-options" "ghc-lang-options" "ghc-options" "source-dirs" "entrypoints" "needs-build-output"
cabal-helper-wrapper: Installing a private copy of Cabal because we couldn't
find the right version in your global/user package-db, this might take a
while but will only happen once per Cabal version you're using.

If anything goes horribly wrong just delete this directory and try again:
    C:\Users\flip111\Local Settings\Cache\cabal-helper

If you want to avoid this automatic installation altogether install
version 2.4.1.0 of Cabal manually (into your user or global package-db):
    $ cabal install Cabal --constraint "Cabal == 2.4.1.0"

Installing Cabal 2.4.1.0 ...
cabal-helper-wrapper.exe: Installing Cabal version 2.4.1.0 failed.

You have the following choices to fix this:

- The easiest way to try and fix this is just reconfigure the project and try
  again:
        $ cabal clean && cabal configure

- If that fails you can try to install the version of Cabal mentioned above
  into your global/user package-db somehow, you'll probably have to fix
  something otherwise it wouldn't have failed above:
        $ cabal install Cabal --constraint 'Cabal == 2.4.1.0'

- If you're using `Build-Type: Simple`:
  - You can see if you can reinstall your cabal-install executable while
    having it linked to a version of Cabal that's available in you
    package-dbs or can be built automatically:
        $ ghc-pkg list | grep Cabal  # find an available Cabal version
            Cabal-W.X.Y.Z
        $ cabal install cabal-install --constraint 'Cabal == W.X.*'
    Afterwards you'll have to reconfigure your project:
        $ cabal clean && cabal configure

- If you're using `Build-Type: Custom`:
  - Have cabal-install rebuild your Setup.hs executable with a version of the
    Cabal library that you have available in your global/user package-db:
        $ cabal clean && cabal configure
    You might also have to install some version of the Cabal to do this:
        $ cabal install Cabal
@jneira
Copy link
Member

jneira commented Nov 19, 2019

Hi @flip111, thanks for the bug report (run the command directly in a cmd was a good idea).
First i want to mention that there is a incoming change to hie internals that will remove that actual use of cabal-helper-wrapper so hopefully it will fix this issue: #1126.

I've just test succesfully opening a stack based project (with stack.yaml file) having cabal-2.4.1.0 and ghc-8.6.5 in path: the log of vscode output of Haskell HIE is here.

A possible problem could be precisely the ghc and cabal versions in path, please include the output of run ghc --version and cabal --version in a shell.

To get a more verbose output i set the trace level to verbose in the vscode-hie-server extension config options and i've set globally the environment variable CABAL_HELPER_DEBUG to 1.
Hopefully we'll see the concrete error that cabal-helper is throwing when trying to installing Cabal-2.4.1.0.

As possible quick and fuzzy workaround: try to remove the directories .stack-work, dist and dist-new-style of the project and the C:\Users\flip111\Local Settings\Cache\cabal-helper dir to force another auto-install.

@flip111
Copy link
Contributor Author

flip111 commented Nov 19, 2019

$ ghc --version
bash: ghc: command not found

$ stack exec -- ghc --version
The Glorious Glasgow Haskell Compilation System, version 8.6.5

$ cabal --version
bash: cabal: command not found

$ stack exec -- cabal --version
Executable named cabal not found on path: [".","C:\\sr\\global-project\\.stack-work\\install\\8e1bcd4f\\bin","C:\\sr\\snapshots\\9be3dfa9\\bin","C:\\sr\\compiler-tools\\x86_64-windows\\ghc-8.6.5\\bin","C:\\Users\\flip111\\AppData\\Local\\Programs\\stack\\x86_64-windows\\ghc-8.6.5\\bin","C:\\Users\\flip111\\AppData\\Local\\Programs\\stack\\x86_64-windows\\ghc-8.6.5\\mingw\\bin","C:\\Users\\flip111\\AppData\\Local\\Programs\\stack\\x86_64-windows\\msys2-20180531\\mingw64\\bin","C:\\Users\\flip111\\AppData\\Local\\Programs\\stack\\x86_64-windows\\msys2-20180531\\usr\\bin","C:\\Users\\flip111\\AppData\\Local\\Programs\\stack\\x86_64-windows\\msys2-20180531\\usr\\local\\bin","C:\\Users\\flip111\\bin","C:\\Program Files\\Git\\mingw64\\bin","C:\\Program Files\\Git\\usr\\local\\bin","C:\\Program Files\\Git\\usr\\bin","C:\\Program Files\\Git\\usr\\bin","C:\\Program Files\\Git\\mingw64\\bin","C:\\Program Files\\Git\\usr\\bin","C:\\Users\\flip111\\bin","C:\\Python38\\Scripts","C:\\Python38","C:\\Program Files (x86)\\Common Files\\Oracle\\Java\\javapath","C:\\Windows\\system32","C:\\Windows","C:\\Windows\\System32\\Wbem","C:\\Windows\\System32\\WindowsPowerShell\\v1.0","C:\\Windows\\System32\\OpenSSH","C:\\ProgramData\\chocolatey\\bin","C:\\Program Files\\Git\\cmd","C:\\tools\\php73","C:\\ProgramData\\ComposerSetup\\bin","C:\\Program Files\\Microsoft VS Code\\bin","C:\\Users\\flip111\\AppData\\Local\\Microsoft\\WindowsApps","C:\\Users\\flip111\\AppData\\Roaming\\Composer\\vendor\\bin","C:\\Users\\flip111\\AppData\\Local\\GitHubDesktop\\bin","C:\\Users\\flip111\\AppData\\Roaming\\local\\bin","C:\\Users\\flip111\\AppData\\Local\\Pandoc","C:\\Program Files\\Git\\usr\\bin\\vendor_perl","C:\\Program Files\\Git\\usr\\bin\\core_perl"]

@jneira
Copy link
Member

jneira commented Nov 20, 2019

Hi, with that configuration (with no ghc and cabal in path and a stack project using ghc-8.6.5) cabal-helper-wrapper is installing Cabal-2.4.0.1 succesfully in my windows computers (with win 7 and 10).
Could you share the log of vscode output of the hie extension (in verbose mode as described above) and the project configuration (stack.yaml and .cabal)?

@flip111
Copy link
Contributor Author

flip111 commented Nov 20, 2019

Hello.

set globally the environment variable CABAL_HELPER_DEBUG to 1

Not sure what "globally" means here. I just set it as my windows sytem variable.

set the trace level to verbose in the vscode-hie-server extension config options

Ok i done this, also i set a location for the log file.

I don't get to see any log files though.

and the project configuration (stack.yaml and .cabal)

Which project ?

@jneira
Copy link
Member

jneira commented Nov 20, 2019

Not sure what "globally" means here. I just set it as my windows sytem variable.

yeah, i wanted to mean this

Ok i done this, also i set a location for the log file.
I don't get to see any log files though.

In the output (menu view > output) view of vscode there should be a log (named Haskell HIE (haskell-ide-engine)) if you unset previously the location in settings

In C:\TEMP there should be a hie.log file too with more info (but different).

Which project ?

The project you are opening with vscode (with menu file > open folder i suppose)

@flip111
Copy link
Contributor Author

flip111 commented Nov 20, 2019

in the output (menu view > output) view of vscode there should be a log

I unset the previous log file and then restarted vscode but i don't see anything in this pane

hie1

In C:\TEMP there should be a hie.log

on my system C:\TEMP does not exist

and the project configuration (stack.yaml and .cabal)?

https://gist.github.com/flip111/844034f39155e15a2f7cf1a56a203b3c

@jneira
Copy link
Member

jneira commented Nov 20, 2019

Ok, i've reproduced the error tweaking some internal config files inside.stack-work.

In short: you need to put cabal (the executable) in the global PATH to make it work so i would recommend run stack install.hs stack-install-cabal in the haskell-ide-engine dir.

It seems that cabal-helper-wrapper needs (some version of) cabal (the executable) to compile Cabal (the library used by that executable). The call to cabal-helper-wrapper you post at beginning has the argument "--with-cabal=cabal" and it uses the value ot that arg to make an internal call to cabal get Cabal-2.4.1.0 to get the source of the library. As there is no executable cabal in the PATH system variable the call fails.

@flip111
Copy link
Contributor Author

flip111 commented Nov 21, 2019

Hi, i installed cabal with stack install.hs stack-install-cabal, after the compiling messages i saw the following:

Copying from C:\sr\snapshots\9be3dfa9\bin\cabal.exe to C:\Users\flip111\AppData\Roaming\local\bin\cabal.exe

Copied executables to C:\Users\flip111\AppData\Roaming\local\bin:
- cabal.exe

Warning: The cabal.exe executable found on the PATH environment variable is
         C:\sr\snapshots\9be3dfa9\bin\cabal.exe and not the version that was just installed. This
         means that cabal.exe calls on the command line will not use this version.
Build completed in 3m14s

than vscode still gave an error so i ran the failing command again, did an update, and again

https://gist.github.com/flip111/f38582455a1fdd270840af55c6439763

It's a bit strange that the compiling ended with a haskell data type print message

After that i restarted vscode and all seemed to work. thanks a lot !

@flip111 flip111 closed this as completed Nov 21, 2019
@flip111
Copy link
Contributor Author

flip111 commented Nov 21, 2019

Some suggestions:

change this line in the documentation:

Although you can use hie for stack based projects (those which have a stack.yaml in the project base directory) without having cabal installed

and modify the install.hs script so that it installs cabal and after updates it too

@jneira
Copy link
Member

jneira commented Nov 21, 2019

well, it used to do it! but it's true that in some (most?) cases cabal is not needed (in fact i was not able to trigger the error "normally"). At some point an user proposed remove the automatic install of cabal (for legitimate reasons imo): #1368

Moreover the incoming refactoring of hie (#1126) definitely will make cabal (or stack) optional for all cases.

So i would modify the docs adding something like: "In some cases cabal is still needed,,,"

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants