Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot build: can't find reason for requirement on github.com/google/pprof #11

Closed
anaisbetts opened this issue Mar 5, 2023 · 11 comments

Comments

@anaisbetts
Copy link

I wanted to give this a try because it looks extremely Cool, but I'm having trouble building it, it seems that the Go package manager is getting Confused:

go: downloading github.com/jackc/pgproto3/v2 v2.3.1
go: downloading github.com/go-logfmt/logfmt v0.5.1
go: downloading github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d
go: downloading github.com/AndreasBriese/bbloom v0.0.0-20190825152654-46b345b51c96
go: downloading github.com/golang/snappy v0.0.4
go: downloading github.com/golang/glog v1.0.0
go: downloading github.com/jackc/chunkreader/v2 v2.0.1
go: downloading github.com/jackc/pgpassfile v1.0.0
go: downloading github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b
go: downloading github.com/shurcooL/sanitized_anchor_name v1.0.0
panic: internal error: can't find reason for requirement on github.com/google/pprof@v0.0.0-20210407192527-94a9f03dee38

goroutine 1 [running]:
cmd/go/internal/modget.(*resolver).updateBuildList.func1({{0xc000b26618, 0x17}, {0xc0000306f0, 0x22}})
        /usr/lib/go/src/cmd/go/internal/modget/get.go:1760 +0xd4
cmd/go/internal/modget.(*resolver).updateBuildList(0xc000156000, {0xb3bd58, 0xc00002c0e0}, {0x0, 0x0, 0x0})
        /usr/lib/go/src/cmd/go/internal/modget/get.go:1765 +0x54c
cmd/go/internal/modget.(*resolver).applyUpgrades(0xc000156000, {0xb3bd58, 0xc00002c0e0}, {0x0?, 0x0, 0xc0000a5d70?})
        /usr/lib/go/src/cmd/go/internal/modget/get.go:1312 +0x465
cmd/go/internal/modget.runGet({0xb3bd58, 0xc00002c0e0}, 0xc000028618?, {0xc000024220, 0x2, 0x2})
        /usr/lib/go/src/cmd/go/internal/modget/get.go:351 +0x458
main.invoke(0xe51280, {0xc0000241f0, 0x5, 0x5})
        /usr/lib/go/src/cmd/go/main.go:225 +0x3d9
main.main()
        /usr/lib/go/src/cmd/go/main.go:179 +0x7ce
2023/03/05 14:38:04 [FATAL] exit status 2
@mholt
Copy link
Contributor

mholt commented Mar 5, 2023

It is super cool!

But alas, you have hit a known bug in the go command.

We've figured out, that with Caddy, specifying the version of v2.6.3 or higher (v2.6.4 is current) fixes it. The plugin can do that in its go.mod or you can manually create a replacement in your own go.mod.

@Zaba
Copy link

Zaba commented Mar 10, 2023

I've had to update both the Caddy and the Tailscale dependencies to get this to build and to work (somehow with the old Tailscale version the node would seemingly be connected to the tailnet but no traffic would actually go through).

