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

Unable to push env vars to WSL on startup #4613

Closed
JohnnyElvis opened this issue Oct 23, 2019 · 5 comments
Closed

Unable to push env vars to WSL on startup #4613

JohnnyElvis opened this issue Oct 23, 2019 · 5 comments
Labels

Comments

@JohnnyElvis
Copy link

Unfortunately I am unable to pass environment variables to WLS on application startup. It is although possible to add a command while executing WLS, unfortunately the session/process is stopped after the command was executed and no further user interaction is possible.

What I am trying to achieve is following:

k8s cli utilities are not very usable while using Windows. Since mutliple k8s clusters needs to be managed, I'd like to spin up multiple WLS (Ubuntu 1804) instances on demand and push env vars (e.g: export KUBECONFIG=/some_path/config.yml ) and a simple command (e.g: cd /some_path) on startup for the specific session on local workstation

Let me know, if there is a way to do this with current release, otherwise it would be great to implement login/startup scripts which can be passed to WSL

@Biswa96
Copy link

Biswa96 commented Oct 23, 2019

You can set WSLENV variable in Windows and LxssManager will automatically pass that into WSL environment. See this blog post for further details Share Environment Vars between WSL and Windows.

@JohnnyElvis
Copy link
Author

Thx for you comment, but this solution does not work. It is simply too static. Not sure how to select between 50+ values for a single variable on demand. Also not all user have permissions to change system variables. Having build tools (go) on a workstation will probably never pass an audit

@Biswa96
Copy link

Biswa96 commented Oct 23, 2019

Also not all user have permissions to change system variables.

The set WSLENV=xyz command can be used in a batch file before executing wsl.exe.

@JohnnyElvis
Copy link
Author

Ok...it took me a while to understand the documentation... I ended up with this one:

powershell -command "$Env:KUBECONFIG = '/some_path_lin/config.yml'; $Env:WSLENV = 'KUBECONFIG'; cd some_path_win; wsl"

thx for your help!

@craigloewen-msft
Copy link
Member

@JohnnyElvis it looks like your issue is resolved, so I'll close this issue for bookkeeping on our side, please feel free to reopen it or add more comments if you still have questions. Thanks for filing! :)

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

No branches or pull requests

4 participants