diff --git a/p/src/commands/run.rs b/p/src/commands/run.rs index 36f93f4..ff97a84 100644 --- a/p/src/commands/run.rs +++ b/p/src/commands/run.rs @@ -16,8 +16,16 @@ pub fn execute(worker_name: Option<&str>, cmd: Vec, no_sync: bool) -> Re let id = Uuid::new_v4().to_string(); let short_id = &id[..8]; let session = format!("p-{}", short_id); - let job_dir = format!("~/.p/jobs/{}", id); - let work_dir = format!("~/.p/workdirs/{}", id); + + // Resolve the remote home directory once using an absolute path so that + // every subsequent call — SSH, rsync, and scripts on the worker — all + // operate on the same concrete path with no ~ expansion ambiguity. + let remote_home = + ssh::run_capture(&worker, "echo $HOME").context("failed to connect to worker")?; + let remote_home = remote_home.trim(); + + let job_dir = format!("{}/.p/jobs/{}", remote_home, id); + let work_dir = format!("{}/.p/workdirs/{}", remote_home, id); let cmd_str = cmd.join(" "); let cwd = std::env::current_dir() .context("failed to get current directory")?