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

Can't build on windows with a space in any of the used paths (stack,ghc,etc locations) #1356

Open
ArthurHNL opened this issue Aug 7, 2019 · 24 comments
Labels

Comments

@ArthurHNL
Copy link

On Windows, when trying to build (after cloning) using the following command:

C:\Tools\haskell-ide-engine [master ≡]> stack .\install.hs cabal-build-all

Gives the following output:

install.hs: C:\Users\Arthur: createProcess: does not exist (No such file or directory)

I'm not really experienced with stack but it appears to be an issue with spaces in the path (my actual user folder is C:\Users\Arthur Heidt), the path appears to be cut off at the first space.

@fendor
Copy link
Collaborator

fendor commented Aug 7, 2019

Do we know which command failed specifically? E.g. does stack .\install.hs help fail with the same error?
Or is this a cabal issue, e.g. cabal v2-build fails?

@ArthurHNL
Copy link
Author

@fendor any stack .\install.hs fails:

C:\Tools\haskell-ide-engine [master ≡]> stack .\install.hs
install.hs: C:\Users\Arthur: createProcess: does not exist (No such file or directory)
C:\Tools\haskell-ide-engine [master ≡]> stack .\install.hs help
install.hs: C:\Users\Arthur: createProcess: does not exist (No such file or directory)

It probably doesn't matter but I'm using the integrated powershell terminal in vscode.

cabal v2-build also does not work but it gives some more diagonstics:

Failed to build network-3.0.1.1. The failure occurred during the configure
step.
Build log ( C:\Users\Arthur
Heidt\AppData\Roaming\cabal\logs\ghc-8.6.5\network-3.0.1.1-a7c0a2f72c1e0fc4564857678c584897c6b48964.log

):
Configuring network-3.0.1.1...
cabal.exe: The package has a './configure' script. If you are on Windows, This
requires a Unix compatibility toolchain such as MinGW+MSYS or Cygwin. If you
are not on Windows, ensure that an 'sh' command is discoverable in your path.
cabal.exe: Failed to build network-3.0.1.1 (which is required by
test:unit-test from haskell-ide-engine-0.12.0.0, test:wrapper-test from
haskell-ide-engine-0.12.0.0 and others). See the build log above for details.

It needs a unix toolchain but I believe it is included with the Haskell platform. Here is the file: network-3.0.1.1-a7c0a2f72c1e0fc4564857678c584897c6b48964.log

@fendor
Copy link
Collaborator

fendor commented Aug 7, 2019

Sounds a bit like an issue upstream...
I know the issue with cabal, but no fix to it.
Stack should work though.

@ArthurHNL
Copy link
Author

Except it does not.

@fendor
Copy link
Collaborator

fendor commented Aug 8, 2019

I tried a minimal example on windows with a space in the path, it seems to work alright. So, this issue might indeed be caused by the install script.
What windows version, btw?

@ArthurHNL
Copy link
Author

Windows 10 Pro x64 version 1903 (updated yesterday).

@ArthurHNL
Copy link
Author

Fyi, I did not clone the repository into my user folder, I cloned it into C:\tools\haskell-ide-engine. The first time I ran the stack command it did some stuff before giving the error, now it immideatly crashes.

@fendor
Copy link
Collaborator

fendor commented Aug 8, 2019

It was probably downloading ghc and building the install script.
I don't know where stack installs the script to, it might be into appdata and then tries to execute which now includes the username. More investigation required!

@jneira
Copy link
Member

jneira commented Aug 9, 2019

It needs a unix toolchain but I believe it is included with the Haskell platform.

re: cabal error
I am afraid that the configure step is not ghc related and you definitely need run cabal inside a msys console to build packages with it as the message suggests (network is required by many many haskell packages)
Once you have built network and it is cached, you can build the package in a ps console.

@jneira
Copy link
Member

jneira commented Aug 9, 2019

@ArthurHNL i would relocate all paths used by stack to directories out of your user dir:

  • if it is not already set, point the stack root directory to X:\sr setting the %STACK_ROOT% env var to that value
  • after a stack init to recreate files under the new %STACK_ROOT% dir if needed, change paths in %STACK_ROOT%\config.yaml:
local-bin-path: X:\bin
local-programs-path: X:\bin\stack

Of course you can replace X:\bin with whatever, but try to keep it short to avoid long paths issues.

@jneira
Copy link
Member

jneira commented Aug 13, 2019

@ArthurHNL have you had the opportunity to try those changes in stak config? Imo that stack configuration is good in general to develop with stack in windows.

@jneira jneira added the build Continuous integration and building label Aug 13, 2019
@ArthurHNL
Copy link
Author

@jneira I just tried the new configuration and it appears to be working :)

@jneira
Copy link
Member

jneira commented Aug 14, 2019

Great! I think we could close this, having a good workaround and being at the end a upstream issue.

@fendor
Copy link
Collaborator

fendor commented Aug 14, 2019

Is it an upstream issue though? Did we confirm that? Could not find a stack issue.

@jneira
Copy link
Member

jneira commented Aug 14, 2019

Mmm i've not reproduced it but given that changing stack config fixes it i think it would be so.
Anyway I'll try to reproduce and fill a stack issue if needed

@fendor
Copy link
Collaborator

fendor commented Aug 14, 2019

Before trying to reproduce is, what is your stack version @ArthurHNL?

EDIT: closed by accident

