# Synthing uses 'git version' command even for a tarball

**URL:** https://forum.syncthing.net/t/synthing-uses-git-version-command-even-for-a-tarball/762
**Category:** Development
**Created:** [August 25, 2014, 12:38pm UTC](https://forum.syncthing.net/t/synthing-uses-git-version-command-even-for-a-tarball/762 "2014-08-25T12:38:12Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![nekorin](https://forum.syncthing.net/user_avatar/forum.syncthing.net/nekorin/32/141_2.png) [@nekorin](https://forum.syncthing.net/u/nekorin)
#### Post date: [August 25, 2014, 12:38pm UTC](https://forum.syncthing.net/t/synthing-uses-git-version-command-even-for-a-tarball/762/1 "2014-08-25T12:38:12Z")

</div>

I’m trying to write a ebuild for syncthing in Gentoo. The problem is the ebuild downloads a tarball (not a git master), and build.go tries to run ‘git version’ in version() function. Which fails, since there is no local git repository. And which fails the entire build.

---

<div class="post-metadata">

### Author: ![calmh](https://forum.syncthing.net/user_avatar/forum.syncthing.net/calmh/32/15311_2.png) [@calmh](https://forum.syncthing.net/u/calmh)
#### Post date: [August 25, 2014, 1:22pm UTC](https://forum.syncthing.net/t/synthing-uses-git-version-command-even-for-a-tarball/762/2 "2014-08-25T13:22:10Z")

</div>

Yes. Building from the git repo is the only “supported” way. That said, if you only use tarballs of official releases, you can easily build it yourself. The build process basically does the following.

Make sure GOPATH is set so that the source is checked out into `$GOPATH/src/github.com/syncthing/syncthing`.

Grab the godep dependency (there are more, but they are for test coverage and things like that you probably don’t need to care about):

```
go get -v github.com/tools/godep

```

If you’re building without internet access, just make sure to have a working godep binary in your PATH and the rest can be skipped.

Then build the binary, while stamping it with the variables figured out from git;

```
godep go build -ldflags "-w -X main.Version v0.9.8+9-gfaf519a \
  -X main.BuildStamp 1408971319 -X main.BuildUser jb \
  -X main.BuildHost jborg-mbp.local -X main.BuildEnv default" \
  -tags noupgrade ./cmd/syncthing

```

(split for clarity)

In reality the entire string `-w ... default` is **one** argument to `-ldflags`.

Set BuildVersion to whatever you downloaded (in that format, with initial `v`), BuildStamp to the current time in epoch seconds (real build uses time of last commit for reproducability, but whatever), BuildUser and BuildHost to sensible values, BuildEnv to `default` and off you go.

If the presence of godep is a dealbreaker you can trivially simulate it with just a manual tweak to GOPATH, so let me know in that case.

Edit: Added `-tags noupgrade` to disable the built in upgrading mechanism.

---

<div class="post-metadata">

### Author: ![nekorin](https://forum.syncthing.net/user_avatar/forum.syncthing.net/nekorin/32/141_2.png) [@nekorin](https://forum.syncthing.net/u/nekorin)
#### Post date: [August 25, 2014, 2:27pm UTC](https://forum.syncthing.net/t/synthing-uses-git-version-command-even-for-a-tarball/762/3 "2014-08-25T14:27:25Z")

</div>

Thanks a lot! -tags option does not work for me in the 0.9.8 version

---

<div class="post-metadata">

### Author: ![calmh](https://forum.syncthing.net/user_avatar/forum.syncthing.net/calmh/32/15311_2.png) [@calmh](https://forum.syncthing.net/u/calmh)
#### Post date: [August 25, 2014, 2:40pm UTC](https://forum.syncthing.net/t/synthing-uses-git-version-command-even-for-a-tarball/762/4 "2014-08-25T14:40:26Z")

</div>

It certainly does for me. Show me what happens?

---

<div class="post-metadata">

### Author: ![nekorin](https://forum.syncthing.net/user_avatar/forum.syncthing.net/nekorin/32/141_2.png) [@nekorin](https://forum.syncthing.net/u/nekorin)
#### Post date: [August 25, 2014, 3:21pm UTC](https://forum.syncthing.net/t/synthing-uses-git-version-command-even-for-a-tarball/762/5 "2014-08-25T15:21:42Z")

</div>

Sorry, I added that to the ldflags string instead of a new argument. Now works.

---

<div class="post-metadata">

### Author: ![system](https://forum-uploads.syncthingcdn.net/original/2X/0/0b50e0a202b22ae6a67190759e8c868805b8ed9f.png) [@system](https://forum.syncthing.net/u/system)
#### Post date: [May 12, 2017, 1:18pm UTC](https://forum.syncthing.net/t/synthing-uses-git-version-command-even-for-a-tarball/762/6 "2017-05-12T13:18:59Z")

</div>


