Skip to content

Circular directories result in infinite loop when recursive pattern is used #8736

Closed

Description

@Cookie04DE

Describe the bug

When you use a recursive pattern and nu traverses a circular directory structure it get's stuck forever.

How to reproduce

  1. cd /
  2. ls **/sources.list
  3. See that nu get's stuck on proc/<pid>/cwd/ and returns "(proc/<pid>/cwd/)" * n + "etc/apt/sources.list" until you abort the command.

Expected behavior

Nu should detect that it already traversed a directory and continue looking elsewhere.

Screenshots

No response

Configuration

key value
version 0.77.2
branch main
commit_hash b84a01c
build_os linux-aarch64
build_target aarch64-unknown-linux-gnu
rust_version rustc 1.66.1 (90743e729 2023-01-10)
rust_channel 1.66.1-aarch64-unknown-linux-gnu
cargo_version cargo 1.66.1 (ad779e08b 2023-01-10)
build_time 2023-04-04 10:09:20 +02:00
build_rust_channel release
features default, zip
installed_plugins

Additional context

No response

Activity

  1. Cookie04DE commented on Apr 4, 2023

    @Cookie04DE
    Author

    I found this workaround for now:
    ls **/sources.list | compact | first

  2. added
    A:file-system
    on Apr 4, 2023
  3. kronberger-droid commented on Nov 13, 2026

    @kronberger-droid
    Contributor

    Still reproduces on 0.117.

    mkdir root/p/1 root/etc/apt; touch root/etc/apt/sources.list
    ^ln -s ../.. root/p/1/cwd; cd root
    ls **/sources.list | length   # 41
    

    The glob follows the loop until the symlink limit of the kernel.
    With a second loop link it ends in "Too many levels of symbolic links" or doesn't finish at all.

  4. manavkdubey commented on Nov 20, 2026

    @manavkdubey
    Contributor

    Hey! I opened #19622 to fix this. Recursive globs now stop descending when a symlink leads back to an ancestor. I verified on macOS that both glob backends still find the file and continue searching sibling directories.

  5. added this to the v0.118.0 milestone on Nov 21, 2026
  6. added a commit that references this issue on Nov 21, 2026
    d5b8ab0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A:file-systemcategory:bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions