[GHC] #12377: getExecutablePath doesn't return absolute path on OpenBSD (and maybe other OS also)
GHC
ghc-devs at haskell.org
Sun Jul 10 19:16:46 UTC 2016
#12377: getExecutablePath doesn't return absolute path on OpenBSD (and maybe other
OS also)
-------------------------------------+-------------------------------------
Reporter: oherrala | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: | Version: 8.0.1
libraries/base |
Keywords: | Operating System: OpenBSD
Architecture: | Type of failure: Incorrect result
Unknown/Multiple | at runtime
Test Case: | Blocked By:
Blocking: | Related Tickets:
Differential Rev(s): | Wiki Page:
-------------------------------------+-------------------------------------
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:
{{{#!hs
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
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12377>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list