Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

man dir does not change as specified by --mandir #10229

Closed
jbhoot opened this issue Mar 7, 2024 · 14 comments · Fixed by #11172
Closed

man dir does not change as specified by --mandir #10229

jbhoot opened this issue Mar 7, 2024 · 14 comments · Fixed by #11172
Assignees
Labels

Comments

@jbhoot
Copy link

jbhoot commented Mar 7, 2024

Problem

dune has been failing to build from source on pkgsrc because they can't get dune to put the man pages in a different location (share/man/*) from dune's default man/* (https://us-central.manta.mnx.io/pkgsrc/public/reports/upstream-trunk/20240305.1526/ocaml-dune-3.11.1/install.log).

As an experiment, I cloned dune from github to build it the make way. I executed the following sequence, from what I understood through various conversations on the github repo:

$ cd dune/
$ ./configure --mandir=./fake_root/share/man
$ PREFIX=fake_root make release
$ PREFIX=fake_root make install

configure.ml seems to be doing what it is intended to - it creates/modifies src/dune_rules/setup.ml:

let library_path = []

let roots : string option Install.Roots.t =
  { lib_root = None
  ; man = Some "/Users/jb/projects/dune/./fake_root/share/man"
  ; doc_root = None
  ; etc_root = None
  ; share_root = None
  ; bin = None
  ; sbin = None
  ; libexec_root = None
  }

Expected Behavior

man pages should be installed at fake_root/share/man/*.

Actual Behavior

man pages are still installed at man/* instead of share/man/*.

> tree -d fake_root
fake_root
├── bin
├── doc
│   └── dune
│       └── odoc-pages
├── lib
│   └── dune
├── man
│   ├── man1
│   └── man5
└── share
    └── emacs
        └── site-lisp

Reproduction

  1. Clone dune repo
  2. Execute the following sequence of commands.
$ cd dune/
$ ./configure --mandir=./fake_root/share/man
$ PREFIX=fake_root make release
$ PREFIX=fake_root make install

Specifications

  • Version of dune (output of dune --version): main branch
  • Version of ocaml (output of ocamlc --version): 4.14.1
  • Operating system (distribution and version): macOS Sonoma 14.3 (Silicon aarm64 architecture)
@rgrinberg rgrinberg added the bug label Mar 7, 2024
@moyodiallo
Copy link
Collaborator

moyodiallo commented Mar 7, 2024

Instead of having PREFIX, doing:

make release
make install

I got.

> tree -d fake_root
fake_root
   | share
         ├── man
         │   ├── man1
         │   └── man5

I think there's an override somewhere using PREFIX. I'll try to investigate.

@moyodiallo
Copy link
Collaborator

Sorry edited #10229 (comment).

@moyodiallo moyodiallo self-assigned this Mar 7, 2024
@jbhoot
Copy link
Author

jbhoot commented Mar 7, 2024

Instead of having PREFIX, doing:

On my end, the process fails without PREFIX, asking me to enter a prefix another way (--prefix).

$ rm -rf fake_root

$ make clean

$ ./configure --mandir=./fake_root/share/man

$ make release

$ make install
./_boot/dune.exe install    dune
Error: The docdir installation directory is unknown.
Hint: It can be specified with '--prefix' or by setting '--docdir'
make: *** [install] Error 1

@moyodiallo
Copy link
Collaborator

I have got what's happening. In your case you don't have.

$ env | grep OPAM_SWITCH_PREFIX
$ OPAM_SWITCH_PREFIX=/home/...

Could means there's no opam in that environment. The rest of installation have to go somewhere. I know this is not ideal, just to notice.

@moyodiallo
Copy link
Collaborator

moyodiallo commented Mar 8, 2024

The problem is cumming from here, the Context.roots context(src/dune_rules/setup.ml) is totally overridden:

let prefix_from_command_line = Option.map ~f:Path.of_string prefix_from_command_line in
let+ roots =
match prefix_from_command_line with
| None -> Memo.run (Context.roots context)
| Some prefix ->
Roots.opam_from_prefix prefix ~relative:Path.relative
|> Roots.map ~f:(fun s -> Some s)
|> Fiber.return
in
let roots = Roots.first_has_priority from_command_line roots in

Could solve the issue before a fix:

 $ ./dune.exe install --prefix fake_root --mandir /home/.../dune/fake_root/share/man dune

A PR will be opened sooner :)

moyodiallo added a commit to moyodiallo/dune that referenced this issue Mar 8, 2024
moyodiallo added a commit to moyodiallo/dune that referenced this issue Mar 8, 2024
moyodiallo added a commit to moyodiallo/dune that referenced this issue Mar 8, 2024
Signed-off-by: Alpha DIALLO <moyodiallo@gmail.com>
moyodiallo added a commit to moyodiallo/dune that referenced this issue Mar 8, 2024
Signed-off-by: Alpha DIALLO <moyodiallo@gmail.com>
moyodiallo added a commit to moyodiallo/dune that referenced this issue Mar 12, 2024
Signed-off-by: Alpha DIALLO <moyodiallo@gmail.com>
moyodiallo added a commit to moyodiallo/dune that referenced this issue Mar 14, 2024
Signed-off-by: Alpha DIALLO <moyodiallo@gmail.com>
moyodiallo added a commit to moyodiallo/dune that referenced this issue Mar 15, 2024
Signed-off-by: Alpha DIALLO <moyodiallo@gmail.com>
@moyodiallo
Copy link
Collaborator

Would you like to confirm if this PR #10240, fixes your issue @jyssh . You can find the branch here https://github.com/moyodiallo/dune/tree/fix-setup-configure.

@jbhoot
Copy link
Author

jbhoot commented Mar 18, 2024

@moyodiallo I am still new at using pkgsrc, the build system that uncovered this bug. So I haven't found out yet how to use a custom url other than the default to build the package.

I will ask for help on pkgsrc channel. But it might take a while - pkgsrc for me is only a backup package manager.

@moyodiallo
Copy link
Collaborator

I drafted the PR opened to fix the issue. It turns out not to be a suitable fix. I'll keep noticing any progress that is made.

@moyodiallo
Copy link
Collaborator

Your issue could be solve by just doing:

$ ./dune.exe install --prefix fake_root --mandir /home/.../dune/fake_root/share/man dune   

And you could add --libdir, --datadir, --bindir, --docdir whenever you need them. It turns out a PR(#10240) is not needed for this issue.

@outpaddling
Copy link

I'm a pkgsrc committer, and this issue has come to my attention as I try to fix some breakage on Darwin.

Any luck figuring out how to make the build system respect configure --mandir?

I could try to hack the pkgsrc package to override the install command, but that would be ugly.

netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this issue Nov 28, 2024
Build system does not respect "configure --mandir"
Added patch to control mandir during install
ocaml/dune#10229
@rgrinberg
Copy link
Member

Could you describe the issue more thoroughly? The workaround in NetBSD/pkgsrc@26f445c
should not be necessary. The makefile in dune is used for development only, and if your goal is to package dune, you should just invoke the build and install commands directly.

For reference, you can see the build commands we use for opam in dune.opam. Note that we don't need an install command because opam automatically installs everything in dune.install.

rgrinberg added a commit that referenced this issue Dec 1, 2024
In symmetric with --prefix in the install command.

Fix #10229

Signed-off-by: Rudi Grinberg <me@rgrinberg.com>

<!-- ps-id: 0a9b3e1e-91d9-4ccf-8780-2210fe3d656c -->
@rgrinberg
Copy link
Member

Reading this issue again, I think we're just missing a prefix argument in the configure script. I added one here: #11172

@outpaddling
Copy link

outpaddling commented Dec 1, 2024

Could you describe the issue more thoroughly? The workaround in NetBSD/pkgsrc@26f445c should not be necessary. The makefile in dune is used for development only, and if your goal is to package dune, you should just invoke the build and install commands directly.

For reference, you can see the build commands we use for opam in dune.opam. Note that we don't need an install command because opam automatically installs everything in dune.install.

Perhaps something like this would be helpful to future users?

--- Makefile.orig       2023-10-09 11:08:29.000000000 +0000
+++ Makefile
@@ -1,9 +1,19 @@
+
+##############################################################################
+# Note: This makefile is only for developers.  End-users and packagers
+# should run the build and install commands directly.
+#
+# See dune.opam for build commands.
+# Install example:
+# dune.exe --prefix PREFIX --libdir LIBDIR --destdir DESTDIR --mandir MANDIR
+##############################################################################
+

@outpaddling
Copy link

outpaddling commented Dec 1, 2024

Reading this issue again, I think we're just missing a prefix argument in the configure script. I added one here: #11172

Actually, I'm not seeing how those changes would help. The issue was exposed when changing mandir to "PREFIX/share/man", instead of just "PREFIX/man" (i.e. PKGMANDIR from "man" to "share/man"). The patches in this pull don't seem to provide any new control over mandir.

rgrinberg added a commit that referenced this issue Dec 8, 2024
In symmetric with --prefix in the install command.

Fix #10229

Signed-off-by: Rudi Grinberg <me@rgrinberg.com>

<!-- ps-id: 0a9b3e1e-91d9-4ccf-8780-2210fe3d656c -->

Signed-off-by: Rudi Grinberg <me@rgrinberg.com>
rgrinberg added a commit that referenced this issue Dec 8, 2024
In symmetric with --prefix in the install command.

Fix #10229

Signed-off-by: Rudi Grinberg <me@rgrinberg.com>

<!-- ps-id: 0a9b3e1e-91d9-4ccf-8780-2210fe3d656c -->

Signed-off-by: Rudi Grinberg <me@rgrinberg.com>
rgrinberg added a commit that referenced this issue Dec 8, 2024
In symmetric with --prefix in the install command.

Fix #10229

Signed-off-by: Rudi Grinberg <me@rgrinberg.com>

<!-- ps-id: 0a9b3e1e-91d9-4ccf-8780-2210fe3d656c -->

Signed-off-by: Rudi Grinberg <me@rgrinberg.com>
rgrinberg added a commit that referenced this issue Dec 8, 2024
In symmetric with --prefix in the install command.

Fix #10229

Signed-off-by: Rudi Grinberg <me@rgrinberg.com>

<!-- ps-id: 0a9b3e1e-91d9-4ccf-8780-2210fe3d656c -->

Signed-off-by: Rudi Grinberg <me@rgrinberg.com>
rgrinberg added a commit that referenced this issue Dec 8, 2024
In symmetric with --prefix in the install command.

Fix #10229

Signed-off-by: Rudi Grinberg <me@rgrinberg.com>

<!-- ps-id: 0a9b3e1e-91d9-4ccf-8780-2210fe3d656c -->

Signed-off-by: Rudi Grinberg <me@rgrinberg.com>
rgrinberg added a commit that referenced this issue Dec 8, 2024
In symmetric with --prefix in the install command.

Fix #10229

Signed-off-by: Rudi Grinberg <me@rgrinberg.com>

<!-- ps-id: 0a9b3e1e-91d9-4ccf-8780-2210fe3d656c -->

Signed-off-by: Rudi Grinberg <me@rgrinberg.com>
rgrinberg added a commit that referenced this issue Dec 8, 2024
In symmetry with --prefix in the install command.

Fix #10229

Signed-off-by: Rudi Grinberg <me@rgrinberg.com>

<!-- ps-id: 0a9b3e1e-91d9-4ccf-8780-2210fe3d656c -->

Signed-off-by: Rudi Grinberg <me@rgrinberg.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
4 participants