prometheus / consul_exporter

Exporter for Consul metrics
Apache License 2.0
440 stars 167 forks source link

Compilation issue when building from master.zip but not when doing a git clone #35

Closed Djidiouf closed 7 years ago

Djidiouf commented 7 years ago

Hi, I went through an issue today about building consul_exporter from sources.

If I git clone the repo, it works perfectly well. However, If I download the master.zip available, it doesn't build the consul_expoter and fails. I did a diff between the 2 folders and beside having the .git folder in the consul_expoter which has been retrieved by doing a git clone, everything is similar.

Can you have a look at it?

Output:

[root@myserver prometheus]# pwd
/tmp/gopath/src/github.com/prometheus
[root@myserver prometheus]# echo $GOPATH
/tmp/gopath
[root@myserver prometheus]# wget https://github.com/prometheus/consul_exporter/archive/master.zip                                                                                   --2016-11-06 21:51:54--  https://github.com/prometheus/consul_exporter/archive/master.zip
Saving to: 'master.zip'

1,136,197    877K/s   in 1.3s

2016-11-06 21:51:57 (877 KB/s) - 'master.zip' saved [1136197]
[root@myserver prometheus]# unzip -qq master.zip
[root@myserver prometheus]# ls -al
total 1128
drwxr-xr-x. 4 root root    4096 Nov  6 21:52 .
drwxr-xr-x. 3 root root    4096 Nov  6 20:30 ..
drwxr-xr-x. 3 root root    4096 Sep  9 04:19 consul_exporter-master
-rw-r--r--. 1 root root 1136197 Nov  6 21:51 master.zip
drwxr-xr-x. 7 root root    4096 Nov  6 20:31 promu
[root@myserver prometheus]# mv consul_exporter-master/ consul_exporter
[root@myserver prometheus]# cd consul_exporter/
[root@myserver consul_exporter]# make
>> formatting code
>> building binaries
 >   .
go install github.com/prometheus/consul_exporter: build output "/tmp/gopath/src/github.com/prometheus/consul_exporter" already exists and is a directory
!! command failed: build -o /tmp/gopath/src/github.com/prometheus/consul_exporter -ldflags -X github.com/prometheus/consul_exporter/vendor/github.com/prometheus/common/version.Version=0.2.0 -X github.com/prometheus/consul_exporter/vendor/github.com/prometheus/common/version.Revision= -X github.com/prometheus/consul_exporter/vendor/github.com/prometheus/common/version.Branch= -X github.com/prometheus/consul_exporter/vendor/github.com/prometheus/common/version.BuildUser=root@myserver.sub.mydomain.com -X github.com/prometheus/consul_exporter/vendor/github.com/prometheus/common/version.BuildDate=20161107-02:52:56  -extldflags '-static' -a -tags netgo github.com/prometheus/consul_exporter: exit status 1
make: *** [build] Error 1

You can see in the above output:

>> building binaries
 >   .

Now, I exit this folder, remove it and issue a git clone.

[root@myserver consul_exporter]# cd ..
[root@myserver prometheus]# rm -rf consul_exporter/
[root@myserver prometheus]# git clone https://github.com/prometheus/consul_exporter.git
Initialized empty Git repository in /tmp/gopath/src/github.com/prometheus/consul_exporter/.git/
remote: Counting objects: 627, done.
remote: Total 627 (delta 0), reused 0 (delta 0), pack-reused 627
Receiving objects: 100% (627/627), 847.95 KiB | 293 KiB/s, done.
Resolving deltas: 100% (210/210), done.
[root@myserver prometheus]# cd consul_exporter/
[root@myserver consul_exporter]# make
>> formatting code
>> building binaries
 >   consul_exporter
>> running tests
ok      github.com/prometheus/consul_exporter   0.006s
[root@myserver consul_exporter]#
grobie commented 7 years ago

Thanks for reporting this @Djidiouf! I just checked and promu expects to be run with a git directory. I opened an issue to either support the git-less use case or at least return a better error message. Please follow that issue for further updates.