/bin/sh: 1: gvm: not found
Asked Answered
W

1

2

Problem:

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.

Error:

When I try building the container with:

docker build -t ##### .

I get this error:

/bin/sh: 1: gvm: not found

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

Installed here:

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

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.

Dockerfile:

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

Question:

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

Washhouse answered 3/1, 2017 at 16:0 Comment(2)
Where is it installing gvm? Is it in your path? Why do you need gvm in a container, which is usually purpose-built for an application?Flameout
@Flameout using it for developing reasons. Figured would be easier to handle go updates, check update for where GVM is installed. GVM usually gets added to the PATH automatically, no? It's not in the PATH, I'll add it later and see if that works.Washhouse
F
4

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

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"]

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
Flameout answered 3/1, 2017 at 16:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.