--- a/go.mod
+++ b/go.mod
@@ -3,8 +3,8 @@ module github.com/tailscale/caddy-tailscale
 go 1.19
 
 require (
-       github.com/caddyserver/caddy/v2 v2.5.3-0.20220831215348-67098e5cbd68
-       tailscale.com v1.1.1-0.20220902232949-3344c3b89bd1
+       github.com/caddyserver/caddy/v2 v2.6.4
+       tailscale.com v1.36.2
 )
 
 require (

(+ many more changes after running go mod tidy)

I've also had to patch the module slightly because the newer version of tsnet verifies the network parameter in Listen. I just hardcoded "tcp", not sure if that's strictly correct but it seemed to work.

--- a/module.go
+++ b/module.go
@@ -46,7 +46,7 @@ func getPlainListener(_ context.Context, network string, addr string, _ net.List
                return nil, err
        }
 
-       return s.Listen(network, ":"+port)
+       return s.Listen("tcp", ":"+port)
 }
 
 func getTLSListener(_ context.Context, network string, addr string, _ net.ListenConfig) (any, error) {
@@ -60,7 +60,7 @@ func getTLSListener(_ context.Context, network string, addr string, _ net.Listen
                return nil, err
        }
 
-       ln, err := s.Listen(network, ":"+port)
+       ln, err := s.Listen("tcp", ":"+port)
        if err != nil {
                return nil, err
        }

Edit: And just for posterity, here's the terrible, no good, very hacky workaround for tailscale/tailscale#6973 that I've added to this module to make it work across restarts of Caddy on Windows:

--- a/module.go
+++ b/module.go
@@ -20,6 +20,10 @@ import (
 	"tailscale.com/client/tailscale"
 	"tailscale.com/tsnet"
 	"tailscale.com/util/strs"
+
+	"path/filepath"
+	"tailscale.com/ipn"
+	"tailscale.com/ipn/store"
 )
 
 var (
@@ -121,6 +125,22 @@ func getServer(_, addr string) (*tsnet.Server, error) {
 			if err := os.MkdirAll(s.Dir, 0700); err != nil {
 				return nil, err
 			}
+
+			stateFile := filepath.Join(s.Dir, "tailscaled.state")
+			log.Printf("attempting to fix state file %s", stateFile)
+			tmpStore, err := store.New(log.Printf, stateFile)
+			if err != nil {
+				log.Printf("could not open store: %v", err)
+			} else {
+				value, err := tmpStore.ReadState(ipn.CurrentProfileStateKey)
+				if err == nil {
+					err := tmpStore.WriteState(ipn.ServerModeStartKey, value)
+					if err != nil {
+						log.Printf("could not fix state file: %v", err)
+					}
+				}
+			}
+
 		}
 
 		servers[host] = s

@ericswpark
Copy link

@Zaba if you have the time, could you please submit your code as a pull request? Currently running into the same issue.

@gbraad
Copy link

gbraad commented Apr 1, 2023

I applied the changes as originally I also ran into compiling issues with the old dependencies (ref: #9). I have a repo, that works with gitpod at: https://gitpod.io/#https://github.com/spotsnel/caddy-tailscale

the changes in module.go are needed, otherwise it fails to start with:
Error: loading initial config: loading new config: http app module: start: listening on tailscale/caddy:80: unsupported network type

Besides this, it works... although it might be that the templates didn't render correctly?

Any suggestions to remove the hard-coded tcp part? Although, this might well be obsolete from an older version of tailscale. @Zaba Have you tried running with bind tailscale+tls/caddy ?

@Zaba
Copy link

Zaba commented Apr 1, 2023

The change to hardcode "tcp" was necessary because the newer versions of tsnet validate the network argument to Listen (see https://github.com/tailscale/tailscale/blob/main/tsnet/tsnet.go#L982), so just passing through "tailscale" or "tailscale+tls" as the original code does no longer works.

Technically it doesn't have to be "tcp" but could also be an empty string or any of the other accepted options, but I have no idea whether and how this value affects anything inside of tsnet and how this does or does not interact with UDP/HTTP3 usage for example, nor do I have time to investigate this in detail, hence I cannot put any of this into a pull request in good faith.

@kernelb00t
Copy link

kernelb00t commented Jun 15, 2023

Hey ! Running into same issue here !
Here are some logs, if they are some kind of useful :

2023/06/15 21:00:24 [INFO] exec (timeout=-2562047h47m16.854775808s): /usr/local/go/bin/go get -d -v
2023/06/15 21:00:28 [INFO] Build environment ready
2023/06/15 21:00:28 [INFO] Building Caddy
2023/06/15 21:00:28 [INFO] exec (timeout=-2562047h47m16.854775808s): /usr/local/go/bin/go mod tidy -e
go: finding module for package golang.org/x/crypto/internal/subtle
caddy imports
        github.com/tailscale/caddy-tailscale imports
        tailscale.com/tsnet imports
        tailscale.com/ipn/ipnlocal imports
        github.com/tailscale/golang-x-crypto/ssh imports
        github.com/tailscale/golang-x-crypto/chacha20 imports
        github.com/tailscale/golang-x-crypto/internal/subtle tested by
        github.com/tailscale/golang-x-crypto/internal/subtle.test imports
        golang.org/x/crypto/internal/subtle: module golang.org/x/crypto@latest found (v0.10.0), but does not contain package golang.org/x/crypto/internal/subtle
2023/06/15 21:00:28 [INFO] exec (timeout=-2562047h47m16.854775808s): /usr/local/go/bin/go build -o /home/pi/temp/caddy -ldflags -w -s -trimpath
package caddy
        imports github.com/tailscale/caddy-tailscale
        imports tailscale.com/tsnet
        imports tailscale.com/ipn/ipnlocal
        imports tailscale.com/net/dns
        imports tailscale.com/net/tstun
        imports gvisor.dev/gvisor/pkg/tcpip
        imports gvisor.dev/gvisor/pkg/atomicbitops
        imports gvisor.dev/gvisor/pkg/cpuid
        imports gvisor.dev/gvisor/pkg/state
        imports gvisor.dev/gvisor/pkg/state/wire
        imports gvisor.dev/gvisor/pkg/gohacks: build constraints exclude all Go files in /home/pi/go/pkg/mod/gvisor.dev/gvisor@v0.0.0-20220801230058-850e42eb4444/pkg/gohacks
2023/06/15 21:00:29 [INFO] Cleaning up temporary folder: /tmp/buildenv_2023-06-15-2100.2723375457
2023/06/15 21:00:29 [FATAL] exit status 1
pi@john:~/temp $ go version
go version go1.20.5 linux/arm64

I'm on Raspberry Pi 4GB, running latest Go and xcaddy, Raspberry Pi OS based on Debian 11.
Caddy itself is building correctly, but not with this module.

@kernelb00t
Copy link

kernelb00t commented Jun 15, 2023

Oh, I didn't realised it wasn't the same issue
But it did happen the first time I tried to build

EDIT : OP's issue happened for me the first 2 times I tried to build, nothing changed between retrys (no updates, etc...). Then it showed me the error of my previous comment.

@vamega
Copy link

vamega commented Jul 14, 2023

@fr3nchalp4a I ran into that issue as well.
Manually patched the value in go.mod to use the value from tailscale/tailscale#6168

I'm still running into some issues, but am getting closer.

caddy imports
        github.com/tailscale/caddy-tailscale imports
        tailscale.com/util/strs: cannot find module providing package tailscale.com/util/strs
caddy imports
        github.com/caddyserver/caddy/v2/modules/standard imports
        github.com/caddyserver/caddy/v2/modules/caddypki/acmeserver imports
        github.com/smallstep/certificates/acme imports
        github.com/smallstep/go-attestation/attest imports
        github.com/google/go-tpm/tpm2/credactivation: cannot find module providing package github.com/google/go-tpm/tpm2/credactivation

The first error is due to this commit.

I'm going to need to learn some go to tackle this, it seems like mashing commands I don't understand isn't going to get me to power through the dependency hell that my chosen set of plugins seems to create.

xcaddy does panic with the exception that started this thread.

> xcaddy version
v0.3.4

> xcaddy build --with github.com/tailscale/caddy-tailscale --with github.com/caddyserver/caddy/v2/modules/standard --with github.com/caddy-dns/cloudflare --with github.com/lum8rjack/caddy-maxmind-geolocation

[ Snipped ]go: downloading github.com/jackc/pgproto3/v2 v2.3.1
go: downloading github.com/golang/glog v1.0.0
panic: internal error: can't find reason for requirement on github.com/google/pprof@v0.0.0-20210407192527-94a9f03dee38

goroutine 1 [running]:
cmd/go/internal/modget.(*resolver).updateBuildList.func1({{0xc001605e90, 0x17}, {0xc000034660, 0x22}})
        /nix/store/i3ab37h47xmd0zh75708gj57hah7v7f4-go-1.20.5/share/go/src/cmd/go/internal/modget/get.go:1760 +0xd4
cmd/go/internal/modget.(*resolver).updateBuildList(0xc00013e000, {0xb45e38, 0xc000032240}, {0x0, 0x0, 0x0})
        /nix/store/i3ab37h47xmd0zh75708gj57hah7v7f4-go-1.20.5/share/go/src/cmd/go/internal/modget/get.go:1765 +0x54c
cmd/go/internal/modget.(*resolver).applyUpgrades(0xc00013e000, {0xb45e38, 0xc000032240}, {0x0?, 0x0, 0xc0000bfd70?})
        /nix/store/i3ab37h47xmd0zh75708gj57hah7v7f4-go-1.20.5/share/go/src/cmd/go/internal/modget/get.go:1312 +0x465
cmd/go/internal/modget.runGet({0xb45e38, 0xc000032240}, 0xc00002e660?, {0xc000024220, 0x2, 0x2})
        /nix/store/i3ab37h47xmd0zh75708gj57hah7v7f4-go-1.20.5/share/go/src/cmd/go/internal/modget/get.go:351 +0x458
main.invoke(0xe67340, {0xc0000241f0, 0x5, 0x5})
        /nix/store/i3ab37h47xmd0zh75708gj57hah7v7f4-go-1.20.5/share/go/src/cmd/go/main.go:225 +0x3d9
main.main()
        /nix/store/i3ab37h47xmd0zh75708gj57hah7v7f4-go-1.20.5/share/go/src/cmd/go/main.go:179 +0x7ce
2023/07/14 19:53:48 [FATAL] exit status 2

@vamega
Copy link

vamega commented Jul 15, 2023

I was able to get this to build by replacing the the tailscale-caddy module with the contents on #13.

 go mod edit --replace github.com/tailscale/caddy-tailscale=github.com/trea/caddy-tailscale@network-listener-changes

@willnorris
Copy link
Member

#13 has been merged, which I believe addresses most (or all?) of the issues mentioned here. This bumps us to caddy v2.6.4, which @mholt noted fixes the original problem discussed. #13 also includes some other changes which I believe takes care of needing to hardcard a network value of "tcp" as well as the tailscale.com/util/strs issue.

If any of these problems remain after updating to the latest version of caddy-tailscale, feel free to reply here or open a new issue.

@mholt
Copy link
Contributor

mholt commented Jul 17, 2023

Yayyyy thanks Will!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants