I have a windows environment variable for JAVA_HOME:
我有一个用于JAVA_HOME的Windows环境变量:
PS > Get-Item Env:JAVA_HOME
Name Value
---- -----
JAVA_HOME C:\Program Files\Eclipse Adoptium\jdk-11.0.15.10-hotspot
I have WSLENV to share env variables with WSL/Ubuntu:
我有WSLENV与WSL/Ubuntu共享环境变量:
$env:WSLENV="JAVA_HOME/p"
$env:WSLENV=“JAVA_HOME/p”
I've verified that the path is being changed properly
我已验证路径是否已正确更改
$ env | grep JAVA
JAVA_HOME=/mnt/c/Program Files/Eclipse Adoptium/jdk-11.0.15.10-hotspot
I can cd
to that directory, although with quotes around it.
我可以cd到那个目录,尽管它周围有引号。
Yet when I try run a gradle command, I get:
然而,当我尝试运行一个gradle命令时,我得到:
[gradle] ERROR: JAVA_HOME is set to an invalid directory: /mnt/c/Program Files/Eclipse Adoptium/jdk-11.0.15.10-hotspot
I'm sure it's the spaces, but I don't know how I'm supposed to force it to use quotes? Wouldn't WSLENV
and /p
have done that already?
我肯定是空格的问题,但我不知道我应该如何强迫它使用引号?难道WSLENV和/P不会已经这么做了吗?
Wrapping the env var in quotes in windows does nothing.
在Windows中将env变量用引号括起来并不起作用。
更多回答
Where are you running the gradle
command? In WSL distro's bash terminal?
你在哪里运行gradle命令?在WSL发行版的bash终端中?
@msrumon This is not a duplicate. This is about the variable failing to be passed when set using setx
. The other is about spaces not being encoded.
@msruon这不是复制品。这是关于使用SETX设置时无法传递的变量。另一个是关于没有编码的空格。
@msrumon In the wsl terminal, yes. Trying out bun
instead of yarn
and we have a java backend so we boot vite and gradle.
@msruon在WSL终端,是的。尝试用发髻而不是纱线,我们有一个Java后端,所以我们启动了Vite和Gradle。
Is gradle
expecting JAVA_HOME
in Windows path format, like C:\Program... ?
Gradle是否期望采用Windows路径格式的JAVA_HOME,如C:\Program...?
我是一名优秀的程序员,十分优秀!