Skip to content

Error with directory symlink: Unexpected file kind "S_DIR" #9873

Closed

Description

@emillon

Hi,

When a directory target contains a directory symlink (symlink whose target is a directory), the following error happens:

  Error: Error trying to read targets after a rule was run:
  - d/b: Unexpected file kind "S_DIR" (directory)
  [1]

This can be found when building ocamlbuild through pkg rules, since its source tree contains such symlinks.

I bisected that to b1c339b in #9407 (@rleshchinskiy).

Activity

  1. added a commit that references this issue on Jan 31, 2024
  2. emillon commented on Jan 31, 2024

    @emillon
    CollaboratorAuthor

    Repro in #9874.

  3. ncitron commented on Feb 27, 2025

    @ncitron

    I have been experiencing this failure on the dune preview (version cd00c2a) when it tries to compile ocamlbuild 0.16.1, which includes a symlink in one of the codebases example folders.

    Any advice for how to resolve?

  4. ncitron commented on Feb 27, 2025

    @ncitron

    Following up here: I was able to resolve this by downgrading ocamlbuild to version 0.15.0, so maybe this issue is better addressed by them.

  5. added
    package management
    on Jul 31, 2025
  6. shonfeder commented on Aug 8, 2025

    @shonfeder
    Member

    It seems to be that this prevents having fstar as a dependency in projects managed by dune pkg:

    $ dune build
    File "dune.lock/fstar.2025.03.25.pkg", line 38, characters 3-74:
    38 |    https://github.com/FStarLang/FStar/archive/refs/tags/v2025.03.25.tar.gz)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    Error: Error trying to read targets after a rule was run:
    - checksum/md5=2d7f02d2931ddc9c74abdac9eb165ed0/dir/stage1/dune/fstar-guts/app: Unexpected file kind "S_DIR" (directory)
    - checksum/md5=2d7f02d2931ddc9c74abdac9eb165ed0/dir/stage1/dune/fstar-guts/ml: Unexpected file kind "S_DIR" (directory)
    - checksum/md5=2d7f02d2931ddc9c74abdac9eb165ed0/dir/stage1/dune/fstar-plugins/app: Unexpected file kind "S_DIR" (directory)
    - checksum/md5=2d7f02d2931ddc9c74abdac9eb165ed0/dir/stage1/dune/fstar-plugins/plugin: Unexpected file kind "S_DIR" (directory)
    - checksum/md5=2d7f02d2931ddc9c74abdac9eb165ed0/dir/stage1/dune/libapp/app: Unexpected file kind "S_DIR" (directory)
    - checksum/md5=2d7f02d2931ddc9c74abdac9eb165ed0/dir/stage1/dune/libapp/app-extra: Unexpected file kind "S_DIR" (directory)
    - checksum/md5=2d7f02d2931ddc9c74abdac9eb165ed0/dir/stage1/dune/libplugin/app: Unexpected file kind "S_DIR" (directory)
    - checksum/md5=2d7f02d2931ddc9c74abdac9eb165ed0/dir/stage1/dune/libplugin/app-extra: Unexpected file kind "S_DIR" (directory)
    - checksum/md5=2d7f02d2931ddc9c74abdac9eb165ed0/dir/stage1/dune/libplugin/plugin: Unexpected file kind "S_DIR" (directory)
    - checksum/md5=2d7f02d2931ddc9c74abdac9eb165ed0/dir/stage1/ulib: Unexpected file kind "S_DIR" (directory)
    - checksum/md5=2d7f02d2931ddc9c74abdac9eb165ed0/dir/stage2/dune/fstar-guts/app: Unexpected file kind "S_DIR" (directory)
    - checksum/md5=2d7f02d2931ddc9c74abdac9eb165ed0/dir/stage2/dune/fstar-guts/ml: Unexpected file kind "S_DIR" (directory)
    - checksum/md5=2d7f02d2931ddc9c74abdac9eb165ed0/dir/stage2/dune/fstar-plugins/app: Unexpected file kind "S_DIR" (directory)
    - checksum/md5=2d7f02d2931ddc9c74abdac9eb165ed0/dir/stage2/dune/fstar-plugins/plugin: Unexpected file kind "S_DIR" (directory)
    - checksum/md5=2d7f02d2931ddc9c74abdac9eb165ed0/dir/stage2/dune/libapp/app: Unexpected file kind "S_DIR" (directory)
    - checksum/md5=2d7f02d2931ddc9c74abdac9eb165ed0/dir/stage2/dune/libapp/app-extra: Unexpected file kind "S_DIR" (directory)
    - checksum/md5=2d7f02d2931ddc9c74abdac9eb165ed0/dir/stage2/dune/libplugin/app: Unexpected file kind "S_DIR" (directory)
    - checksum/md5=2d7f02d2931ddc9c74abdac9eb165ed0/dir/stage2/dune/libplugin/app-extra: Unexpected file kind "S_DIR" (directory)
    - checksum/md5=2d7f02d2931ddc9c74abdac9eb165ed0/dir/stage2/dune/libplugin/plugin: Unexpected file kind "S_DIR" (directory)
    - checksum/md5=2d7f02d2931ddc9c74abdac9eb165ed0/dir/stage2/ulib: Unexpected file kind "S_DIR" (directory)
    
    
  7. giltho commented on Aug 20, 2025

    @giltho

    Hello, I also hit this when trying to install a pinned version of https://github.com/AeneasVerif/charon (funnily enough, not unrelated to fstar). It's also because there is a symlinked folder somewhere.

  8. shonfeder commented on Sep 3, 2025

    @shonfeder
    Member

    @ElectreAAS will be picking this up. She will connect with @Leonidas-from-XIV first to determine whether he has come part way to the solution.

    Update: @Leonidas-from-XIV noted that his PR is here #10426 ! It is passing tests and has no merge conflicts. There are some questions to be addressed there.

  9. 1 remaining item

  10. Sudha247 commented on Nov 19, 2025

    @Sudha247
    Member

    I encountered this when trying to build the OxCaml fork of odoc-parser, a part of odoc. I was trying to build this with dune pkg and 5.2.0+ox compiler.

    File "dune.lock/odoc-parser.pkg", line 15, characters 3-82:
    15 |    git+https://github.com/oxcaml/odoc.git#97e1daecb432d33a7137d525f7a554f203073a95)))
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    Error: Error trying to read targets after a rule was run:
    - url/ebca61d809da743073794a02009c3602/dir/test/generators/html/fonts: Unexpected file kind "S_DIR" (directory)
    

    Looking at the odoc repository, it does have a few symlinks:

    $ find . -type l -ls
      6184620      0 lrwxrwxrwx   1 sudha    sudha           8 Nov 17 13:42 ./doc/index.mld -> odoc.mld
     12756655      0 lrwxrwxrwx   1 sudha    sudha          37 Nov 17 13:42 ./test/generators/html/fonts -> ../../../src/html_support_files/fonts
     12756677      0 lrwxrwxrwx   1 sudha    sudha          40 Nov 17 12:42 ./test/generators/html/odoc.css -> ../../../src/html_support_files/odoc.css
     12756660      0 lrwxrwxrwx   1 sudha    sudha          49 Nov 17 12:42 ./test/generators/html/highlight.pack.js -> ../../../src/html_support_files/highlight.pack.js
     12756666      0 lrwxrwxrwx   1 sudha    sudha          44 Nov 17 12:42 ./test/generators/html/katex.min.js -> ../../../src/html_support_files/katex.min.js
     12756665      0 lrwxrwxrwx   1 sudha    sudha          45 Nov 17 12:42 ./test/generators/html/katex.min.css -> ../../../src/html_support_files/katex.min.css
     12756250      0 lrwxrwxrwx   1 sudha    sudha          34 Nov 17 12:42 ./test/generators/cases/ocamlary.mli -> ../../../src/ocamlary/ocamlary.mli
    

    But, curiously, the symlink issue doesn't appear with the mainline compiler. odoc and friends build okay when building with dune pkg and stock OCaml compiler. I'm going to remove the symlinks and try to build with OxCaml.

  11. shonfeder commented on Nov 25, 2025

    @shonfeder
    Member

    In #12613, @Alizter notes:

    Coming back to the original issue #9873, it only seems to occur with pathological examples. I have yet to see a package where a directory symlink is a critical part of the build and dune does not offer a sound work-around. Many packages that appear in practice can therefore be patched in our pkg overlays, as we have done for ocamlbuild.

    If the need arises in the future that a commonly used package needs this feature, then it would be enough motivation to rethink the solution here.

    For this reason, and because the fix is apparently not as straightforward as one may think, we have deprioritized work in this issue and removed it form the MSP.

    But I am still of the opinion it should be fixed.

  12. removed their assignment
    on Dec 12, 2025
  13. removed this from the [pkg]: Stable Product milestone on Apr 22, 2026
  14. added theissue type on May 4, 2026
  15. shonfeder commented on May 6, 2026

    @shonfeder
    Member

    IIUC, #13792 should have largely addressed this. But if there are outstanding issues, could you update here with details @ElectreAAS?

  16. ElectreAAS commented on May 7, 2026

    @ElectreAAS
    Collaborator

    This is indeed partially solved by #13792.
    The original reported issue was building ocamlbuild as a package dependency (this is now fixed), however the reproduction in #9874 is slightly different: it shows that we have the exact same problem when building a local package with dune rules that contains a directory symlink, and that is not fixed.
    The way to fix that would be to properly support directory symlinks in the dune engine, which is waaaay more complicated than what I'm doing in #13792, and importantly here, not needed to build ocamlbuild as a package.
    I am hence closing this issue as partially fixed (in the case of dune pkg), and partially not planned (in the case of directory symlinks in the rest of dune)

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

Metadata

Metadata

Assignees

Labels

package management

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions