feat(vfox): add RUNTIME.envType for libc variant detection#8493
feat(vfox): add RUNTIME.envType for libc variant detection#8493
RUNTIME.envType for libc variant detection#8493Conversation
Add env_type() function in crates/vfox/src/config.rs that detects the
libc environment type at runtime on Linux by scanning /lib and /lib64
for the dynamic linker (ld-linux-* for glibc, ld-musl-* for musl).
Returns Some("gnu"), Some("musl"), or None on non-Linux platforms.
Add cross-reference comments to both is_musl_system() in src/platform.rs
and env_type() in crates/vfox/src/config.rs to keep the duplicated
logic in sync.
Assisted-By: Claude Opus 4.6 via GitHub Copilot
Add env_type: Option<String> field to the vfox Runtime struct, populated from the env_type() helper added in the previous commit. Exposed to Lua plugins as RUNTIME.envType — returns "gnu" on glibc Linux, "musl" on musl Linux, and nil on all other platforms. Runtime::with_platform() sets env_type to None since the target libc variant is unknown in cross-platform URL generation context. Add set_env_type() test helper and update reset() to restore env_type. Assisted-By: Claude Opus 4.6 via GitHub Copilot
Add RUNTIME.envType to the Lua type definitions in mise-plugin.lua and to the RUNTIME reference sections in both backend-plugin-development.md and tool-plugin-development.md. Also add previously missing RUNTIME.version and RUNTIME.pluginDirPath entries to tool-plugin-development.md for parity with backend-plugin-development.md. Assisted-By: Claude Opus 4.6 via GitHub Copilot
Relax Linux env_type test to allow None when libc detection is unavailable, matching the documented contract. Add a runtime regression test to assert RUNTIME.envType is nil when RUNTIME is overridden via Runtime::with_platform for cross-platform hook execution. Assisted-By: GPT-5.3-Codex via GitHub Copilot
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the vfox runtime by exposing the detected libc environment type (glibc or musl) to Lua plugins via a new Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
Greptile SummaryThis PR exposes the libc variant detection introduced in #8490 to vfox Lua plugins via a new Key changes:
Minor style observations:
Confidence Score: 4/5
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[env_type called] --> B{target_os = linux?}
B -- No --> C[return None]
B -- Yes --> D{/lib or /lib64 contains ld-linux-* ?}
D -- Yes --> E[return Some-gnu]
D -- No --> F{/lib contains ld-musl-* ?}
F -- Yes --> G[return Some-musl]
F -- No --> H[return None]
subgraph Runtime Initialisation
I[Runtime::new] --> J[env_type = env_type]
K[Runtime::with_platform] --> L[env_type = None\ntarget libc unknown]
end
subgraph Lua Exposure
M[RUNTIME.envType] --> N{env_type value}
N -- Some-gnu --> O[Lua string 'gnu']
N -- Some-musl --> P[Lua string 'musl']
N -- None --> Q[Lua nil]
end
Last reviewed commit: 118ebf4 |
There was a problem hiding this comment.
Code Review
This pull request introduces RUNTIME.envType to expose libc variant detection to vfox plugins, which is a valuable addition for creating platform-specific logic. The implementation is well-executed, with the core detection logic in crates/vfox/src/config.rs being efficient and correctly memoized. The changes are consistently applied across the runtime, documentation, and type definitions. I particularly appreciate the new test case that verifies the behavior for platform overrides, ensuring robustness. Overall, this is a high-quality contribution.
Make test_env_type_linux_is_valid meaningfully stricter than the
cross-platform test_env_type by asserting env_type() returns Some("gnu")
or Some("musl") on Linux, rather than also accepting None.
Assisted-By: Claude Opus 4.6 <noreply@anthropic.com>
…dard systems Drop test_env_type_linux_is_valid since it would break for contributors on Linux systems without standard glibc/musl linker paths (e.g., minimal containers, statically-linked setups). The cross-platform test_env_type already validates all valid return values. Assisted-By: Claude Opus 4.6 <noreply@anthropic.com>
| pub(crate) fn env_type() -> Option<String> { | ||
| use once_cell::sync::Lazy; | ||
| static ENV_TYPE: Lazy<Option<String>> = Lazy::new(|| { | ||
| // If glibc's dynamic linker exists, this is a glibc system | ||
| for dir in ["/lib", "/lib64"] { | ||
| if has_file_prefix(dir, "ld-linux-") { | ||
| return Some("gnu".to_string()); | ||
| } | ||
| } | ||
| // No glibc linker found — check for musl's | ||
| if has_file_prefix("/lib", "ld-musl-") { | ||
| return Some("musl".to_string()); | ||
| } | ||
| None | ||
| }); | ||
| ENV_TYPE.clone() | ||
| } |
There was a problem hiding this comment.
once_cell::Lazy vs stdlib LazyLock
The src/platform.rs counterpart uses std::sync::LazyLock (stable since Rust 1.80), while this implementation uses once_cell::sync::Lazy imported inline. Because the vfox crate already depends on once_cell elsewhere (runtime.rs uses it at the module level), there is no new dependency concern — but the two "mirrored" implementations now rely on different lazy-init primitives, which adds a subtle inconsistency for anyone reading both files side-by-side.
If the MSRV allows it, aligning on std::sync::LazyLock would match platform.rs exactly:
use std::sync::LazyLock;
static ENV_TYPE: LazyLock<Option<String>> = LazyLock::new(|| {
// …same body…
});This is purely a style/consistency observation; both approaches are functionally identical.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
There was a problem hiding this comment.
RUNTIME itself is using once_cell::Lazy:
mise/crates/vfox/src/runtime.rs
Lines 15 to 22 in 6d69c1f
(As does SDKS.)
If anything, this should be refactored in a separate PR.
| #[test] | ||
| async fn test_runtime_env_type_is_nil_for_platform_override() { | ||
| let plugin = Plugin::test("dummy"); | ||
|
|
||
| Runtime::set_env_type(Some("gnu".to_string())); | ||
|
|
||
| let host_env_type: Option<String> = plugin | ||
| .eval_async(chunk! { | ||
| return RUNTIME.envType | ||
| }) | ||
| .await | ||
| .unwrap(); | ||
| assert_eq!(host_env_type, Some("gnu".to_string())); | ||
|
|
||
| let target_runtime = Runtime::with_platform(plugin.dir.clone(), "linux", "amd64"); | ||
| let target_os = "linux".to_string(); | ||
| let target_arch = "amd64".to_string(); | ||
| let target_env_type: Option<String> = plugin | ||
| .eval_async(chunk! { | ||
| local saved_os = OS_TYPE | ||
| local saved_arch = ARCH_TYPE | ||
| local saved_runtime = RUNTIME | ||
| OS_TYPE = $target_os | ||
| ARCH_TYPE = $target_arch | ||
| RUNTIME = $target_runtime | ||
| local env_type = RUNTIME.envType | ||
| OS_TYPE = saved_os | ||
| ARCH_TYPE = saved_arch | ||
| RUNTIME = saved_runtime | ||
| return env_type | ||
| }) | ||
| .await | ||
| .unwrap(); | ||
| assert_eq!(target_env_type, None); | ||
|
|
||
| Runtime::reset(); | ||
| } |
There was a problem hiding this comment.
Test does not guard against panic before Runtime::reset()
Runtime::set_env_type(Some("gnu".to_string())) mutates the process-wide RUNTIME singleton. If the test panics between that call and Runtime::reset() at line 287, the global state is left dirty and can affect other tests running in the same process.
The existing pattern in this file (e.g., test_linux_arm64_and_windows_x64) has the same issue, so this is not unique to this PR. However, since a new test is being added here it is worth noting. A scopeguard-style defer, or wrapping the body in a closure with std::panic::catch_unwind, would make the reset unconditional:
let _guard = scopeguard::defer(|| Runtime::reset());Alternatively, a Drop wrapper around the mutation would achieve the same effect.
This is low priority given that cargo test passes and the existing tests follow the same pattern.
### 🚀 Features - **(vfox)** add `RUNTIME.envType` for libc variant detection by @malept in [#8493](#8493) - store provenance verification results in lockfile by @jdx in [#8495](#8495) ### 🐛 Bug Fixes - **(env)** skip remote version fetching for "latest" in prefer-offline mode by @jdx in [#8500](#8500) - **(tasks)** deduplicate shared deps across task delegation by @vadimpiven in [#8497](#8497) - **(windows)** correctly identify mise binary without extension by @jdx in [#8503](#8503) ### 🚜 Refactor - **(core)** migrate cmd! callers to async with kill_on_drop by @jdx in [a63f7d2](a63f7d2) ### Chore - **(ci)** temporarily disable `mise up` in release-plz by @jdx in [#8504](#8504) - consolidate all linters into hk.pkl by @jdx in [#8498](#8498) ## 📦 Aqua Registry Updates #### New Packages (1) - [`apache/ant`](https://github.com/apache/ant)
Summary
Expose the libc type detection added in #8490 to vfox plugins, in the
RUNTIMEglobal table.Details
RUNTIME.envTypeto vfox Lua plugins ("gnu"for glibc Linux,"musl"for musl Linux,nilotherwise)env_type()incrates/vfox/src/config.rsto detect libc at runtime via/liband/lib64linker namescrates/vfox/src/config.rsandsrc/platform.rsto keep both implementations alignedenv_typetoNoneinRuntime::with_platform()because target libc is unknown for platform overridesRUNTIME.envTypein Lua types and plugin docsRUNTIME.versionandRUNTIME.pluginDirPathentries todocs/tool-plugin-development.mdfor parityUsage in plugins
Design decisions
We intentionally duplicate musl/glibc detection in
crates/vfoxbecausevfoxis a separate crate boundary and sharingis_musl_system()would add unnecessary coupling. The logic is small, self-contained, and cross-referenced by sync notes in both locations to reduce drift.Test plan
env_type()return only valid values ("gnu","musl", ornil) on Linux andnilon non-LinuxRUNTIME.envTypeisnilwhen using platform override (Runtime::with_platform)cargo testpassesmise --cd crates/vfox run lint-fix)🤖 This PR description was generated with the assistance of Claude Opus 4.6.