Building OpenCloud against a local Reva checkout
- #go
- #opencloud
- #reva
A Go workspace points an OpenCloud build at a sibling Reva tree without a replace line in go.mod and without touching vendor/.
OpenCloud vendors Reva. A normal make build compiles that copy, so edits in a sibling Reva tree never reach the binary. A Go workspace switches the build to the local module without a replace line in go.mod and without touching vendor/.
Layout
Lay the two repositories out as siblings:
src/
go.work
opencloud/
reva/
opencloud/go.mod requires github.com/opencloud-eu/reva/v2. The local Reva module must use that same path.
Workspace
Create the workspace from the parent directory:
cd src
go work init ./opencloud ./reva
go work init writes the toolchain version from go version into go.work. The file looks like this:
go 1.27.3
use (
./opencloud
./reva
)
Go walks up from the current directory and picks up that file. Check that the opencloud module resolves Reva to the sibling directory:
cd src/opencloud
go list -m -f '{{.Dir}}' github.com/opencloud-eu/reva/v2
The output has to be the absolute path of src/reva. A version such as v2.52.1 and no directory means the workspace is not in use and the build will keep compiling the vendored module.
Build
Build from the OpenCloud repository:
rm -f opencloud/bin/opencloud
make -C opencloud build
The binary is opencloud/bin/opencloud. The rm is required. That Makefile tracks *.go only inside opencloud/opencloud, so a change under src/reva still produces Nothing to be done for 'build' while the old binary is newer than those files.
Leave go.work uncommitted. It is a local development file.
Two flags that undo this
vendor/ makes Go default to -mod=vendor when no workspace is active. Vendoring ignores go.work. If go env GOWORK prints off, the parent file is not loaded. Point GOWORK at it for the build:
export GOWORK=$HOME/src/go.work
In workspace mode -mod may only be readonly or vendor. GOFLAGS=-mod=mod fails with:
go: -mod may only be set to readonly or vendor when in workspace mode, but it is set to "mod"
readonly is already the default and is what selects the local module. -mod=vendor is legal in workspace mode and selects the vendored tree again. If go env GOFLAGS contains either value, run unset GOFLAGS before go list and make.