xcaddy build failed with module certmagic error

This issue has been created since 2022-05-04.

cwd is an empty dir

➜  sf-caddy go version
go version go1.17.9 darwin/amd64

➜  sf-caddy xcaddy version
v0.3.0 h1:3LTHAhHb5YKKqTLLj8kdF9cfGMl4jHV4uRbtw7LBJ6k=

➜  sf-caddy xcaddy build
2022/05/04 17:55:38 [INFO] Temporary folder: /Users/a/sf-caddy/buildenv_2022-05-04-1755.820910291
2022/05/04 17:55:38 [INFO] Writing main module: /Users/a/sf-caddy/buildenv_2022-05-04-1755.820910291/main.go
package main

import (
        caddycmd "github.com/caddyserver/caddy/v2/cmd"

        // plug in Caddy modules here
        _ "github.com/caddyserver/caddy/v2/modules/standard"
)

func main() {
        caddycmd.Main()
}
2022/05/04 17:55:38 [INFO] Initializing Go module
2022/05/04 17:55:38 [INFO] exec (timeout=10s): /usr/local/go/bin/go mod init caddy
go: creating new go.mod: module caddy
go: to add module requirements and sums:
        go mod tidy
2022/05/04 17:55:38 [INFO] Pinning versions
2022/05/04 17:55:38 [INFO] exec (timeout=0s): /usr/local/go/bin/go get -d -v github.com/caddyserver/caddy/v2
go get: added github.com/caddyserver/caddy/v2 v2.5.0
2022/05/04 17:55:45 [INFO] exec (timeout=0s): /usr/local/go/bin/go get -d -v
2022/05/04 17:55:52 [INFO] Build environment ready
2022/05/04 17:55:52 [INFO] Building Caddy
2022/05/04 17:55:52 [INFO] exec (timeout=0s): /usr/local/go/bin/go mod tidy
2022/05/04 17:55:52 [INFO] exec (timeout=0s): /usr/local/go/bin/go build -o /Users/a/sf-caddy/caddy -ldflags -w -s -trimpath
# github.com/caddyserver/certmagic
../../../../go/pkg/mod/github.com/caddyserver/[email protected]/handshake.go:755:64: clientHello.Context undefined (type *tls.ClientHelloInfo has no field or method Context)
note: module requires Go 1.17
2022/05/04 17:55:53 [INFO] Cleaning up temporary folder: /Users/a/sf-caddy/buildenv_2022-05-04-1755.820910291
2022/05/04 17:55:53 [FATAL] exit status 2

i have multiple go versions installed, it looks like xcaddy not use go1.17?

mholt wrote this answer on 2022-05-04

I'm not sure, but it looks like the Go in your PATH is different from the Go in the PATH that xcaddy sees. You can force a specific Go version if you use the latest commit on xcaddy (not yet released): 7abc7f5

Granted, I don't think that should be necessary, but I'm not entirely sure what is going on there. Is /usr/local/go/bin/go not the right which go from when you ran go version?

toien wrote this answer on 2022-05-04

Thanks for fast reply!

i figure it out:

3 go versions installed on my osx, locations are:

/usr/local/go
{HOME}/sdk/go1.17.9
{HOME}/sdk/go1.18.1

and i use alias go=go1.17.9 to switch to go version. but it's wrong.

xcaddy will fork new process to finish build task and the go version it picks is from env $PATH.
shell aliases are not visible to subprocess.

2 solutions to solve:

  1. manipulate $PATH carefully
  2. use [email protected], it respect an env variable called XCADDY_WHICH_GO to do build task
mholt wrote this answer on 2022-05-04

Cool, thanks for the helpful follow up!

More Details About Repo
Owner Name caddyserver
Repo Name xcaddy
Full Name caddyserver/xcaddy
Language Go
Created Date 2020-03-21
Updated Date 2022-09-22
Star Count 381
Watcher Count 14
Fork Count 72
Issue Count 3

YOU MAY BE INTERESTED

