Skip to content

[RFC] Relocation library #1185

@ghost

Description

It is common for programs to read configuration of data files installed on the system, for instance in /etc or /usr/share. In order for the program to find the files at runtime, it is common practice to capture an absolute path at configure time and store this path in the source code of the program.

There are two problems with this approach:

  • it is not clear how the program should find such files inside the project tests, i.e. before it is installed on the system
  • this doesn't play well when the binary artifacts are moved around. Systems that keep caches of built packages might do that for instance (esy, opam, ...)

The idea of this proposal is to provide a library so that programs can easily find such files without hassle. When running tests, dune would arrange things so that the paths reported by the library points to the local installation directory, i.e. _build/install. This library would also honor the environment variable from various systems (such as OPAM_SWITCH_PREFIX: ocaml/opam#3411) so that the binary artifacts can be easily relocated.

API

Here is a possible API for this library:

type path = string

val etc : unit -> path
val share : package:string -> path
...

Metadata

Metadata

Assignees

No one assigned

    Labels

    acceptedaccepted proposalsproposalRFC's that are awaiting discussion to be accepted or rejected

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions