Score:1

How do I set environment variables so that they execute when calling WSL from PowerShell?

co flag

First let me clarify the question. I'm not asking how to sync environment variables. What I am asking is how to set JAVA_HOME so that when I call wsl echo `$JAVA_HOME from powershell it writes out the specified bash environment variable.

So far, I've tried setting the value in /etc/environments. I've also tried setting the value in ~/.bashrc and ~/.bash_profile. The command I'm executing in both of those startup scripts is: export JAVA_HOME="/path/to/java"

The WSL OS is Ubuntu 20.04.3

What am I missing. Surely there must be a way to set environment variables. If I execute something like wsl echo `$PATH, I get a value.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.