haskell / haskell/cabal

Questions about prefix-independence for data files

Open
#7,888 5 comments 1 reaction 0 assignees View on GitHub
attention: needs-help Cabal: other data-files documentation re: project-file type: bug
Dominant language
Haskell
Stars
1.7k
Forks
750
Avg merge
4d 3h
Merged PRs (30d)
28

Description

I've been following the documentation for the [Paths_pkgname](https://cabal.readthedocs.io/en/latest/cabal-package.html#accessing-data-files-from-package-code) and [data-files](https://cabal.readthedocs.io/en/latest/cabal-package.html#pkg-field-data-files) mechanism and managed to get a simple example going.

However, I don't quite understand the documentation for [prefix-independence](https://cabal.readthedocs.io/en/latest/setup-commands.html#prefix-independence):

> On Windows it is possible to obtain the pathname of the running program.

Does that mean that prefix-independence is only for Windows? Perhaps it should be explicitly stated.

> The executable can find its auxiliary files by finding its own path and knowing the location of the other files relative to $bindir. Prefix-independence is particularly useful: it means the user can choose the install location (i.e. the value of $prefix) at install-time

Here by "installing", do we mean something like copying the executable to another location, maybe across machines?

If the executable finds the other files relative to `$bindir`, why is `$prefix` needed at all?

> In order to achieve this, we require that for an executable on Windows, all of $bindir, $libdir, $dynlibdir, $datadir and $libexecdir begin with $prefix.

Is this the default, or do I have to do tweak something in order to achieve it? Does "beginning with $prefix" mean "beginning with the literal text '$prefix'" or "beginning with the value of $prefix"?

**System information**

- Cabal 3.6.2.0

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.