xai-org/grok-build · warning

no home directory resolves; set GROK_COPY_FILE to enable the

Error message

no home directory resolves; set GROK_COPY_FILE to enable the copy backup file

What it means

write_copy_fallback writes clipboard content to a backup file on disk; the backup path comes from default_copy_fallback_path() (GROK_COPY_FILE or a home-derived default). When no home directory resolves and no override is set, it returns this NotFound error instead of guessing a location, telling the user how to enable the feature.

Source

Thrown at crates/codegen/xai-grok-pager-render/src/clipboard/mod.rs:603

        file.set_permissions(std::fs::Permissions::from_mode(0o600))?;
        file.write_all(text.as_bytes())
    }
    #[cfg(not(unix))]
    std::fs::write(path, text)
}

/// Write to the default fallback path ([`default_copy_fallback_path`]).
///
/// Errors with `NotFound` when no fallback path resolves (no home and no
/// `GROK_COPY_FILE`) — the backup file is skipped rather than written to a
/// predictable temp location.
///
/// On Unix a missing parent directory is created `0700` (a custom
/// `GROK_COPY_FILE` may point at a not-yet-created private directory;
/// `~/.grok` normally already exists).
pub fn write_copy_fallback(text: &str) -> std::io::Result<std::path::PathBuf> {
    let Some(path) = default_copy_fallback_path() else {
        return Err(std::io::Error::new(
            std::io::ErrorKind::NotFound,
            "no home directory resolves; set GROK_COPY_FILE to enable the copy backup file",
        ));
    };
    #[cfg(unix)]
    if let Some(parent) = path.parent()
        && !parent.as_os_str().is_empty()
    {
        use std::os::unix::fs::DirBuilderExt;
        std::fs::DirBuilder::new()
            .recursive(true)
            .mode(0o700)
            .create(parent)?;
    }
    write_text_to_copy_file(text, &path)
}

/// Compose a [`CopyDelivery`] from the clipboard toast and the (always

View on GitHub (pinned to bc7f02eddd)

Solutions

  1. Set GROK_COPY_FILE to an explicit absolute file path and retry
  2. Set HOME so the default fallback path (~/.grok/...) resolves
  3. Check clipboard availability; on systems with a working clipboard the fallback is not needed
  4. Create the parent directory (0700 on Unix) if GROK_COPY_FILE points at a new private dir

Example fix

// before
write_copy_fallback("text")?; // NotFound
// after
std::env::set_var("GROK_COPY_FILE", "/tmp/grok-copy-backup.txt");
let path = write_copy_fallback("text")?;
Defensive patterns

Strategy: fallback

Validate before calling

let usable = std::env::var_os("GROK_COPY_FILE").is_some()
    || std::env::var_os("HOME").map(|h| !h.is_empty()).unwrap_or(false);
if !usable { eprintln!("copy fallback disabled: set GROK_COPY_FILE"); }

Try / catch

match write_copy_fallback(text) {
    Err(e) if e.kind() == std::io::ErrorKind::NotFound => {
        eprintln!("copy backup unavailable; clipboard content not persisted");
    }
    other => other?,
}

Prevention

When it happens

Trigger: Calling write_copy_fallback (via copy_text_or_file) with GROK_COPY_FILE unset in an environment where the home directory cannot be resolved.

Common situations: Headless/CI/container environments lacking HOME; clipboard unavailable and the fallback path also unresolvable; typo'd GROK_COPY_FILE being empty so the default path is used.

Understand the failure class

Background: "environment variable is not set" and "Missing keys in environment" errors: what missing required env var messages mean and how to fix them — this error's family across 28 libraries.

Related errors


AI-assisted analysis of xai-org/grok-build@bc7f02eddd (2026-08-31). Data as JSON: /api/errors/8923ec58ee151a04. Report an issue: GitHub.