使用*ocaml\u TAR创建TAR文件时,结束\u文件异常*

使用*ocaml\u TAR创建TAR文件时,结束\u文件异常*,ocaml,Ocaml,当我尝试使用ocaml\u TAR库创建TAR文件时,我得到一个文件结束异常 我的代码 #require "tar";; #require "tar.unix";; let f = Unix.openfile "test.tar" [ Unix.O_RDWR; Unix.O_CREAT ] 0o600;; Tar_unix.Archive.create ["write_ex.ml"] f;; Unix.close f;; 。。。生成以下堆栈跟踪: $ utop write_ex.ml Exce

当我尝试使用ocaml\u TAR库创建TAR文件时,我得到一个文件结束异常

我的代码

#require "tar";;
#require "tar.unix";;
let f = Unix.openfile "test.tar" [ Unix.O_RDWR; Unix.O_CREAT ] 0o600;;
Tar_unix.Archive.create ["write_ex.ml"] f;;
Unix.close f;;
。。。生成以下堆栈跟踪:

$ utop write_ex.ml
Exception: End_of_file.
Raised at file "lib/tar.ml", line 549, characters 36-47
Called from file "lib/tar.ml", line 460, characters 4-11
Called from file "stream.ml", line 149, characters 33-38
Called from file "lib/tar.ml", line 578, characters 6-28
Called from file "toplevel/toploop.ml", line 180, characters 17-56

有人知道出了什么问题吗?

您的代码没有问题。它实际上是unix模块中的一个bug。
输出
函数不够健壮,如果写入被截断,则会导致文件结束异常。我已经解决了这个问题,您的代码运行良好。有关更多信息,请参阅我的

更新 PR被合并,较新的(0.5.1)版本发布到opam。升级至最新版本,方法是:

opam update
opam upgrade
通过查询opam,确保安装了最新的(>=0.5.1)版本

opam show tar-format
如果仍然旧,则强制opam安装最新的:

opam install 'tar-format>=0.5.1'
你可能想,已经是了