Cannot upgrade from caddy 1.5 to 2.1

1. Caddy version (caddy version):

1.5

2. How I run Caddy:

I run caddy as a docker container with our plugins running on top of it.

a. System environment:

We build our docker from alpine:3.7. I am running the development environment in Mac OS, Mojave.

b. Command:

I also tried:

go get github.com/caddyserver/caddy@v2.1.0

which still gives me the same error.

d. My complete Caddyfile or JSON config:

http://*:80/ {
  root /var/www/html/
  own_plugin
  tls off
  log stdout
}

3. The problem I’m having:

I am trying to upgrade caddy from 1.5 to 2.1. But after updating go.mod file to github.com/caddyserver/caddy v2.1.0, if I run go mod vendor, I am getting the following error:

    go: errors parsing go.mod:
    repo/go.mod:7: require github.com/caddyserver/caddy: version "v2.1.0" invalid: module contains a go.mod file, so major version must be compatible: should be v0 or v1, not v2

How can I upgrade to caddy v2.1.0?

4. Error messages and/or full log output:

go: errors parsing go.mod:
repo/go.mod:7: require github.com/caddyserver/caddy: version “v2.1.0” invalid: module contains a go.mod file, so major version must be compatible: should be v0 or v1, not v2

5. What I already tried:

I also tried:

go get github.com/caddyserver/caddy@v2.1.0

which still gives me the same error.

6. Links to relevant resources:

Hi @masumbuet – so, it looks like you are building from source?

I would recommend following our instructions here: https://caddyserver.com/docs/build

Your go get command doesn’t have proper syntax; you can read how Go modules work here: https://github.com/golang/go/wiki/Modules – especially the section about Semantic Import Versioning will be relevant.

FYI, Caddy 1.5 never existed. Maybe you are referring to v1.0.5?

Also, FYI Caddy v2 is a complete rewrite from Caddy v1, so your plugins will not work without significant changes. Please refer to the docs for the v2 upgrade guide and the Extending Caddy guide for writing plugins.

1 Like