dstack icon indicating copy to clipboard operation
dstack copied to clipboard

[Bug]: No run env vars in non-login SSH session

Open un-def opened this issue 4 weeks ago • 0 comments

Steps to reproduce

Apply the configuration:

# dev-environment.dstack.yml
type: dev-environment
name: dev-environment
ide: vscode
env:
  - RUN_VAR=1
  1. Log in and run command:

    $ ssh dev-environment
    root@a6e6bda7be8e:/# printenv SHELL CUDA_VERSION DSTACK_RUN_NAME RUN_VAR
    
  2. Run the same command via ssh:

    $ ssh dev-environment printenv SHELL CUDA_VERSION DSTACK_RUN_NAME RUN_VAR
    

Variable sources:

  • SHELL — set by sshd
  • CUDA_VERSION — from the image
  • DSTACK_RUN_NAME — injected by dstack
  • RUN_VAR — declared in the run configuration

Actual behaviour

  1. /bin/bash
    12.8.1
    dev-environment
    1
    
  2. /bin/bash
    

Expected behaviour

The output in the second case should be the same.

dstack version

a49d34c43913f0962ed8b5b7da6f28dea621186f

Server logs


Additional information

dstack exports vars in /dstack/profile, which is sourced in /etc/profile, which, in turn, only sourced by login shells, while ssh destination command [argument ...] executes command in a non-login shell.

un-def avatar Dec 04 '25 12:12 un-def