@fendor fendor closed this as completed Aug 14, 2019
@fendor fendor reopened this Aug 14, 2019
@jneira
Copy link
Member

jneira commented Aug 14, 2019

Ok, i've reproduced it simply setting a path with spaces in local-programs-path field of %STACK_ROOT%\config.yaml:

local-programs-path: D:\bin\s t a c k

When you run a stack command instead a script it emits a warning:

D:\dev\ws\haskell\stack-test> stack build
Stack's 'programs' path contains a space character and has no alternative short ('8 dot 3') name. 
This will cause problems with packages that use the GNU project's 'configure' shell script. 
Use the 'local-programs-path' configuation option to specify an alternative path. 
The current 'shortest' path is: D:\bin\s t a c k\

The warning is a little bit weird in the suggestions but i think that makes clear that they are aware of the issue. The improvement could be show the message when running a script (like hie install.hs) too.

Filling an issue upstream...

@samuelpilz
Copy link
Contributor

@jneira should I add a check into the install.hs?

@jneira
Copy link
Member

jneira commented Aug 15, 2019

mmm, it would be great at least while stack itself doesn't warn anything.

@samuelpilz samuelpilz self-assigned this Aug 16, 2019
@jneira
Copy link
Member

jneira commented Aug 20, 2019

@power-fungus i've just opened a pr upstream to make stack show the warning. We will have to wait to the next release but maybe we dont need add the message to hie.

@samuelpilz
Copy link
Contributor

@jneira Awesome. The warning does make more sense coming from stack

@samuelpilz samuelpilz removed their assignment Aug 21, 2019
@jneira jneira pinned this issue Aug 27, 2019
@fendor
Copy link
Collaborator

fendor commented Sep 1, 2019

Since the upstream issue is closed, what do we aim to do here? Add to readme, or just close this issue?

@jneira
Copy link
Member

jneira commented Sep 1, 2019

Not sure if we should wait to a stack release with the warning that hie could use

@aivo0
Copy link

aivo0 commented Dec 18, 2019

I had the same issue because Stack was installed under C:\Program Files\ .. . Moving Stack to C:\bin\stack was not enough however. Had to also uninstall and reinstall the whole Haskell Platform to C:\Haskell\8.6.5 which was previously installed under C:\Program Files\Haskell Platform\8.6.5 .

Before reinstalling the Haskell Platform the GHC 8.6.5 and stack based install failed with:
cabal: Failed to build cabal-helper-0.9.0.0 (which is required by
exe:hie-wrapper from haskell-ide-engine-0.14.0.0, lib:hie-test-utils from
haskell-ide-engine-0.14.0.0 and others). The failure occurred during the final
install step. The exception was:
dieVerbatim: user error (cabal:
'C:\bin\stack\x86_64-windows\ghc-8.6.5\bin\ghc-pkg.exe' exited with an
error:
cabal-helper-0.9.0.0: Warning: .:3:1: Unknown field: "visibility"
cabal-helper-0.9.0.0: Warning: library-dirs: C:\Program doesn't exist or isn't
a directory
cabal-helper-0.9.0.0: Warning: dynamic-library-dirs: C:\Program doesn't exist
or isn't a directory
cabal-helper-0.9.0.0: Warning: include-dirs: C:\Program doesn't exist or isn't
a directory
cabal-helper-0.9.0.0: Warning: include-dirs:
C:\hie\haskell-ide-engine\submodules\cabal-helper\Files\Haskell doesn't exist
or isn't a directory
cabal-helper-0.9.0.0: Warning: include-dirs:
C:\hie\haskell-ide-engine\submodules\cabal-helper\Platform\8.6.5\mingw\include
doesn't exist or isn't a directory
cabal-helper-0.9.0.0: Warning: haddock-interfaces:
C:\hie\haskell-ide-engine\dist-newstyle\build\x86_64-windows\ghc-8.6.5\cabal-helper-0.9.0.0\doc\html\cabal-helper\cabal-helper.haddock
doesn't exist or isn't a file
cabal-helper-0.9.0.0: Warning: haddock-html:
C:\hie\haskell-ide-engine\dist-newstyle\build\x86_64-windows\ghc-8.6.5\cabal-helper-0.9.0.0\doc\html\cabal-helper
doesn't exist or isn't a directory
cabal-helper-0.9.0.0: library-dirs: Files\Haskell is a relative path which
makes no sense (as there is nothing for it to be relative to). You can make
paths relative to the package database itself by using ${pkgroot}. (use
--force to override)
cabal-helper-0.9.0.0: library-dirs: Platform\8.6.5\mingw\lib is a relative
path which makes no sense (as there is nothing for it to be relative to). You
can make paths relative to the package database itself by using ${pkgroot}.
(use --force to override)
cabal-helper-0.9.0.0: dynamic-library-dirs: Files\Haskell is a relative path
which makes no sense (as there is nothing for it to be relative to). You can
make paths relative to the package database itself by using ${pkgroot}. (use
--force to override)
cabal-helper-0.9.0.0: dynamic-library-dirs: Platform\8.6.5\mingw\lib is a
relative path which makes no sense (as there is nothing for it to be relative
to). You can make paths relative to the package database itself by using
${pkgroot}. (use --force to override)
)

@jneira jneira changed the title Can't build on windows with a space in username Can't build on windows with a space in any of the used paths (stack,ghc,etc locations) Dec 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

5 participants