Skip to content

feat(linux): install udev rules with an explained cross-distro root prompt - #1622

Merged
zackees merged 2 commits into
mainfrom
feat/1621-udev-install
Oct 2, 2026
Merged

zackees merged 2 commits into
mainfrom
feat/1621-udev-install

Conversation

@zackees

@zackees zackees commented Oct 2, 2026

Copy link
Copy Markdown
Member

Closes #1621.

What changes

  • fbuild port udev --install installs the USB rules through whatever root prompt the host has:
    • pkexec, which shows the desktop's polkit dialog, or its text agent on a tty;
    • sudo on a terminal;
    • sudo -A with an askpass helper.
      If none is available, it prints the exact manual command.
  • The user is told why before any password prompt. fbuild shows its own dialog (kdialog on KDE, zenity elsewhere, terminal text otherwise). It says it is installing USB device rules so boards can be opened without root, that this is one-time, the file it writes, and the command to run yourself instead. Skip prints that command and changes nothing.
  • The polkit dialog names a helper, not a shell one-liner. pkexec runs fbuild-install-usb-rules <destination> … from a private temp dir. The helper's arguments are only paths fbuild generated, so no user text reaches a root shell.
  • deploy, monitor and debug run a Linux preflight. If an attached board from a registry vendor can't be opened and the rules are missing or stale, they offer the install. The prompt is never raised in CI, with FBUILD_NO_ELEVATE=1, or in a non-interactive session; those get the command instead.
  • The rules cover what actually failed. They now add usb and hidraw alongside tty, so probe-rs, picotool, DFU and HID loaders can open their devices. They add TAG+="uaccess" and are installed as 70-fbuild.rules so they sort before logind's 73-seat-late.rules, which is what grants the ACL; a stale 99-fbuild.rules is removed.
  • GROUP= is only emitted when the group exists. udev discards the entire line when a group doesn't resolve (Failed to resolve group 'plugdev', ignoring). plugdev doesn't exist on NixOS, Arch or Fedora, so the feat(linux): own udev rules setup — deploy fails with 'Permission denied' but advises cables and BOOTSEL #1424 rules matched nothing there.
  • NixOS: /etc/udev/rules.d is a read-only store symlink, so the rules go to /run/udev/rules.d, which udevd also reads. fbuild then prints the services.udev.extraRules snippet for a permanent install.

Evidence (NixOS 26.05, KDE, LPC845-BRK on LPC-Link2 1fc9:0132)

Before:

/dev/bus/usb/001/015  crw-rw-r-- root root
probe-rs: Failed to open probe: The selected USB device could not be opened.
fbuild_deploy::lpc: probe-rs SWD flash exited 1; falling back to lpc21isp UART ISP
deploy error: failed to spawn ["lpc21isp", ...]: No such file or directory

After fbuild port udev --install:

udev rules installed at /run/udev/rules.d/70-fbuild.rules
/dev/bus/usb/001/015  crw-rw----+ root root   (getfacl: user:niteris:rw-)

bash autoresearch lpc845 (FastLED, this build via FBUILD_EXECUTABLE) now deploys through probe-rs, with no lpc21isp fallback:

✅ Deploy succeeded (fbuild) [79.4s]

The first attempt also showed the plugdev problem: the rules were read but every line was dropped (/run/udev/rules.d/70-fbuild.rules:16 Failed to resolve group 'plugdev', ignoring: Unknown group), and the device kept TAGS=:seat: with no uaccess.

Tests

  • 27 udev tests:
    • rendering: three subsystems, uaccess, sorting before 73, no GROUP without the group, group-database lookup;
    • elevation choice for root, desktop, terminal, askpass and none;
    • auto-prompt suppression (CI, opt-out, headless) and the NixOS /run target;
    • the pkexec argv (named helper with the destination first, no sh -c);
    • helper script, explanation text (what, why, one-time, manual command), and an idempotent rules check.
  • soldr cargo test -p fbuild-cli: 352 passed. Clippy -D warnings and fmt are clean, and find_direct_subprocess.py --fail passes.

…rompt (#1621)

fbuild port udev --install (and a deploy/monitor/debug preflight) installs
USB rules covering tty, raw usb and hidraw with TAG+=uaccess as
70-fbuild.rules, after an fbuild dialog that explains why and gives the
manual command. Elevates via pkexec (polkit dialog), sudo, or sudo -A;
NixOS installs to /run/udev/rules.d and prints the extraRules snippet.
GROUP is only emitted when the group exists: udev drops the whole rule
line for an unknown group, so the plugdev rules never applied on
NixOS/Arch/Fedora.

Closes #1621
@coderabbitai

coderabbitai Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 50 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Repository: FastLED/fbuild/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 3723a9cb-745e-4436-af30-737e9a76ab5d

📥 Commits

Reviewing files that changed from the base of the PR and between fcf8aaa and f39ae43.

📒 Files selected for processing (7)
  • crates/fbuild-cli/src/cli/debug.rs
  • crates/fbuild-cli/src/cli/deploy.rs
  • crates/fbuild-cli/src/cli/mod.rs
  • crates/fbuild-cli/src/cli/port_scan.rs
  • crates/fbuild-cli/src/cli/udev.rs
  • crates/fbuild-cli/src/cli/udev_install.rs
  • crates/fbuild-cli/src/cli/udev_install_tests.rs
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

…emp dir (#1621)

Dylint and the platform-boundary inventory rejected the new installer:
cfg!(target_os) and std::os::unix PermissionsExt outside
fbuild_core::platform (also a Windows compile break), raw PathBuf, and an
unrooted tempfile tempdir. Use platform::host::is_linux,
platform::fs::set_executable, NormalizedPath, and tempdir_in under
fbuild_paths::temp_subdir. Behavior is otherwise unchanged.
@zackees
zackees merged commit 2db8bee into main Oct 2, 2026
23 checks passed
@zackees
zackees deleted the feat/1621-udev-install branch October 2, 2026 21:48
zackees added a commit that referenced this pull request Oct 2, 2026
…ass on Windows (#1626)

NormalizedPath::display() prints backslashes on Windows, so the
pkexec/sudo argv tests added in #1622 failed the 2.5.32 release
dry run (windows Check job). display_slash is identity on Unix,
where this argv actually executes, so Linux behavior is unchanged.
@fastled-project-sync fastled-project-sync Bot moved this to Triage in FastLED Tracker Oct 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

Linux: install udev rules automatically with a cross-distro root prompt (pkexec/sudo), covering raw USB for probe-rs

1 participant