TheThingsArchive / ttn

The Things Network Stack V2
https://www.thethingsnetwork.org
MIT License
461 stars 276 forks source link

Failed to build basic dev configuration #735

Closed amateusz closed 6 years ago

amateusz commented 6 years ago

I might be terribly mistaken as it seems to be too severe to be true, but the regular build fails for me.

This is a bug report for the backend.

What do you want to do?

I want to setup development environment and compile ttn's source (not any fork) as guided in Development section

What steps did you take?

I followed those instructions. Fulfilled all the deps.

What went wrong or what is missing?

The step make test fails, and (I assume) consecutively make build fails as well. Logs:

make test

pi@raspberrypi:~/src/github.com/TheThingsNetwork/ttn $ make test
go test ./amqp ./api/pool ./cmd ./core/band ./core/broker ./core/component ./core/discovery ./core/discovery/announcement ./core/handler ./core/handler/application ./core/handler/cayennelpp ./core/handler/device ./core/handler/functions ./core/networkserver ./core/networkserver/device ./core/proxy ./core/router ./core/router/gateway ./core/storage ./core/types ./mqtt ./ttnctl/util ./utils/fcnt ./utils/otaa ./utils/parse ./utils/random ./utils/security ./utils/toa
ok      github.com/TheThingsNetwork/ttn/amqp    1.213s
ok      github.com/TheThingsNetwork/ttn/api/pool        2.095s
ok      github.com/TheThingsNetwork/ttn/cmd     1.202s
ok      github.com/TheThingsNetwork/ttn/core/band       0.043s
ok      github.com/TheThingsNetwork/ttn/core/broker     4.434s
ok      github.com/TheThingsNetwork/ttn/core/component  6.409s
ok      github.com/TheThingsNetwork/ttn/core/discovery  1.002s
ok      github.com/TheThingsNetwork/ttn/core/discovery/announcement     1.102s
VALUE [72 105]
--- FAIL: TestConvertFieldsDownCayenneLPP (0.01s)
        doc.go:64:
                /home/pi/src/github.com/TheThingsNetwork/ttn/core/handler/convert_fields_test.go:307
                Expected: '[]uint8{7, 249, 232}'
                Actual:   '[]uint8{7, 0, 0}'
                (Should resemble)!
--- FAIL: TestDryDownlinkFieldsCayenneLPP (0.01s)
        doc.go:64:
                /home/pi/src/github.com/TheThingsNetwork/ttn/core/handler/dry_run_test.go:227
                Expected: '[]uint8{5, 249, 232}'
                Actual:   '[]uint8{5, 0, 0}'
                (Should resemble)!
FAIL
FAIL    github.com/TheThingsNetwork/ttn/core/handler    3.867s
ok      github.com/TheThingsNetwork/ttn/core/handler/application        0.171s
--- FAIL: TestEncode (0.00s)
        doc.go:64:
                /home/pi/src/github.com/TheThingsNetwork/ttn/core/handler/cayennelpp/encoder_test.go:25
                Expected: '[]uint8{2, 236, 69}'
                Actual:   '[]uint8{2, 0, 0}'
                (Should resemble)!
FAIL
FAIL    github.com/TheThingsNetwork/ttn/core/handler/cayennelpp 0.089s
ok      github.com/TheThingsNetwork/ttn/core/handler/device     0.140s
ok      github.com/TheThingsNetwork/ttn/core/handler/functions  0.061s
ok      github.com/TheThingsNetwork/ttn/core/networkserver      1.077s
ok      github.com/TheThingsNetwork/ttn/core/networkserver/device       0.296s
ok      github.com/TheThingsNetwork/ttn/core/proxy      0.053s
ok      github.com/TheThingsNetwork/ttn/core/router     1.256s
--- FAIL: TestScheduleRealtime (0.00s)
        doc.go:64:
                /home/pi/src/github.com/TheThingsNetwork/ttn/core/router/gateway/schedule_test.go:33
                Expected '1.535047286401191e+18' to almost equal '1.5350429914339456e+18' (but it didn't)!
FAIL
FAIL    github.com/TheThingsNetwork/ttn/core/router/gateway     1.285s
ok      github.com/TheThingsNetwork/ttn/core/storage    0.192s
ok      github.com/TheThingsNetwork/ttn/core/types      0.078s
ok      github.com/TheThingsNetwork/ttn/mqtt    6.468s
ok      github.com/TheThingsNetwork/ttn/ttnctl/util     0.779s
ok      github.com/TheThingsNetwork/ttn/utils/fcnt      0.017s
ok      github.com/TheThingsNetwork/ttn/utils/otaa      0.114s
ok      github.com/TheThingsNetwork/ttn/utils/parse     0.062s
ok      github.com/TheThingsNetwork/ttn/utils/random    0.054s
ok      github.com/TheThingsNetwork/ttn/utils/security  5.106s
ok      github.com/TheThingsNetwork/ttn/utils/toa       0.062s
Makefile:84: recipe for target 'test' failed
make: *** [test] Error 1

make build

pi@raspberrypi:~/src/github.com/TheThingsNetwork/ttn $ make build
CGO_ENABLED=0 GOOS=linux GOARCH=arm go build -a -installsuffix cgo -ldflags "-w -X main.version=v2.9.4-dev -X main.gitBranch=`git rev-parse --abbrev-ref HEAD 2>/dev/null` -X main.gitCommit=`git rev-parse HEAD 2>/dev/null` -X main.buildDate=`date -u +%Y-%m-%dT%H:%M:%SZ`" -tags "dev" -o "release/ttn-linux-arm" ./main.go
CGO_ENABLED=0 GOOS=linux GOARCH=arm go build -a -installsuffix cgo -ldflags "-w -X main.version=v2.9.4-dev -X main.gitBranch=`git rev-parse --abbrev-ref HEAD 2>/dev/null` -X main.gitCommit=`git rev-parse HEAD 2>/dev/null` -X main.buildDate=`date -u +%Y-%m-%dT%H:%M:%SZ`" -tags "dev" -o "release/ttnctl-linux-arm" ./ttnctl/main.go
# github.com/TheThingsNetwork/ttn/ttnctl/cmd
ttnctl/cmd/clients_list.go:42: undefined: sort.Slice
Makefile:148: recipe for target 'release/ttnctl-linux-arm' failed
make: *** [release/ttnctl-linux-arm] Error 2

undefined: sort.Slice ?? I'm seeing golang for the first time..

What kind of OS/Browser/Gateway are you using? Which version?

I'm compiling for release/ttnctl-linux-arm Raspberry Pi model 3.

What are the IDs and EUIs of your Device/Gateway? (if applicable)

What do your configuration files look like?

What do your log files look like?

Can you fix this yourself and submit a pull request?

htdvisser commented 6 years ago

I suspect that you're on an old version of Go. The current version is 1.10.3 and the oldest version that is known to work with TTN is 1.8.

Could you please comment with the output of go version and go env?

Note that you can (and probably should) set up your development environment on a regular machine, and cross-compile for the Raspberry Pi. Running make build with something like GOOS=linux GOARCH=arm GOARM=7 or GOOS=linux GOARCH=arm64 (not 100% sure) should give you binaries that will run on the RPi.

amateusz commented 6 years ago

I was indeed on 1.7.4 installed from apt. Now as I used this gist I'm on 1.10.1 and it builds with no errors. I haven't taken the plunge to setup cross-compile env... Oh, is it as simple as adding some flags to make build on regular machine? By the way, these flags seem to be CGO_ENABLED=0 GOOS=linux GOARCH=arm as per my build here on RPi 3.