Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(record): propagate env of vhs process to record terminal #572

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tr3mor
Copy link
Contributor

@tr3mor tr3mor commented Jan 16, 2025

Hello,
This pr broke env variables propagation to terminal spawned by record command.
From Env description

	// If Env is nil, the new process uses the current process's
	// environment.

Appending VHS_RECORD makes it not nil, so it resets env. This pr fixes #554.

For example with the latest released vhs

root# echo $HOME
/var/root
root# vhs record
sh-3.2# echo $HOME
sh-3.2# env
VHS_RECORD=true
PWD=/private/var/root
SHLVL=1
_=/usr/bin/env

The simplest solution is to get env of the main process and then append VHS_RECORD
The same example with the build from this PR

root# echo $HOME
/var/root
root# ./vhs record
sh-3.2# echo $HOME
/var/root

sh-3.2# env
TERM=xterm-ghostty
SHELL=/bin/sh
LC_ALL=en_US.UTF-8
USER=root
SUDO_UID=503
SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.4WqxVicPZH/Listeners
__CF_USER_TEXT_ENCODING=0x0:0:0
PATH=/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Users/REDACTED/go/bin:/Users/REDACTED/.local/share/zinit/polaris/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/Applications/Ghostty.app/Contents/MacOS:/Users/REDACTED/Library/Application Support/JetBrains/Toolbox/scripts
MAIL=/var/mail/root
VHS_RECORD=true
PWD=/Users/REDACTED/personal/vhs
LANG=en_US.UTF-8
HOME=/var/root
SUDO_COMMAND=/bin/sh
SHLVL=2
LOGNAME=root
SUDO_GID=20
COLORTERM=truecol

Let me know if you see a better solution.

@tr3mor tr3mor requested a review from a team as a code owner January 16, 2025 16:08
@tr3mor tr3mor requested review from csandeep and removed request for a team January 16, 2025 16:08
@tr3mor
Copy link
Contributor Author

tr3mor commented Jan 16, 2025

It looks like lint issues are unrelated to my change, so I don't think I need to fix them.

@bashbunni
Copy link
Member

@tr3mor agreed, will take a look at this. Thanks so much for spotting this issue and coming up with a solution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

vhs record unsets $HOME
2 participants