Skip to content

fix(win): meson DirectoryLock crashes on fresh build dir #114

Closed

Description

@zackees

Bug

After fixing #111 and #113, the next Windows build failure is a Meson upstream crash:

[WASM] Configuring meson (mode: quick)...
Traceback (most recent call last):
  File "...mesonbuild\msetup.py", line 191, in generate
    with mesonlib.DirectoryLock(self.build_dir, 'meson-private/meson.lock', FAIL, ...):
  File "...mesonbuild\utils\win32.py", line 34, in __enter__
    msvcrt.locking(self.lockfile.fileno(), mode, 1)
                   ^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'fileno'

Cause

Meson 1.9.1's DirectoryLock.__enter__ on Windows tries to open(<build_dir>/meson-private/meson.lock, 'w+') before meson has created the meson-private directory. The open() raises an OSError that the except OSError branch silently swallows (it only re-raises FileNotFoundError/IsADirectoryError), leaving self.lockfile = None. Then msvcrt.locking(self.lockfile.fileno(), ...) crashes.

This is a Meson upstream bug, but we can avoid it by pre-creating the directory so the open() succeeds.

Fix

In crates/fastled-cli/src/wasm_build.rs, add fs::create_dir_all(build_dir.join("meson-private"))?; before invoking meson setup. Repro: fastled --just-compile --quick against any sketch on Windows with a fresh .build/ directory.

Activity

  1. zackees commented on May 31, 2026

    @zackees
    MemberAuthor

    Root cause clarified — the meson DirectoryLock crash is triggered by us passing the canonicalized Windows long-path form (\?\C:\...) as the build_dir argument to meson.

    Python on Windows can't open() a file whose path uses the \?\ prefix from canonicalized paths before handing them to meson (and any other external Python tool). Done by adding strip_windows_unc_prefixtonormalize_pathinwasm_build.rs`.

  2. zackees commented on Jun 2, 2026

    @zackees
    MemberAuthor

    Resolved by merged PR #118 (e008ca3e). Current origin/main routes wasm_build::normalize_path through crate::path::canonicalize_normalized, which strips Windows \\?\ long-path prefixes before paths are handed to Meson/Python tools.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions