首页 > 解决方案 > F# Fake 在 WSL2 中运行可解析宿主 Windows 中的程序路径,而不是 Linux

问题描述

环境

问题

我正在关注SAFE Stack 快速入门,但 FAKE 构建脚本失败:

$ dotnet fake build --target run

但 FAKE 找不到npm二进制文件:

Target          Duration
------          --------
Clean           00:00:00.0053439
InstallClient   00:00:00.1517122   (npm was not found in path. Please install it and make sure it's available from your path. See https://safe-stack.github.io/docs/quickstart/#install-pre-requisites for more info)

问题

通过插入调试消息,FAKE 脚本似乎build.fsx从宿主 Windows 解析 PATH,而不是从 WSL2 Linux 环境:

DEBUG: Some "C:\Program Files\Git\usr\bin\ls.EXE"

脚本中的示例:

// My Debug
printfn "DEBUG: %A" (ProcessUtils.tryFindFileOnPath "ls")
// The actual script
let npmPath =
    match ProcessUtils.tryFindFileOnPath "npm" with
    | Some path -> path
    | None ->
        "npm was not found in path. Please install it and make sure it's available from your path. "
        + "See https://safe-stack.github.io/docs/quickstart/#install-pre-requisites for more info"
        |> failwith

=> 这是一个错误还是我在这里遗漏了什么?(我对 .Net 和 F# 很陌生)

标签: f#f#-fakewsl-2

解决方案


好的,从我的角度来看,这很愚蠢:在以前的混合 Windows + WSL 设置中,我添加到bash_aliases带有alias dotnet=dotnet.exe. 我应该在安装 Linux .Net Core 软件包时删除它

结案


推荐阅读