Skip to content

fix: env blocks not setting variable for SSH script and terminal blocks#377

Merged
BinaryMuse merged 2 commits intomainfrom
mkt/env-over-ssh
Feb 3, 2026
Merged

fix: env blocks not setting variable for SSH script and terminal blocks#377
BinaryMuse merged 2 commits intomainfrom
mkt/env-over-ssh

Conversation

@BinaryMuse
Copy link
Member

Fixes #376

#319 made it so we only set $ATUIN_OUTPUT_VARS if it's included in the script text; since environment variables are often read by sub-programs, I opted not to go that route here.

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Jan 30, 2026

Greptile Overview

Greptile Summary

Fixes environment variable propagation to SSH sessions for script and terminal blocks. Previously, env blocks only set variables locally but not for remote SSH execution.

The fix introduces build_env_exports() that generates properly escaped export statements for all environment variables, using POSIX single-quote escaping to handle special characters safely.

  • Script blocks: prepends env exports to code sent over SSH
  • Terminal blocks: writes env exports to SSH PTY after opening
  • Local execution: unchanged, continues using native env mechanisms

Important Files Changed

Filename Overview
crates/atuin-desktop-runtime/src/ssh/ssh_env.rs Added new module with shell escaping logic for env vars, includes comprehensive tests
crates/atuin-desktop-runtime/src/blocks/script.rs Now exports env vars for SSH script execution using new build_env_exports function
crates/atuin-desktop-runtime/src/blocks/terminal.rs Now writes env exports to SSH PTY before setting ATUIN_OUTPUT_VARS

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@BinaryMuse BinaryMuse requested a review from ellie January 30, 2026 19:33
@BinaryMuse BinaryMuse enabled auto-merge (squash) January 30, 2026 19:37
@BinaryMuse BinaryMuse merged commit c5e287e into main Feb 3, 2026
10 checks passed
@BinaryMuse BinaryMuse deleted the mkt/env-over-ssh branch February 3, 2026 19:07
@github-actions github-actions bot locked and limited conversation to collaborators Feb 3, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] env blocks don't set environment variables for script or terminal blocks running over SSH

2 participants