wtf: Error on Build?

Bug Report

Summary

Ran Go Get and ran make and ran into error

What is the current behaviour?

When running make, errors out with  ╍╍  g s g s    wtf  make install │ which wtf | xargs rm || true go install -ldflags="-X main.version=v0.0.4_`git rev-parse --abbrev-ref HEAD` -X main.date=2018-06-02T15:28:42+0100" which wtf make: *** [install] Error 1

Go version is go version go1.10.2 darwin/amd64

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 2
  • Comments: 34 (18 by maintainers)

Most upvoted comments

@International @askl56

Well, looks good but this change is not required. First we take a look if the gopath is set.

echo $GOPATH

If this return empty we have to set the go path first before installing.

export GOPATH=$HOME/go
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin

Installation

Installing wtf appears simple. You can follow the instructions there. After you set your go path we will clone this repository using go.

Note we are not using git clone here because this could lead to unexpected things like in this case.

Step: 1

cloning: go get -u github.com/senorprogrammer/wtf

Step: 2

changing directories: cd $GOPATH/src/github.com/senorprogrammer/wtf

Step: 3

installing make install

Step: 4

testing make run

Misc

If this problem still occur, please paste the output of go run wtf.go. In the most cases, the dependencies are missing.

Regards,

deltax

Edit: 1

Looks like that go doesn’t support that you have your code outside, read here.

This commit on master now checks for the GOPATH. If not set, attempts to set it.

Got an error as well. Seems it’s just a PATH issue as mentioned above. Make sure you have GOPATH in your PATH, and $GOPATH/bin.

First trying to install it:

$ go get -u github.com/wtfutil/wtf

$ cd go/src/github.com/wtfutil/wtf

$ make install
go clean
go install -ldflags="-s -w -X main.version=0.4.0-32-g48cb7b -X main.date=2019-01-13T19:24:59+0100"
which wtf
which: no wtf in (/opt/google-cloud-sdk/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/var/lib/snapd/snap/bin)
make: *** [Makefile:12: install] Error 1

As you can see there’s no wtf in my path. Checking the bin dir of my GOPATH shows that the binary exists.

$ cd ~/go/bin

$ ls -lah | grep wtf
-rwxr-xr-x 1 anders users  20M Jan 13 19:25 wtf

Permissions are correct and everything, so it seems it just a matter of adding it to the PATH. I use zsh so I update my PATH in ~/.zshrc.

export PATH="${PATH}:${HOME}/go/bin"

Restart terminal and it works.

Maybe add a simple check in the Makefile to verify that they have the GOPATH and binary folder setup before they install?

I finally have a Linux install to test this against and yeah, make install is pretty broken there. Unless you’re using zsh it really doesn’t like the shell bits of the install command (amongst other things). Will sort that out.

Not really sure what shell is supposed to be, and it seems that the Makefile is relying on the presence of some environment variables ( maybe zsh or some other shell extensions ). The following change works on my machine:

BRANCH := `git rev-parse --abbrev-ref HEAD`

.PHONY: dependencies install run

dependencies:
	go get -v ./...

install:
	which wtf | xargs rm || true
	go install -ldflags="-X main.version=$(git describe --always --abbrev=6)_$(git rev-parse --abbrev-ref HEAD) -X main.date=$(date +%FT%T%z)"
	which wtf

run:
	wtf