Opened 5 years ago

Closed 5 years ago

#9698 closed feature request (fixed)

GHC_PACKAGE_PATH should be more lenient for empty paths

Reported by: Fuuzetsu Owned by:
Priority: normal Milestone: 7.10.1
Component: ghc-pkg Version: 7.8.3
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: #2521 Differential Rev(s): Phab:D414
Wiki Page:

Description

Consider a working GHC_PACKAGE_PATH=foo:bar:baz:.

It is not uncommon that we would want to append som extra vars later which might possibly be empty, perhaps resulting in GHC_PACKAGE_PATH=foo:bar:baz::qux:. Unfortunately, due to the :: GHC tries to looking for a package at the empty path and shows the usual error about not being able to find the package. This forces the user to set up various safeguards (such as ${GHC_PACKAGE_PATH:+:} bashism) at the inital binding location.

It'd be great if GHC would simply skip over empty paths.

Change History (4)

comment:1 Changed 5 years ago by thomie

Component: Compilerghc-pkg

comment:2 Changed 5 years ago by thomie

Differential Rev(s): Phab:D414
Status: newpatch

comment:3 Changed 5 years ago by Austin Seipp <austin@…>

In 6fc78fdfa1482a31ed7b586f20c9d7cb592ea944/ghc:

Refactor: use System.FilePath.splitSearchPath

Summary:
To address #2521 ("Trailing colon on GHC_PACKAGE_PATH doesn't work with
ghc-pkg"), we were using a custom version of splitSearchPath (e4f46f5de). This
solution however caused issue #9698 ("GHC_PACKAGE_PATH should be more lenient
for empty paths").

This patch reverts back to System.FilePath.splitSearchPath (fixes #9698) and
adresses (#2521) by testing for a trailing search path separators explicitly
(instead of implicitly using empty search path elements).

Empty paths are now allowed (ignored on Windows, interpreted as current
directory on Posix systems), and trailing path separator still tack on the
user and system package databases.

Also update submodule filepath, which has a version of splitSearchPath which
handles quotes in the same way as our custom version did.

Test Plan:
$ GHC_PACKAGE_PATH=/::/home: ./ghc-pkg list
...
db stack: ["/",".","/home","<userdb>","<systemdb>"]
...

Reviewers: austin

Reviewed By: austin

Subscribers: thomie, carter, simonmar

Differential Revision: https://phabricator.haskell.org/D414

GHC Trac Issues: #2521, #9698

comment:4 Changed 5 years ago by thoughtpolice

Milestone: 7.10.1
Resolution: fixed
Status: patchclosed

Merged, thanks!

Note: See TracTickets for help on using tickets.