Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Makefile在Windows上失败:语法错误;(“意外_Windows_Makefile_Path_Environment Variables - Fatal编程技术网

Makefile在Windows上失败:语法错误;(“意外

Makefile在Windows上失败:语法错误;(“意外,windows,makefile,path,environment-variables,Windows,Makefile,Path,Environment Variables,我有一个用于go项目的Makefile,该项目有一个生成protobuf源的步骤。最小的可复制示例是(假设安装了所有必需的依赖项,并且正确定位了proto文件): 您可以在此处查看完整版本: 它在Linux和CI管道上正常工作,但在WSL下的Windows上失败,错误为: 语法错误:“(”意外 失败的行是$(PROTOC)--go\u out=plugins=grpc:$(out)--go\u opt=path=source\u relative*.proto Windows似乎在PATHenv

我有一个用于go项目的
Makefile
,该项目有一个生成protobuf源的步骤。最小的可复制示例是(假设安装了所有必需的依赖项,并且正确定位了proto文件):

您可以在此处查看完整版本:

它在Linux和CI管道上正常工作,但在WSL下的Windows上失败,错误为:

语法错误:“(”意外

失败的行是
$(PROTOC)--go\u out=plugins=grpc:$(out)--go\u opt=path=source\u relative*.proto

Windows似乎在
PATH
env变量中有一些大括号,
make--debug
将其显示为:

env PATH=/home/username/go/bin:/home/username/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/usr/games:/usr/local/games:/mnt/c/程序文件(x86)/VMware/VMware Player/bin/:/mnt/c/Ruby25-x64/bin:/mnt/c/WINDOWS:/mnt/c/WINDOWS/system32:/mnt/c/WINDOWS/system32/Wbem:/mnt/c/WINDOWS/system32/windowspowshell/v1.0:/mnt/c/WINDOWS/system32:/mnt/c/WINDOWS/system32/Wbem:/mnt/c/WINDOWS/system32/windowspowshell/v1.0:/mnt/c/WINDOWS/system32/windowspowshell/v1.0:/mnt/c/WINDOWS/System32/OpenSSH/:/mnt/c/程序文件(x86)/英伟达公司/PhysX/Common:/mnt/c/Program Files/NVIDIA公司/NVIDIA-NvDLISR:/mnt/c/Go/bin:/mnt/c/Program Files/Git/cmd:/mnt/c/Program Files/CMake/bin:/mnt/c/WINDOWS/system32:/mnt/c/WINDOWS/system32/Wbem:/mnt/c/WINDOWS/system32/windowspowshell/v1.0/:/mnt/c/WINDOWS/system32/ssh/:/t/c/Program Files/Docker/Docker/resources/bin:/mnt/c/ProgramData/DockerDesktop/version bin:/mnt/c/Ruby26-x64/bin:/mnt/c/Users/username/AppData/Local/Microsoft/WindowsApps:/mnt/c/Program Files/JetBrains/IntelliJ IDEA 2020.2.1/bin:/mnt/c/Users/go/c/Program Files/JetBrains/GoLand 2020.2/bin:/mnt/c/Program/JetBrains/RubyMine2020.2.1/bin:/snap/bin:/home/username/go/bin:/home/username/.local/bin protoc--go\u out=plugins=grpc:/mnt/c/Users/username/GitHub/degitx/proto/go/degitxpb--go\u opt=path=source\u relative*.proto

注意
:/mnt/c/程序文件(x86)/*
路径条目


如何在Windows上正确运行此脚本以避免此错误?也许我需要以某种方式转义环境变量?

在POSIX Shell中,您需要应用引号,如下所示:

PROTOC := env PATH="$(GOPATH)/bin:${PATH}" protoc
PROTOC := env PATH="$(GOPATH)/bin:${PATH}" protoc