Windows 10 Makefile错误make(e = 2):系统找不到指定的文件 [英] Windows 10 Makefile error make (e=2): The system cannot find the file specified

查看:392
本文介绍了Windows 10 Makefile错误make(e = 2):系统找不到指定的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用:

  • Windows 10
  • 制作3.81
  • docker CE 18.09.2
  • docker撰写1.23.2
  • git bash 2.22.0.windows.1

我有一个 docker-compose.yaml 文件,如下所示:

 版本:"3.2"服务:地形:图片:hashicorp/terraform:0.11.14入口点:terraformworking_dir:/var/tmp/code/数量:-.:/var/tmp/code/:rw 

我的 Makefile 看起来像这样

  init:docker-compose运行terraform init 

当我从GitBash命令行运行此代码时:

 进行初始化 

我得到以下输出

docker-compose运行terraform init
process_begin:CreateProcess(NULL,docker-compose run terraform init,...)失败.
make(e = 2):系统找不到指定的文件.
make:*** [init]错误2

我看过


更新2

如果我修改了makefile,以便它明确指出 docker-compose.exe 文件的路径,那么它将起作用:

  init:"/c/Program Files/Docker/Docker/resources/bin/docker-compose.exe"运行terraform初始化 


更新3-解决方案

所以我完整的 Makefile 实际上是这样的:

 <代码>#!make包括.env出口.env:@ [-f ./.env-aws]&&来源./.env-aws;env |grep AWS |sed's/export//g;s/"//g'> .env初始化测试:docker-compose运行terraform init 

运行 make .env 创建一个 .env文件,其中包含一个PATH env var

 <代码> AWS_SECRET_ACCESS_KEY = ...AWS_SESSION_TOKEN = ...AWS_ACCESS_KEY_ID = ...PATH = ... 

从此文件中删除 PATH 行可以为我解决:)

解决方案

如果您的 Makefile 以某种方式操纵了 PATH 变量,从而使 docker-compose所在的目录不再安装在其上,这将导致这种症状.

要进行故障排除,请尝试添加

  echo"$$ PATH" 

(当然,由选项卡缩进)在失败的命令之前,然后检查结果是否确认您的期望.

(在这种情况下,美元符号必须加倍,以将文字的美元符号从 make 传递到基础外壳.)

I'm using:

  • Windows 10
  • make 3.81
  • docker CE 18.09.2
  • docker compose 1.23.2
  • git bash 2.22.0.windows.1

I've got a docker-compose.yaml file that looks like this:

version: '3.2'

services:
  terraform:
    image: hashicorp/terraform:0.11.14
    entrypoint: terraform
    working_dir: /var/tmp/code/
    volumes:
      - .:/var/tmp/code/:rw

And my Makefile looks like this

init:
    docker-compose run terraform init

When I run this from the GitBash command line:

make init

I get the following output

docker-compose run terraform init
process_begin: CreateProcess(NULL, docker-compose run terraform init, ...) failed.
make (e=2): The system cannot find the file specified.
make: *** [init] Error 2

I've seen other posts relating to this, and understand this to be a problem with the values on my PATH environment variable, however I'm not sure how to correct the problem.

Please let me know if I can provide any more information


Update

I have confirmed that:

  • docker-compose is installed
  • the docker-compose.exe exists on my PATH environment variable (see below)

My PATH environment variable:


Update 2

If I modify the makefile so it explicitly states the path to the docker-compose.exe file, it works:

init:
    "/c/Program Files/Docker/Docker/resources/bin/docker-compose.exe" run terraform init


Update 3 - Solution

So my full Makefile actually looked like this:

#!make
include .env
export

.env:
    @[ -f ./.env-aws ] && source ./.env-aws; env | grep AWS | sed 's/export //g; s/"//g' > .env

init-test:
    docker-compose run terraform init

Running make .env creates a .env file, which included a PATH env var

AWS_SECRET_ACCESS_KEY=...
AWS_SESSION_TOKEN=...
AWS_ACCESS_KEY_ID=...
PATH=...

Deleting the PATH line from this file solve it for me :)

解决方案

If your Makefile somehow manipulates the PATH variable so that the directory where docker-compose is installed is no longer on it, that would cause this kind of symptom.

For troubleshooting, try to add

echo "$$PATH"

(indented by a tab, of course) just before the failing command, and examine whether the result confirms your expectations.

(The dollar sign needs to be doubled in this context to pass a literal dollar sign from make to the underlying shell.)

这篇关于Windows 10 Makefile错误make(e = 2):系统找不到指定的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