buchgr / bazel-remote

A remote cache for Bazel
https://bazel.build
Apache License 2.0
595 stars 154 forks source link

cannot `go get github.com/buchgr/bazel-remote@v2.4.0` #635

Closed dragonsinth closed 1 year ago

dragonsinth commented 1 year ago

Hi friends, great library! We're finding it very useful. However, we're sorta stuck on v1.3.3 because the directory layout doesn't follow the normal Go module version guidelines. Trying to pull a recent version fails:

> go get github.com/buchgr/bazel-remote@v2.4.0
go: github.com/buchgr/bazel-remote@v2.4.0: invalid version: module contains a go.mod file, so module path must match major version ("github.com/buchgr/bazel-remote/v2")

Thanks! Scott

mostynb commented 1 year ago

Hi, bazel-remote isn't intended to be used as a library (though I have heard of people trying), and the "official" way to build it is with bazel, which "go get" doesn't support. Do you actually need to consume parts of bazel-remote as a library, or are you just trying to get a binary?

dragonsinth commented 1 year ago

I'm actually trying to use it as a library, since it has a pretty nice clean interface. I'm bundling it into a service that also includes other sorts of network-accessible caches and proxies. (And in my case, it's easier to deploy as part of internal application framework, where I get things like logging and metrics and monitoring for free.)

mostynb commented 1 year ago

I'll need to do some research on go modules then (perhaps next week). I wonder if moving all the code except main.go into a v2/ directory with its own go.mod file would work...

dragonsinth commented 1 year ago

It might be possible to just change the module declaration? Example I found: https://github.com/ClickHouse/clickhouse-go/blob/main/go.mod -- this package is imported as github.com/ClickHouse/clickhouse-go/v2 and works just fine.

Assuming there's no need to maintain 1.x releases going forward, this might be easiest.

iangudger commented 1 year ago

I'm running into this same issue. I want to build my own version of bazel-remote with a custom cache implementation.

mostynb commented 1 year ago

Sorry it took me a while to get around to this. Would something like this work? https://github.com/buchgr/bazel-remote/pull/646

(Note that I provide no guarantees on the stability or backwards compatibility of these packages.)

I would love to hear more about how you're using bazel-remote (or parts of it). Just curious- maybe it's something worth upstreaming?

dragonsinth commented 1 year ago

Seems like that would work https://github.com/buchgr/bazel-remote/pull/646#issuecomment-1455252112

I'm putting together a caching proxy for a self-hosted CI that can handle multiple languages/tools, such as bazel, npm, go, python, etc. We sort of have our own "service rails" that make it easy to deploy self-built Go services.

mostynb commented 1 year ago

I made a 2.4.1 release with this change- does it work for you now?

dragonsinth commented 1 year ago

Seems to work, thank you!!

> go get github.com/buchgr/bazel-remote/v2
go: downloading github.com/buchgr/bazel-remote/v2 v2.4.1