jdx/mise · error
history directory contains a NUL character
Error message
history directory contains a NUL character
What it means
On Windows, mise creates the history directory with restricted ACLs via Win32 APIs. Before calling the API it encodes the directory path as UTF-16; if the path contains an interior NUL character, the Win32 string would be silently truncated, so mise rejects it up front with this io-like error. Interior NULs indicate a corrupted or malformed path.
Solutions
- Check the environment variables that determine the data/state dir on Windows (`MISE_DATA_DIR`, `LOCALAPPDATA`) for corruption.
- Re-set the variable from a clean shell: `setx MISE_DATA_DIR "%LOCALAPPDATA%\mise"`.
- If the path is built programmatically, trim at the first NUL before passing it in.
- Restart the shell to pick up non-corrupted environment.
Example fix
// before: corrupted env value with embedded NUL set MISE_DATA_DIR=C:\Users\me\AppData\Local\mis<0x00>e // after setx MISE_DATA_DIR "%LOCALAPPDATA%\mise"
Defensive patterns
Strategy: validation
Validate before calling
// Windows: reject interior NULs before invoking Win32 APIs
let wide: Vec<u16> = dir.as_os_str().encode_wide().collect();
if wide.contains(&0) {
eprintln!("history directory path contains NUL; fix MISE_DATA_DIR/env");
} Type guard
fn path_is_nul_free(dir: &Path) -> bool {
use std::os::windows::ffi::OsStrExtW;
!dir.as_os_str().encode_wide().any(|c| c == 0)
} Try / catch
match result {
Err(e) if e.to_string().contains("NUL character") => {
// repair the environment variable that produced the path
}
other => other?,
} Prevention
- Keep MISE_DATA_DIR/LOCALAPPDATA set to plain, valid Windows paths.
- Trim at the first NUL when building paths from raw buffers.
- Re-open shells after changing environment variables.
When it happens
Trigger: Resolving the history directory path from configuration/environment on Windows when the computed path string contains an embedded NUL byte (e.g. corrupted env var or misbuilt path buffer).
Common situations: A MISE_DATA_DIR / XDG-style env var corrupted on Windows; a programmatic caller constructing a path from a buffer that retained a NUL terminator; registry or env corruption.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- invalid tool path : extended-length and device paths (\\?\…
- --localized-dir cannot be carried to Windows: is not…
- : target must be absolute or start with ~/
- : target must be absolute or start with ~/
- a process it started kept its output open
AI-assisted analysis of jdx/mise@533346cc37 (2026-09-17).
Data as JSON: /api/errors/624d94bd309ba8e6.
Report an issue: GitHub.
Appendix: source
Thrown at src/system/history/store.rs:144
let sddl: Vec<u16> = "D:P(A;OICI;FA;;;OW)\0".encode_utf16().collect();
let mut descriptor = std::ptr::null_mut();
// SAFETY: both pointers are valid for the call; Windows allocates the
// descriptor, released with LocalFree below on every path.
if unsafe {
ConvertStringSecurityDescriptorToSecurityDescriptorW(
sddl.as_ptr(),
1,
&mut descriptor,
std::ptr::null_mut(),
)
} == 0
{
return Err(std::io::Error::last_os_error().into());
}
let result = (|| -> Result<()> {
let mut path: Vec<u16> = dir.as_os_str().encode_wide().collect();
if path.contains(&0) {
eyre::bail!("history directory contains a NUL character");
}
path.push(0);
let attributes = SECURITY_ATTRIBUTES {
nLength: std::mem::size_of::<SECURITY_ATTRIBUTES>() as u32,
lpSecurityDescriptor: descriptor,
bInheritHandle: 0,
};
if !dir.is_dir()
// SAFETY: path is NUL-terminated and attributes/descriptor remain live.
&& unsafe { CreateDirectoryW(path.as_ptr(), &attributes) } == 0
&& !dir.is_dir()
{
return Err(std::io::Error::last_os_error().into());
}
// Also tighten an existing directory instead of trusting inherited ACLs.
// SAFETY: path and descriptor are valid until the call returns.
if unsafe {
SetFileSecurityW(View on GitHub (pinned to 533346cc37)