commercialhaskell / commercialhaskell/stack

MSYS paths incorrectly recognized as relative on Windows

Open
#1,989 5 comments 1 reaction 0 assignees View on GitHub
component: Windows type: enhancement
Dominant language
Haskell
Stars
4.1k
Forks
850
Avg merge
10h 37m
Merged PRs (30d)
4

Description

On Windows, I'd like to use Unix-style paths, which reference directories inside the Stack-installed MSYS2 environment, for library and include directories. My tests below were on Windows 7 64-bit with 32-bit Stack.

**Steps to reproduce**

Clone https://github.com/mtolly/stack-msys. The important parts are, in `stack.yaml`,

```
extra-lib-dirs:
- /mingw32/lib
extra-include-dirs:
- /mingw32/include
```

And in `stack-msys.cabal`:

```
build-depends: base >= 4.7 && < 5, base64-bytestring
```

The `base64-bytestring` is not important -- it can be any other package, but for whatever reason the problem only shows up when you have at least one dependency that needs to be compiled beforehand. (So, if you don't see the problem because `base64-bytestring` is already compiled, try either changing it to some other package, or deleting the precompiled one from your `%AppData%/stack/snapshots` folder.)

**Expected:**

The directories, by virtue of starting with `/`, are recognized as Unix absolute paths and so are located relative to the Stack-local MSYS2 installation; for example mine would be `C:\Users\Mike\AppData\Local\Programs\stack\i386-windows\msys2-20150512\`.

The directory may not exist; this should be ignored with just a warning, not a fatal error. Specifically my end goal here is to have this in my `stack.yaml`:

```
extra-lib-dirs:
- /mingw32/lib # windows
- /usr/local/lib # mac homebrew
extra-include-dirs:
- /mingw32/include # windows
- /usr/local/include # mac homebrew
```

**Actual:**

This is from, inside `cmd.exe`, running `stack exec bash`, so apologies for the hard wrapping.

```
Mike@Mike-PC ~/stack-msys
$ stack --version
Version 1.0.4, Git revision cf18703b1392a96a5a4896a560309e501af63260 (3220 commi
ts) i386

Mike@Mike-PC ~/stack-msys
$ stack build
base64-bytestring-1.0.0.1: configure
base64-bytestring-1.0.0.1: build

-- While building package base64-bytestring-1.0.0.1 using:
C:\Users\Mike\AppData\Roaming\stack\setup-exe-cache\i386-windows\setup-Sim
ple-Cabal-1.22.5.0-ghc-7.10.3.exe --builddir=.stack-work\dist\95439361 build --g
hc-options " -ddump-hi -ddump-to-file"
Process exited with code: ExitFailure 1
Logs have been written to: C:\Users\Mike\AppData\Local\Programs\stack\i386-w
indows\msys2-20150512\home\Mike\stack-msys\.stack-work\logs\base64-bytestring-1.
0.0.1.log

Configuring base64-bytestring-1.0.0.1...
Warning: 'extra-lib-dirs: /mingw32/lib' directory does not exist.
Warning: 'include-dirs: /mingw32/include' directory does not exist.
Building base64-bytestring-1.0.0.1...
Preprocessing library base64-bytestring-1.0.0.1...
[1 of 5] Compiling Data.ByteString.Base64.Internal ( Data\ByteString\Base64\
Internal.hs, .stack-work\dist\95439361\build\Data\ByteString\Base64\Internal.o )

[2 of 5] Compiling Data.ByteString.Base64.URL ( Data\ByteString\Base64\URL.h
s, .stack-work\dist\95439361\build\Data\ByteString\Base64\URL.o )
[3 of 5] Compiling Data.ByteString.Base64.URL.Lazy ( Data\ByteString\Base64\
URL\Lazy.hs, .stack-work\dist\95439361\build\Data\ByteString\Base64\URL\Lazy.o )

[4 of 5] Compiling Data.ByteString.Base64 ( Data\ByteString\Base64.hs, .stac
k-work\dist\95439361\build\Data\ByteString\Base64.o )
[5 of 5] Compiling Data.ByteString.Base64.Lazy ( Data\ByteString\Base64\Lazy
.hs, .stack-work\dist\95439361\build\Data\ByteString\Base64\Lazy.o )
In-place registering base64-bytestring-1.0.0.1...
setup-Simple-Cabal-1.22.5.0-ghc-7.10.3.exe:
'C:\Users\Mike\AppData\Local\Programs\stack\i386-windows\ghc-7.10.3\bin\ghc-
pkg.exe'
exited with an error:
base64-bytestring-1.0.0.1: Warning: haddock-interfaces:
C:\Users\Mike\AppData\Local\Temp\stack3800\base64-bytestring-1.0.0.1\.stack-
work\dist\95439361\doc\html\base64-bytestring\base64-bytestring.haddock
doesn't exist or isn't a file
base64-bytestring-1.0.0.1: Warning: haddock-html:
C:\Users\Mike\AppData\Local\Temp\stack3800\base64-bytestring-1.0.0.1\.stack-
work\dist\95439361\doc\html\base64-bytestring
doesn't exist or isn't a directory
base64-bytestring-1.0.0.1: library-dirs: /mingw32/lib is a relative path whi
ch
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)
base64-bytestring-1.0.0.1: include-dirs: /mingw32/include 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)
Progress: 1/2
Mike@Mike-PC ~/stack-msys
$
```

Note that the two warnings about the dirs not existing are false, since they do exist.

[Here](http://pastebin.com/PMWvbLMp) is the verbose output.

This problem does **not** occur if, instead of specifying the dirs in `stack.yaml`, I pass them on the command line with `stack build --extra-lib-dirs=/mingw32/lib --extra-include-dirs=/mingw32/include`. I suspect this is just because the MSYS shell is converting them to Windows paths before Stack even sees them, but it's possible Stack could be treating them differently as well.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.