【问题标题】:exec: "gcc": executable file not found in $PATHexec:“gcc”:在 $PATH 中找不到可执行文件
【发布时间】:2018-07-16 02:22:57
【问题描述】:

我遇到了一个 App Engine 项目将不再远程构建的问题(通过 gcloud app deploy)

这一切都是出乎意料的,在此结束时没有任何代码更改。不确定是否相关,但这是部署到 App Engine Flex 环境的 go 1.9 项目。

我不确定如何在与构建相同的环境中对其进行测试,因为错误来自 Google 的容器注册表

这是来自 Container Registry 控制台的日志

starting build "73f85b4d-7370-41bd-bbb2-bcf42fc38873" 

FETCHSOURCE 
Fetching storage object: gs://staging.[project].appspot.com/us.gcr.io/[project]/appengine/default.1ed3c690ead06f27aa651a30fab342611:latest#1531698266413753 
Copying gs://staging.[project].appspot.com/us.gcr.io/[project]/appengine/default.1ed3c690ead49f731806f27aa630fab342611:latest#1531698266413753... 
Operation completed over 1 objects/1.7 MiB.  

BUILD 
Starting Step #0 
Step #0: Pulling image: gcr.io/gcp-runtimes/go1-builder@sha256:c62ac3fbec31ddec70601d6c5b44d07063bcff6a823bdcf5e0bbaa9d3799d1db 
Step #0: sha256:c62ac3fbec31ddec70601d6c5b44d07063bcff6a823bdcf5e0bbaa9d3799d1db: Pulling from gcp-runtimes/go1-builder 
Step #0: Digest: sha256:c62ac3fbec31ddec70601d6c5b44d07063bcff6a823bdcf5e0bbaa9d3799d1db 
Step #0: Status: Downloaded newer image for gcr.io/gcp-runtimes/go1-builder@sha256:c62ac3fbec31ddec70601d6c5b44d07063bcff6a823bdcf5e0bbaa9d3799d1db 
Step #0: exec: "gcc": executable file not found in $PATH Finished 
Step #0 ERROR ERROR: build step 0 "gcr.io/gcp-runtimes/go1-builder@sha256:c62ac3fbec31ddec70601d6c5b44d07063bcff6a823bdcf5e0bbaa9d3799d1db" failed: exit status 2

【问题讨论】:

  • 你能在 ~/.bashrc 中检查你的 PATH 值吗?是否包含 /usr/bin?
  • 在我的 ~/.bashrc 还是远程的?我不知道如何访问 GCR 中正在运行的实例...
  • 远程的。
  • 是否可以在 GCR 中访问远程 shell?我想这确实是我的问题,如果我能进去看看,我也许能解决它。

标签: google-app-engine go google-container-registry


【解决方案1】:

看起来您正在使用容器 gcr.io/gcp-runtimes/go1-builder 作为构建步骤。查看source in GitHub,我发现自 6 月下旬以来没有任何更新。我在Dockerfile 中看到FROM 指令中的基本映像是gcr.io/google-appengine/debian9:latest,查看该映像显示没有安装gcc。我在Dockerfile 安装 gcc 中没有看到任何步骤,并且查看您的构建步骤图像确认它不存在:

~$ docker run --rm -t -i --entrypoint /bin/bash gcr.io/gcp-runtimes/go1-builder@sha256:c62ac3fbec31ddec70601d6c5b44d07063bcff6a823bdcf5e0bbaa9d3799d1db -- which gcc
Unable to find image 'gcr.io/gcp-runtimes/go1-builder@sha256:c62ac3fbec31ddec70601d6c5b44d07063bcff6a823bdcf5e0bbaa9d3799d1db' locally
sha256:c62ac3fbec31ddec70601d6c5b44d07063bcff6a823bdcf5e0bbaa9d3799d1db: Pulling from gcp-runtimes/go1-builder
e154cec6816f: Pull complete 
<pulls elided>
Digest: sha256:c62ac3fbec31ddec70601d6c5b44d07063bcff6a823bdcf5e0bbaa9d3799d1db
Status: Downloaded newer image for gcr.io/gcp-runtimes/go1-builder@sha256:c62ac3fbec31ddec70601d6c5b44d07063bcff6a823bdcf5e0bbaa9d3799d1db
~$ 

也许安装了基础debian9 映像的早期版本,您可以深入研究历史来查看。但看起来go1-builder 图像最近没有更改以删除 gcc。

如果您需要gcc,您始终可以将构建应用程序与部署应用程序分开。通过gcloud container builds submit 使用您自己的cloudbuild.yaml 构建,然后使用gcloud app deploy --image-url=... 部署构建的容器通过完全控制构建,您始终可以基于go-builder 映像并安装您需要的其他工具,例如顶部的gcc在使用 Docker 构建你的最终应用容器之前。

【讨论】:

  • 我想这是我最好的选择。谷歌的构建镜像甚至无法构建 App Engine SDK 似乎很奇怪! (当我将它作为一个 dep 删除时,它可以正常部署)
  • 我提交了这个问题:github.com/GoogleCloudPlatform/golang-docker/issues/141;如果这对您很重要,他们无疑会接受拉取请求...
  • 另一种选择是将app.yaml 更改为runtime: custom 并使用您喜欢的映像创建自己的Dockerfile 来构建应用程序:``` FROM golang:latest RUN mkdir /app ADD 。 /app/ WORKDIR /app RUN go build -o main 。 CMD ["/app/main"] ```
猜你喜欢
  • 2023-01-25
  • 2022-12-04
  • 1970-01-01
  • 2021-09-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多