/bin/sh:1:1:gvm:找不到 [英] /bin/sh: 1: gvm: not found

查看:94
本文介绍了/bin/sh:1:1:gvm:找不到的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个Dockerfile,该文件安装所有可运行Go的组件,以安装 GVM(Go版本管理),并安装特定的Go版本.

I'm attempting to create a Dockerfile that installs all the components to run Go, to install GVM (Go Version Management), and to install specific Go Versions.

当我尝试使用以下方法构建容器时:

When I try building the container with:

docker build -t ##### .

我收到此错误:

/bin/sh:1:gvm:找不到

/bin/sh: 1: gvm: not found

命令'/bin/sh -c gvm install go1.4 -B'返回非零代码:127

The command '/bin/sh -c gvm install go1.4 -B' returned a non-zero code: 127

安装在这里:

/root/.gvm/scripts/env/gvm
/root/.gvm/scripts/gvm
/root/.gvm/bin/gvm

我尝试过的事情:

它显然能够安装GVM,但无法使用它.为什么?我以为也许我需要刷新 .bashrc .bash_profile ...,但这没有用,因为它们不存在.

What I tried:

It's clearly able to install GVM but unable to use it. Why? I thought maybe I needed to refresh the .bashrc or the .bash_profile ... but that didn't work, since they don't exist.

FROM #####/#####

#Installing Golang dependencies
RUN apt-get -y install curl git mercurial make binutils bison gcc build-essential

#Installing Golang

RUN ["/bin/bash", "-c", "bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer)"]
#gvm does not exist here... why?
RUN gvm install go1.4 -B
RUN gvm use go1.4

问题:

为什么似乎未安装GVM?如何消除错误?

Question:

Why does GVM not seem to be installed? How do I get rid of the error?

推荐答案

您的shell是/bin/sh ,但是 gvm 将其初始化放在〜/.bashrc ,并期望/bin/bash .

Your shell is /bin/sh, but gvm puts its initialization in ~/.bashrc, and expects /bin/bash.

您需要获取 gvm 初始化脚本以从非交互式bash shell运行命令:

You need to source the gvm initialization scripts to run the commands from a non-interactive bash shell:

RUN ["/bin/bash", "-c", ". /root/.gvm/scripts/gvm && gvm install go1.4 -B"]
RUN ["/bin/bash", "-c", ". /root/.gvm/scripts/gvm && gvm use go1.4"]

甚至更好的方法是将要执行的命令放在单个bash脚本中,然后将其添加到映像中.

Or even better might be to put the commands you want to execute in a single bash script and add that to the image.

#!/bin/bash
set -e

source /root/.gvm/scripts/gvm
gvm install go1.4
gvm use go1.4

这篇关于/bin/sh:1:1:gvm:找不到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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