go build with -no-upgrade fails

I’m trying to build latest git clone via

go run build.go -no-upgrade

and it fails with

# github.com/syncthing/syncthing/cmd/stupgrades
cmd/stupgrades/main.go:24:10: undefined: upgrade.FetchLatestReleases
cmd/stupgrades/main.go:30:12: undefined: upgrade.SortByRelease
exit status 2
exit status 1

Am I missing something ?

cheers, Peter

You need to build syncthing package only if you want to use that option, not all packages. I think the build command takes additional parameters what to build, which I think you need to specify ./cmd/syncthing or syncthing

OK, I managed to build it by first running

go run build.go

and then an additional

go run build.go -no-upgrade build syncthing

which left me with 2 syncthing binaries, one in cmd/ and one in the current dir.

$ bin/syncthing --upgrade-check
11:09:53 WARNING: Checking for upgrade: no upgrade available (current "v1.7.0-rc.1+3-gb6b6caea" >= latest "v1.6.1").
$ ./syncthing --upgrade-check
11:10:01 WARNING: Checking for upgrade: upgrade unsupported

So, this worked for me, but maybe there’s a better solution.

Anyways, the docs should be fixed: https://docs.syncthing.net/dev/building.html?highlight=-no-upgrade

The binary in the current dir is from the second command, the one in cmd/ from the first. The second command would have worked without first calling the former one. Go has a distinction between build, putting the binary in the current dir, and install, putting the binaries into a common installation dir (which the build.go script defines as cmd/ I think).

What needs fixing? A note mentioning that -no-upgrade is not compatible with the default (all) target would be helpful - feel free to add it.

I think the docs are correct. The examples work, and it says -no-upgrade influences the build (create binary in current dir), zip and tar (create the named archive types) subcommands. It also says giving no subcommand is equivalent to install, which is something else and creates binaries in bin/.

We might simplify though. The distinction between build and install comes from earlier Go versions which had more of a difference between those two modes than the current Go releases do. It’s not really necessary today.

1 Like