Skip to content

fix(pkg): pass explicit -z/-j flags for non-auto-detecting tar#13688

Open
Alizter wants to merge 1 commit intoocaml:mainfrom
Alizter:push-psnuumsxxwlr
Open

fix(pkg): pass explicit -z/-j flags for non-auto-detecting tar#13688
Alizter wants to merge 1 commit intoocaml:mainfrom
Alizter:push-psnuumsxxwlr

Conversation

@Alizter
Copy link
Collaborator

@Alizter Alizter commented Feb 27, 2026

OpenBSD tar doesn't auto-detect compression format and requires explicit -z (gzip) or -j (bzip2) flags.

This adds tar implementation detection via --version output:

  • 'bsdtar' or 'libarchive' -> BSD tar (auto-detects compression)
  • 'GNU tar' -> GNU tar (auto-detects compression)
  • Otherwise -> Other (needs explicit flags)

Fixes #10123

@Leonidas-from-XIV
Copy link
Collaborator

What about archives that are compressed with xz? opam-repository has a few of those. Also, opam supports xz as well as lzma.

@Alizter
Copy link
Collaborator Author

Alizter commented Mar 2, 2026

I think supporting these compression formats explicitly should be a separate issue. Can you open an issue (for each)?

@Leonidas-from-XIV
Copy link
Collaborator

#13715 and #13716

@Alizter Alizter force-pushed the push-psnuumsxxwlr branch from c75647a to 0e10e56 Compare March 4, 2026 09:55
OpenBSD tar doesn't auto-detect compression format and requires
explicit -z (gzip) or -j (bzip2) flags.

This adds tar implementation detection via --version output:
- 'bsdtar' or 'libarchive' -> BSD tar (auto-detects compression)
- 'GNU tar' -> GNU tar (auto-detects compression)
- Otherwise -> Other (needs explicit flags)

Fixes ocaml#10123

Signed-off-by: Ali Caglayan <alizter@gmail.com>
(* CR-soon alizter: handle .tar.xz (-J) and .tar.lzma (--lzma) which
OPAM also supports. Should error with a clear message if the tar
implementation doesn't support auto-detection for these formats. *)
[]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still think that throwing an User_error here is better since in this code branch we're dealing with e.g. OpenBSD tar which just doesn't support -J or --lzma. Thus returning [] will just make it fail later on, when tar xf archive.tar.xz happens. Here we can at least error out with a better error message ("Your tar does not support XZ decompression" "Hint: Install libarchive bsdtar maybe").

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tar on OpenBSD

2 participants