Dep: install.sh script doesn't support multiple directories in GOPATH

Created on 11 Mar 2018  路  5Comments  路  Source: golang/dep

On my Mac, install.sh script doesn't support multiple directories in GOPATH. It gives an error saying the directory is not existed when more than one path are set in GOPATH.

I expect the install.sh takes the first directory in GOPATH and install it in [FIRST GOPATH DIR]/bin.

Most helpful comment

Thank you gerep.
Actually, a more easier workaround is temporarily change the GOPATH to the one I want to install it to, than change it back afterward.
I'm not looking for a workaround. I want it to be fixed permanently which will give others an easier life.

All 5 comments

As a workaround, you can edit the install.sh at line 73 to:

GOBIN="${GOPATH%:*}/bin"

This will return the first path in your GOPATH and will be used to install dep.

If you are on Windows, the path separator is ; so you will need to change the bash string operator.

Thank you gerep.
Actually, a more easier workaround is temporarily change the GOPATH to the one I want to install it to, than change it back afterward.
I'm not looking for a workaround. I want it to be fixed permanently which will give others an easier life.

Try following command to install on Unix-like system:

curl https://raw.githubusercontent.com/golang/dep/master/install.sh | GOBIN="${GOPATH%:*}/bin" sh

@rousan: I agree with @uynap . The workaround is easy, but is an unnecessary stumbling point for what is supposed to be a hands-off installation method. The convention of defaulting to the first path is established in other go tools.

While installing dep using install.sh script, there is an environment variable named INSTALL_DIRECTORY to set your custom installation directory, So for the platforms having multiple directories in GOPATH should do some manual efforts as follows:

$ curl https://raw.githubusercontent.com/golang/dep/master/install.sh | GOBIN="${GOPATH%%:*}/bin" sh

or edit the install.sh file like what @gerep said.

or set INSTALL_DIRECTORY environment variable like this:

$ INSTALL_DIRECTORY="${GOPATH%%:*}/bin" curl https://raw.githubusercontent.com/golang/dep/master/install.sh

So, I don't think this is a smart default. So need to be fixed this one,
And I'm working on this issue and will send PR ASAP.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kardianos picture kardianos  路  43Comments

sdboyer picture sdboyer  路  26Comments

pbennett picture pbennett  路  30Comments

fabulous-gopher picture fabulous-gopher  路  27Comments

cpapidas picture cpapidas  路  50Comments