rtk-ai/rtk

Tee hint path with ~ shorthand breaks on paths with spaces (not shell-safe)

Open

#1644 opened on Apr 30, 2026

View on GitHub
 (2 comments) (0 reactions) (0 assignees)Rust (48,085 stars) (2,914 forks)batch import
bugeffort-smallgood first issue

Description

The path shown in rtk output is not directly usable when it contains spaces and uses ~.

Example: rtk curl -fsSL https://raw.githubusercontent.com/rtk-ai/rtk/refs/heads/master/install.sh

Output includes: [full output: ~/Library/Application Support/rtk/tee/1777536940_curl.log]

Trying to use this path directly fails: cat "~/Library/Application Support/rtk/tee/1777536940_curl.log"

or even: cat ~/Library/Application Support/rtk/tee/1777536940_curl.log

Both do not work as expected in bash/zsh.

However, using the absolute path works: cat "$HOME/Library/Application Support/rtk/tee/1777536940_curl.log"

This is problematic for LLM/agent-based workflows, where the path is often copied verbatim and reused in subsequent commands. Since ~ does not expand inside quotes and spaces are not escaped, the file cannot be accessed, which may lead the agent to incorrectly assume the file does not exist.

File to fix: src/core/tee.rs Location: Lines 172–183, function format_hint() Current code:

/// Format the hint line with ~ shorthand for home directory.                                                                                                                                                                           LSP                                     
     fn format_hint(path: &std::path::Path) -> String {                                                                                                                                                                                      LSPs will activate as files are read    
         let display = if let Some(home) = dirs::home_dir() {                                                                                                                                                                                                                        
             if let Ok(relative) = path.strip_prefix(&home) {                                                                                                                                                                                                                        
                 format!("~/{}", relative.display())                                                                                                                                                                                                                                 
             } else {                                                                                                                                                                                                                                                                
                 path.display().to_string()                                                                                                                                                                                                                                          
             }                                                                                                                                                                                                                                                                       
         } else {                                                                                                                                                                                                                                                                    
             path.display().to_string()                                                                                                                                                                                                                                              
         };                                                                                                                                                                                                                                                                          
                                                                                                                                                                                                                                                                                     
         format!("[full output: {}]", display)                                                                                                                                                                                                                                       
     }

Problem:
The format_hint() function formats tee file paths using ~ shorthand (e.g., ~/Library/Application Support/rtk/tee/123_curl.log). This causes issues in shell environments when:

  1. The path contains spaces (e.g., Application Support)
  2. The ~ does not expand inside double quotes in bash/zsh
  3. LLM/agent workflows copy the path verbatim, making it unusable directly

Proposed fix: Replace ~ shorthand with the absolute path using $HOME or full absolute path:

/// Format the hint line with absolute path (shell-safe, no ~ shorthand).
fn format_hint(path: &std::path::Path) -> String {
    let absolute_path = std::fs::canonicalize(path).unwrap_or_else(|_| path.to_path_buf());
    format!("[full output: {}]", absolute_path.display())
}

Benefits:

  • Absolute paths work reliably in all shell contexts
  • No ambiguity with ~ expansion rules
  • LLM/agents can copy-paste the path directly without modification
  • Fixes workflows where the hint path is reused in subsequent commands

Contributor guide