Issue Title Created Date Comment Count Updated Date
Question about versions 2 2021-12-09 2022-09-09
How to change default toolbar (appearance)? 2 2018-07-17 2022-09-07
Match the Github design as much as possible 0 2019-12-14 2022-09-07
pageup pagedown keys not working 1 2018-09-15 2022-09-07
Bot stopped responding to commands 5 2021-09-29 2022-07-15
"Your request was denied by the provider due to insufficient permissions or quota limits" v1.0.21 4 2021-09-30 2022-08-15
Error since Sonarr was updated to version 3.0.6.1335 4 2021-09-30 2022-05-15
Error Registering Application commands since v1.0.19 2 2021-09-27 2022-07-09
Spring Boot 2.3.1: Failed to replace DataSource with an embedded database for tests. 5 2020-07-03 2022-07-22
Request: add studytonight.com to the filter 1 2022-06-12 2022-09-12
Request: add faqcode4u.com to the filter 1 2022-06-12 2022-09-12
heat equation with variable material properties 2 2022-04-11 2022-09-07
Plotting example for Nonlinear problems 0 2022-04-18 2022-09-07
Have Firmware Update section of Admin page optionally show nightly firmware instead of stable 3 2021-10-31 2022-08-19
how to make a custom current position button react-native-maps? 0 2022-04-25 2022-09-29
Cannot quit screen saver with mouse cursor moving 3 2017-09-21 2022-09-19
maven/maven-publish plugins produce invalid POMs when including additional BOMs 10 2019-06-26 2022-09-12
Large Cluster doesn't work 1 2021-10-19 2022-09-19
Scala.js Com failed: Error: connect ECONNREFUSED ::1:50550 1 2021-11-04 2022-09-18
Using wezterm to ssh stuck at `Authenticating...` 5 2022-01-20 2022-08-15
Some bug in `transforms.RandCropByPosNegLabeld` caused by `spatial_size` 3 2022-05-11 2022-08-20
TypeError: t.charCodeAt is not a function doc.addimage() 2 2021-12-15 2022-09-18
System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. Parameter name: to 21 2021-09-05 2022-09-12
Unattended installation 18 2022-03-30 2022-09-08
Unable to Connect GitHub Organization to Jira Site 25 2022-01-04 2022-07-13
Question: Is differentiation w.r.t graph supported? 5 2021-03-15 2022-09-12
Accessing via IPv6 address results in socket server connect timeout 3 2021-09-10 2022-09-22
backup plugins and other firefox configurations 1 2022-03-25 2022-09-12
orchestrator vitess errors trying for graceful failover using UI 1 2022-03-28 2022-09-14
what's difference between pod-kill and container-kill 2 2022-06-13 2022-09-18
No such file or directory 1 2022-06-17 2022-09-20
server: Tenant pods fan out to cancel SQL sessions 2 2021-11-17 2022-08-14
RetrieveURL 5 2021-05-10 2021-12-27
[bitnami/kube-prometheus] Incorrect label used by service selector 4 2021-11-10 2022-09-18
make lkm fails on alpine:3.15 (kernel 5.10) 8 2021-12-28 2022-09-08
Unable to execute rtsig during build 4 2021-12-26 2022-09-18
Update super_res.cpp 0 2021-10-11 2022-03-09
Add markdown support to project description 0 2021-09-02 2022-08-17
Better options checking 1 2020-12-27 2022-09-17
How to account for padded inputs in LEAF? 0 2022-03-27 2022-08-21
@azure/arm-reservations client.quota.beginUpdateAndWait() provisioning state failed 5 2022-06-27 2022-09-29
Options/Ideas for fixed TP/SL (take profit/stoploss) ratio at trade-entry 9 2022-09-14 2022-09-19
FileUtil.del("");会删掉classes文件夹 3 2021-08-30 2022-01-21
Workspace extensions can't access attached devices 8 2022-09-12 2022-09-28
Fails to build when archiving 8 2021-01-29 2022-08-17
extending non extension points and configuration 8 2019-12-17 2022-09-25
Receiving unauthenticated after successful login and receiving cookies 34 2020-03-04 2022-09-19
Punctuation errors on https://kubernetes.io/zh-cn/docs/reference/kubernetes-api/cluster-resources 4 2022-09-08 2022-09-19
Punctuation errors on https://kubernetes.io/zh-cn/docs/reference/kubernetes-api/cluster-resources 2 2022-09-08 2022-09-19
I have java TCP server running separately 2 2019-01-22 2022-09-28