Skip to main content

Check Symlinks

Test status Deploy Status Arch User Repsoitory PyPI

Check for broken symbolic links.

$ check-symlinks
Broken symlink: some/path/broken_link

check-symlinks is optimized for large codebases as well as small, incremental checks,

Bar chart of benchmark results: check-symlinks 4.0 ms, fd 15.6 ms, check_symlinks.py 104.3 ms, find 150.1 ms, shell loop 225.4 ms.

where the full commands are respectively,

check-symlinks

fd --type symlink --exec sh -c 'test -e "$0"'

git ls-files | xargs pre_commit_hooks/check_symlinks.py

find . -type l ! -exec test -e {} \; -print0 | xargs --no-run-if-empty -0 git ls-files

while read file; do test -e "$file"; done < <(git ls-files)

and check_symlinks.py is from https://github.com/pre-commit/pre-commit-hooks. Regenerate the chart with scripts/gen-benchmark-chart.py, which documents the exact hyperfine invocations.

Install

pre-commit:

repos:
  - repo: https://github.com/jmelahman/check-symlinks
    rev: v0.6.0
    hooks:
      - id: check-symlinks

The check-symlinks hook is built from source by pre-commit's Go toolchain and has no other dependencies. Use check-symlinks-system instead to run a binary already on PATH.

AUR:

check-symlinks is available from the Arch User Repository.

yay -S check-symlinks

pip:

check-symlinks is available as a pypi package.

pip install check-symlinks

Binaries:

Static binaries for Linux and macOS (amd64 and arm64) are attached to every release.

Usage

check-symlinks [flags] [path ...]

With no paths, the current directory is walked. Flags must precede the paths.

Flag Description
--hidden Include hidden files and directories in the walk.
--no-ignore Ignore .symlinkignore / .config/symlinkignore.
--threads N Number of worker threads (0 = one per CPU).
-q, --quiet Don't print broken links.
--debug Report which ignore file was loaded and which paths it skipped.
--version Print the version and exit.

Exit status is 0 when every symlink resolves, 1 when at least one is broken, and 2 on a usage error.

Paths listed in .symlinkignore (or .config/symlinkignore) at the top of the repository are skipped. Hidden entries are skipped while walking, but a hidden path named on the command line is always checked.

Building

check-symlinks is written in Solod, a strict subset of Go that translates to C: release binaries are a few hundred kilobytes, start instantly, and have no runtime dependencies. The same sources build with either toolchain — see CONTRIBUTING.md.

so build -o check-symlinks ./so   # solod (needs the so tool and a C compiler)
go build .                        # Go, via the gocompat shims

Windows is not supported: Solod's os package is POSIX-only.

Metadata

Release files for check-symlinks 0.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for check-symlinks 0.6.0
File Size Uploaded
check_symlinks-0.6.0.tar.gz 21.3 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for check-symlinks 0.6.0
File
check_symlinks-0.6.0-py3-none-manylinux_2_17_x86_64.whl Python 3 none Linux glibc 2.17+ x86-64 Details
check_symlinks-0.6.0-py3-none-manylinux_2_17_aarch64.whl Python 3 none Linux glibc 2.17+ ARM64 Details
check_symlinks-0.6.0-py3-none-macosx_11_0_arm64.whl Python 3 none macOS 11.0+ ARM64 Details
check_symlinks-0.6.0-py3-none-macosx_10_12_x86_64.whl Python 3 none macOS 10.12+ x86-64 Details

Total release size: 365.1 kB

Release history Release notifications | RSS feed

This release

0.6.0 This release

5 release files

0.5.3

7 release files

0.5.2

7 release files

0.5.1

7 release files

0.5.0

7 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page