getExecutablePath doesn't return absolute path on OpenBSD (and maybe other OS also)
System.Environment.getExecutablePath doesn't return absolute path to executable in OpenBSD. This happens because getExecutablePath uses argv[0] to determine path and argv[0] might not be absolute path.
My environment:
$ uname -a
OpenBSD fizbuz.pilkki.ciz.fi 6.0 GENERIC.MP#2274 amd64
$ ghc -V
The Glorious Glasgow Haskell Compilation System, version 7.10.3
This test program in OpenBSD:
module Main where
import System.Environment
main = getExecutablePath >>= print
returns
$ ./test
"./test"
For example in OS X the call returns absolute path:
$ ./test
"/Users/oherrala/tmp/test"
OpenBSD is one of the operating systems which gets fall back to using argv[0] to determine exec's location:
https://git.haskell.org/ghc.git/blob/HEAD:/libraries/base/System/Environment/ExecutablePath.hsc#l152
Maybe the argv[0] result should be wrapped with realpath(3) to get absolute path?
This bug is also present in cabal-install and reported here: https://github.com/haskell/cabal/issues/3512#issuecomment-231604356
Trac metadata
| Trac field | Value |
|---|---|
| Version | 8.0.1 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | libraries/base |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture |