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

xcaddy development mode fails if 'go.mod' includes 'replace' directive #68

Closed
simnalamburt opened this issue Aug 29, 2021 · 1 comment · Fixed by #69
Closed

xcaddy development mode fails if 'go.mod' includes 'replace' directive #68

simnalamburt opened this issue Aug 29, 2021 · 1 comment · Fixed by #69

Comments

@simnalamburt
Copy link
Contributor

simnalamburt commented Aug 29, 2021

How to reproduce this issue:

Clone https://github.com/simnalamburt/xcaddybug and try to build with xcaddy.

// main.go
package xcaddybug
import "example.com/stringutil"
import "github.com/caddyserver/caddy/v2"

func init() {
	caddy.RegisterModule(Example{})
}
type Example struct {}
func (Example) CaddyModule() caddy.ModuleInfo {
	return caddy.ModuleInfo{
		ID:  caddy.ModuleID(stringutil.Reverse("elpmaxe.oof")),
		New: func() caddy.Module { return new(Example) },
	}
}
// go.mod
module github.com/simnalamburt/xcaddybug
go 1.17
replace example.com v0.0.1 => golang.org/x/example v0.0.0-20210811190340-787a929d5a0d
require (
	example.com v0.0.1
	github.com/caddyserver/caddy/v2 v2.4.3
)

Error message:

2021/08/29 22:55:01 [INFO] Resolved relative replacement example.com=>golang.org/x/example v0.0.0-20210811190340-787a929d5a0d to /home/simnalamburt/workspace/xcaddybug/golang.org/x/example v0.0.0-20210811190340-787a929d5a0d
2021/08/29 22:55:01 [INFO] Temporary folder: /tmp/buildenv_2021-08-29-2255.2607006221
2021/08/29 22:55:01 [INFO] Writing main module: /tmp/buildenv_2021-08-29-2255.2607006221/main.go
2021/08/29 22:55:01 [INFO] Initializing Go module
2021/08/29 22:55:01 [INFO] exec (timeout=10s): /usr/sbin/go mod init caddy
go: creating new go.mod: module caddy
go: to add module requirements and sums:
        go mod tidy
2021/08/29 22:55:01 [INFO] Replace github.com/simnalamburt/xcaddybug => /home/simnalamburt/workspace/xcaddybug
2021/08/29 22:55:01 [INFO] exec (timeout=10s): /usr/sbin/go mod edit -replace github.com/simnalamburt/xcaddybug=/home/simnalamburt/workspace/xcaddybug
2021/08/29 22:55:01 [INFO] Replace example.com => /home/simnalamburt/workspace/xcaddybug/golang.org/x/example v0.0.0-20210811190340-787a929d5a0d
2021/08/29 22:55:01 [INFO] exec (timeout=10s): /usr/sbin/go mod edit -replace example.com=/home/simnalamburt/workspace/xcaddybug/golang.org/x/example@v0.0.0-20210811190340-787a929d5a0d
2021/08/29 22:55:01 [INFO] Pinning versions
2021/08/29 22:55:01 [INFO] exec (timeout=0s): /usr/sbin/go get -d -v github.com/caddyserver/caddy/v2
go: errors parsing go.mod:
/tmp/buildenv_2021-08-29-2255.2607006221/go.mod:7: replacement module directory path "/home/simnalamburt/workspace/xcaddybug/golang.org/x/example" cannot have version
2021/08/29 22:55:01 [ERROR] exit status 1

References

@simnalamburt simnalamburt changed the title Fails if 'go.mod' includes 'replace' directive xcaddy development mode fails if 'go.mod' includes 'replace' directive Aug 29, 2021
@simnalamburt
Copy link
Contributor Author

Patch of this issue has been proposed: #69

Use forked version of xcaddy if you need to workaround this issue right now:

go install github.com/simnalamburt/xcaddy/cmd/xcaddy@466a1a4b86

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

Successfully merging a pull request may close this issue.

1 participant