New build process? #3166

Closed
opened 2025-11-02 05:02:32 -06:00 by GiteaMirror · 3 comments
Owner

Originally created by @coolaj86 on GitHub (Apr 10, 2019).

It's been a minute since I've contributed to gitea and it seems like the build instructions have changed from what's in the README and I'd like to know what they are:

How I Installed

Installing gcc (for sqlite):

apt install -y build-essential

Installing Go:

wget https://dl.google.com/go/go1.12.3.linux-amd64.tar.gz
tar xvf go1.12.3.linux-amd64.tar.gz
mkdir -p ~/local
mv ./go ~/local/
export PATH="/root/local/go/bin:$PATH"

Build gitea:

git clone https://github.com/go-gitea/gitea.git
pushd gitea/
TAGS="bindata" make generate all

The Error I Got:

can't load package: package code.gitea.io/gitea: cannot find package "code.gitea.io/gitea" in any of:
        /root/local/go/src/code.gitea.io/gitea (from $GOROOT)
        /root/go/src/code.gitea.io/gitea (from $GOPATH)

I'm not clear on why it's not finding code.gitea.io/gitea when I'm in the right directory where the go.mod is.

Originally created by @coolaj86 on GitHub (Apr 10, 2019). It's been a minute since I've contributed to gitea and it seems like the build instructions have changed from what's in the README and I'd like to know what they are: # How I Installed **Installing gcc** (for sqlite): ```bash apt install -y build-essential ``` **Installing Go**: ```bash wget https://dl.google.com/go/go1.12.3.linux-amd64.tar.gz tar xvf go1.12.3.linux-amd64.tar.gz mkdir -p ~/local mv ./go ~/local/ export PATH="/root/local/go/bin:$PATH" ``` **Build gitea**: ```bash git clone https://github.com/go-gitea/gitea.git pushd gitea/ TAGS="bindata" make generate all ``` # The Error I Got: ``` can't load package: package code.gitea.io/gitea: cannot find package "code.gitea.io/gitea" in any of: /root/local/go/src/code.gitea.io/gitea (from $GOROOT) /root/go/src/code.gitea.io/gitea (from $GOPATH) ``` I'm not clear on why it's not finding `code.gitea.io/gitea` when I'm in the right directory where the `go.mod` is.
GiteaMirror added the type/proposal label 2025-11-02 05:02:32 -06:00
Author
Owner

@coolaj86 commented on GitHub (Apr 10, 2019):

Simplest

Here are the simplest possible instructions that will work with any Go setup, no special configuration:

go generate -mod vendor ./...
go build -mod vendor -tags 'bindata'

Recommended

Here's the recommended build (which requires a C compiler):

go generate -mod vendor ./...
go build -mod vendor -tags 'bindata sqlite sqlite_unlock_notify'

Complete

And here's how to do it with main.Version and main.Tags properly set:

GITEA_VERSION=$(git describe --tags --always | sed 's/-/+/' | sed 's/^v//')
TAGS='bindata sqlite sqlite_unlock_notify'
LDFLAGS="-X 'main.Version=$GITEA_VERSION' -X 'main.Tags=$TAGS'"
    
go generate -mod vendor ./...
go build -mod vendor -tags "$TAGS" -ldflags "-s -w $LDFLAGS"

After a Go Generate PR

That looks a bit gnarly, but with a PR to go generate, it can actually be reduced to:

TAGS='bindata sqlite sqlite_unlock_notify'
go generate -mod vendor -tags "$TAGS" ./...
go build -mod vendor -tags "$TAGS" -ldflags "-s -w"

Non-Production, but complete

Of course, if you're going for just fewer characters and not the production build process, you can reduce that down further to just this:

TAGS='bindata sqlite sqlite_unlock_notify'
go generate -tags "$TAGS" ./...
go build -tags "$TAGS"
@coolaj86 commented on GitHub (Apr 10, 2019): # Simplest Here are the simplest possible instructions that will work with any Go setup, no special configuration: ```bash go generate -mod vendor ./... go build -mod vendor -tags 'bindata' ``` # Recommended Here's the recommended build (which requires a C compiler): ```bash go generate -mod vendor ./... go build -mod vendor -tags 'bindata sqlite sqlite_unlock_notify' ``` # Complete And here's how to do it with `main.Version` and `main.Tags` properly set: ```bash GITEA_VERSION=$(git describe --tags --always | sed 's/-/+/' | sed 's/^v//') TAGS='bindata sqlite sqlite_unlock_notify' LDFLAGS="-X 'main.Version=$GITEA_VERSION' -X 'main.Tags=$TAGS'" go generate -mod vendor ./... go build -mod vendor -tags "$TAGS" -ldflags "-s -w $LDFLAGS" ``` # After a Go Generate PR That looks a bit gnarly, but with a PR to `go generate`, it can actually be reduced to: ```bash TAGS='bindata sqlite sqlite_unlock_notify' go generate -mod vendor -tags "$TAGS" ./... go build -mod vendor -tags "$TAGS" -ldflags "-s -w" ``` # Non-Production, but complete Of course, if you're going for just fewer characters and not the production build process, you can reduce that down further to just this: ```bash TAGS='bindata sqlite sqlite_unlock_notify' go generate -tags "$TAGS" ./... go build -tags "$TAGS" ```
Author
Owner

@coolaj86 commented on GitHub (Apr 10, 2019):

Solved by https://github.com/go-gitea/gitea/pull/6567

@coolaj86 commented on GitHub (Apr 10, 2019): Solved by https://github.com/go-gitea/gitea/pull/6567
Author
Owner

@zeripath commented on GitHub (Apr 13, 2019):

https://docs.gitea.io/en-us/install-from-source/

@zeripath commented on GitHub (Apr 13, 2019): https://docs.gitea.io/en-us/install-from-source/
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#3166