Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix(backend): adjust libc detection for musl distros#10020

Open
thespags wants to merge 1 commit into
jdx:mainfrom
thespags:fix-musl-detection-with-gcompat
Open

fix(backend): adjust libc detection for musl distros#10020
thespags wants to merge 1 commit into
jdx:mainfrom
thespags:fix-musl-detection-with-gcompat

Conversation

@thespags
Copy link
Copy Markdown

@thespags thespags commented May 21, 2026

Hi,

I was running into issues where if gcompat was installed on Alpine, mise would select the wrong environment. The workaround is to explicitly set with MISE_LIBC. and refactored out an existing piece that followed the same logic.

Thank you

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 21, 2026

Greptile Summary

This PR fixes libc detection on Alpine Linux (and other musl distros) when gcompat is installed. gcompat places /lib/ld-linux-* shims alongside /lib/ld-musl-*, causing the previous linker-scan logic to misclassify the system as glibc. The fix adds an /etc/os-release-first check that authoritatively identifies known musl distros before falling through to linker detection.

  • src/platform.rs gains a new detect_libc() function with a three-stage detection order (os-release → linker files → compile-time target_env), plus musl_from_os_release() that correctly skips blank/comment lines via continue.
  • The duplicate env_type() in crates/vfox/src/config.rs is removed; vfox_plugin.rs now uses settings.libc() (i.e. MISE_LIBC) first, then falls back to the new detect_libc().

Confidence Score: 5/5

Safe to merge. The os-release check correctly short-circuits linker detection for known musl distros, and MISE_LIBC override precedence is preserved at every call site.

The core fix is narrow and well-tested: musl_from_os_release handles blank lines and comments with continue, the MISE_LIBC env-var override is checked before detect_libc() in both Platform::current() and vfox_plugin.rs, and the duplicate detection code in the vfox crate has been cleanly removed.

No files require special attention.

Important Files Changed

Filename Overview
src/platform.rs Introduces detect_libc() with os-release-first detection and musl_from_os_release(). Blank/comment lines are correctly skipped with continue. Logic correctly handles gcompat on Alpine.
src/plugins/vfox_plugin.rs Adds detect_libc() as fallback after settings.libc() (MISE_LIBC) for env_type resolution; precedence order is correct.
crates/vfox/src/config.rs Removes the duplicate env_type() and its tests; detection is now consolidated in src/platform.rs.
crates/vfox/src/runtime.rs Hardcodes env_type: None in the static initializer/reset; the actual value is injected at call time via Runtime::get(dir, env_type_override), which is correct.
.idea/vcs.xml IDE-generated file; unrelated to the fix.

Reviews (4): Last reviewed commit: "fix(backend): adjust libc detection for ..." | Re-trigger Greptile

Comment thread src/platform.rs
Comment thread crates/vfox/src/config.rs Outdated
Comment thread src/platform.rs
Comment thread .idea/vcs.xml Outdated
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request improves musl libc detection on Linux by parsing /etc/os-release for specific distribution IDs, ensuring correct identification even when compatibility shims like gcompat are present. Review feedback identified a bug in the parsing logic where the use of the ? operator causes the function to exit prematurely when encountering empty lines or comments. Additionally, it is recommended to centralize the musl_from_os_release function to avoid code duplication between the vfox crate and the main platform module.

Comment thread crates/vfox/src/config.rs Outdated
Comment thread src/platform.rs Outdated
Comment thread src/platform.rs
@thespags thespags force-pushed the fix-musl-detection-with-gcompat branch from 786d80d to d78acbb Compare May 22, 2026 04:00
@thespags thespags changed the title adjust libc detection for musl distros fix: adjust libc detection for musl distros May 22, 2026
@thespags thespags changed the title fix: adjust libc detection for musl distros fix (backend): adjust libc detection for musl distros May 22, 2026
@thespags thespags changed the title fix (backend): adjust libc detection for musl distros fix(backend): adjust libc detection for musl distros May 22, 2026
Comment thread crates/vfox/Cargo.toml Outdated
env_logger = { version = "0.11", optional = true }
clap = { version = "4", features = ["derive"], optional = true }
tempfile = "3"
mise-libc-detect = { path = "../mise-libc-detect" }
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a whole new crate for this seems excessive

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @jdx thanks for the view.
Where would you prefer the code live?

  1. Duplicate the code between vfox and mise
  2. Move the code into vfox
  3. An independent crate

I don't have a strong opinion and want to respect your preference. Thank you.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or something else?

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would probably just configure vfox from the mise crate

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated @jdx

@thespags thespags force-pushed the fix-musl-detection-with-gcompat branch from d78acbb to db444ff Compare May 27, 2026 04:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants