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

Environment variable does not pass-through by limactl shell #1419

Closed
ningziwen opened this issue Mar 15, 2023 · 1 comment
Closed

Environment variable does not pass-through by limactl shell #1419

ningziwen opened this issue Mar 15, 2023 · 1 comment

Comments

@ningziwen
Copy link
Contributor

ningziwen commented Mar 15, 2023

Description

$ cat printenv.sh 
echo $MY_VAR

# in host
$ MY_VAR=test ./printenv.sh
test

$ MY_VAR=test limactl shell default ./printenv.sh
# print nothing

# in guest
$ MY_VAR=test ./printenv.sh
test

So the environment variables are not passed through by limactl shell today. Is this the expected behaviour? If so, I'm interested to learn the reason of it.

I'm aware of Lima yaml has a field to pass env var but seems it can only be populated one time during booting, instead of passing-through in each limactl shell command.

Context of my use case.

@jandubois
Copy link
Member

limactl shell is just establishing an ssh connection. You would have to configure both the client and the server side to allow transfer of an environment variable.

An easier way is to just assign the variable explicitly in your remote command:

$ MY_VAR=test limactl shell default ./printenv.sh
# print nothing

$ MY_VAR=foo; limactl shell default printenv MY_VAR
$ MY_VAR=foo; limactl shell default MY_VAR=$MY_VAR printenv MY_VAR
foo

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

No branches or pull requests

2 participants