mattermost / mattermost-plugin-starter-template

Build scripts and templates for writing Mattermost plugins.
https://developers.mattermost.com/extend/plugins/
Apache License 2.0
128 stars 120 forks source link

Does current master work well with the 5th branch? #164

Closed vblz closed 1 year ago

vblz commented 2 years ago

plugin.json says "min_server_version": "5.37.0", but backend plugin requires github.com/mattermost/mattermost-server/v6.

Plugin builded with current master has error deploying to v5.39.1:

{
    "level": "error",
    "ts": 1645430037.4994786,
    "caller": "mlog/log.go:251",
    "msg": "Unable to activate plugin",
    "plugin_id": "ID",
    "error": "unable to start plugin: ID: Unrecognized remote plugin message: \n\nThis usually means that the plugin is either invalid or simply\nneeds to be recompiled to support the latest protocol.",
    "errorVerbose": "Unrecognized remote plugin message: \n\nThis usually means that the plugin is either invalid or simply\nneeds to be recompiled to support the latest protocol.\nunable to start plugin: ID\ngithub.com/mattermost/mattermost-server/v5/plugin.(*Environment).Activate\n\tgithub.com/mattermost/mattermost-server/v5/plugin/environment.go:274\ngithub.com/mattermost/mattermost-server/v5/app.(*Server).syncPluginsActiveState.func2\n\tgithub.com/mattermost/mattermost-server/v5/app/plugin.go:144\nruntime.goexit\n\truntime/asm_amd64.s:1374"
}
hanzei commented 2 years ago

@vblz Can you reproduce the error consistently? Does it also happen when you deploy to a v6 server?

vblz commented 2 years ago

I manage to reproduce it consistently, it repdocues on both v5 and v6 servers.

Env

# go version
go version go1.18.1 linux/amd64

# go env
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/v/.cache/go-build"
GOENV="/home/v/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/v/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/v/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.18.1"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/v/path/to/project/go.mod"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build1614194871=/tmp/go-build -gno-record-gcc-switches"

# cat /etc/*-release
DISTRIB_ID=Pop
DISTRIB_RELEASE=21.10
DISTRIB_CODENAME=impish
DISTRIB_DESCRIPTION="Pop!_OS 21.10"
NAME="Pop!_OS"
VERSION="21.10"
ID=pop
ID_LIKE="ubuntu debian"
PRETTY_NAME="Pop!_OS 21.10"
VERSION_ID="21.10"
HOME_URL="https://pop.system76.com"
SUPPORT_URL="https://support.system76.com"
BUG_REPORT_URL="https://github.com/pop-os/pop/issues"
PRIVACY_POLICY_URL="https://system76.com/privacy"
VERSION_CODENAME=impish
UBUNTU_CODENAME=impish
LOGO=distributor-logo-pop-os

Mattermost test stand: sudo docker run --name mattermost-preview -d --publish 8065:8065 mattermost/mattermost-preview

WTR

  1. git clone --depth 1 https://github.com/mattermost/mattermost-plugin-starter-template com.example.my-plugin && cd com.example.my-plugin && GOFLAGS=-buildvcs=false make
  2. Upload dist/com.mattermost.plugin-starter-template-0.1.0.tar.gz as a plugin

Result

The plugin doesn't start with the error This plugin failed to start. Check your system logs for errors. Logs:

{"timestamp":"2022-04-20 07:28:02.685 Z","level":"error","msg":"Unable to activate plugin","caller":"app/plugin.go:142","plugin_id":"com.mattermost.plugin-starter-template","error":"unable to start plugin: com.mattermost.plugin-starter-template: Unrecognized remote plugin message: \n\nThis usually means that the plugin is either invalid or simply\nneeds to be recompiled to support the latest protocol."}

Way to fix (really strange)

Remove all -trimpath arguments from Makefile and rebuild again

# sed -e "s/-trimpath //g" -i Makefile
# GOFLAGS=-buildvcs=false make

after that plugin starts working. I found it during git bisect, the commit plugin stops working is https://github.com/mattermost/mattermost-plugin-starter-template/commit/05c25c4c47d1780cbd0698da5ded65df9ff1fa85

vblz commented 2 years ago

Found another way to bypass the problem: disabling CGO. CGO_ENABLED=0 GOFLAGS=-buildvcs=false make builds working plugin without removing -trimpath