首页 > 解决方案 > 在 /home 下无法运行 .exe 但在 /mnt/c 下可以

问题描述

.exe在适用于 Linux 的 Windows 子系统中,当我在文件结构下时,我似乎能够运行文件,但在文件结构/mnt/c/...下时却不行/home/...。有没有办法.exe在我的密码下访问文件/home/...

$ pwd
/mnt/c
$ "/c/Program Files/R/R-4.0.2/bin/Rscript.exe" -e "print('hello')"
[1] "hello"
$ cd ~
# pwd
/home/mpettis
$ "/c/Program Files/R/R-4.0.2/bin/Rscript.exe" -e "print('hello')"
(nothing run or returned)

如果这是安装文件系统的任何线索,这是我的df输出:

$ df
Filesystem     1K-blocks      Used Available Use% Mounted on
rootfs         498799612 133929648 364869964  27% /
none           498799612 133929648 364869964  27% /dev
none           498799612 133929648 364869964  27% /run
none           498799612 133929648 364869964  27% /run/lock
none           498799612 133929648 364869964  27% /run/shm
none           498799612 133929648 364869964  27% /run/user
cgroup         498799612 133929648 364869964  27% /sys/fs/cgroup
C:             498799612 133929648 364869964  27% /c

标签: windows-subsystem-for-linux

解决方案


在其中创建/etc/wsl.conf并定义以下内容:

[automount]
enabled = true
options = "metadata,uid=1000,gid=1000,umask=0022,fmask=11,case=off"
mountFsTab = false
crossDistro = true

[network]
generateHosts = true
generateResolvConf = true

[filesystem]
umask = 0022

[interop]
enabled = true
appendWindowsPath = true

显式启用它为 true 的 interop 部分可能会解决此问题。请务必记住,如果您运行 WSL2 并且还使用 systemd hack,您的 Windows 互操作将中断,并且无法执行任何 exe 文件。


推荐阅读