changkun / midgard

⛰️ Universal clipboard sharing service (supports macOS/Linux/Windows/iOS)
https://changkun.de/s/midgard
GNU General Public License v3.0
210 stars 18 forks source link

Install error: -mod=vendor -x -work flag provided but not defined: -mod #26

Closed LorenAmelang closed 1 year ago

LorenAmelang commented 1 year ago

I was all excited to find a clipboard tool with both Linux and iOS connections!

But:

ubuntu@arm:~/builds/midgard$ make
go build -o mg -ldflags="-X changkun.de/x/midgard/internal/version.GitVersion=v0.0.9 -X changkun.de/x/midgard/internal/version.BuildTime=2023-07-20T16:52:29-0700" -mod=vendor -x -work
flag provided but not defined: -mod

"The build flags are shared by the build, install, run, and test commands:" No list item for "-mod"...

Maybe this server is too old: Ubuntu 14.04.3 LTS (GNU/Linux 3.8.13-bone56 armv7l)

But I just installed go, it wasn't here before, and didn't get errors...

Get:1 http://ports.ubuntu.com/ubuntu-ports/ trusty/universe golang-src armhf 2:1.2.1-2ubuntu1 [4,727 kB]
Get:2 http://ports.ubuntu.com/ubuntu-ports/ trusty/universe golang-go-linux-arm armhf 2:1.2.1-2ubuntu1 [6,235 kB]
Get:3 http://ports.ubuntu.com/ubuntu-ports/ trusty/universe golang-go armhf 2:1.2.1-2ubuntu1 [7,264 kB]

I found this but it is way beyond my go knowledge: https://stackoverflow.com/questions/75090216/go-build-mod-mod-with-no-go-mod

Is there any way to make this work?

changkun commented 1 year ago

does removing -mod work for you?

LorenAmelang commented 1 year ago

Sorry is this is a hopeless newbie question, but where would I remove -mod? I haven't found where that command is stored...

changkun commented 1 year ago

Try to remove -mod=vendor from here then make?

https://github.com/changkun/midgard/blob/91c538353ff48bf381d19d8795a36dfa2a6a2e11/Makefile#L13

LorenAmelang commented 1 year ago

Tried that, thanks! But:

Edited Makefile:

---
ubuntu@arm:~/builds/midgard$ cat Makefile
# Copyright 2020-2021 Changkun Ou. All rights reserved.
# Use of this source code is governed by a GPL-3.0
# license that can be found in the LICENSE file.

VERSION = $(shell git describe --always --tags)
BUILDTIME = $(shell date +%FT%T%z)
GOPATH=$(shell go env GOPATH)
IMAGE = midgard
BINARY = mg
TARGET = -o $(BINARY)
MIDGARD_HOME = changkun.de/x/midgard
BUILD_SETTINGS = -ldflags="-X $(MIDGARD_HOME)/internal/version.GitVersion=$(VERSION) -X $(MIDGARD_HOME)/internal/version.BuildTime=$(BUILDTIME)"
BUILD_FLAGS = $(BUILD_SETTINGS) -x -work
GOVERSION = $(shell curl -s 'https://go.dev/dl/?mode=json' | grep '"version"' | sed 1q | awk '{print $$2}' | tr -d ',"') # get latest go version

all:
        go build $(TARGET) $(BUILD_FLAGS)
install:
        go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.27.1
        go install google.golang.org/grpc/cmd/protoc-gen-go-grpc
gen:
        go generate ./...
dep:
        go mod tidy
        go mod vendor
build:
        cp -f $(SSH_KEY_PATH) id_rsa
        docker build --build-arg GOVERSION=$(GOVERSION) -t $(IMAGE):latest .
        rm id_rsa
up:
        docker-compose up -d
down:
        docker-compose down
clean: down
        rm -rf $(BINARY)
        docker rmi -f $(shell docker images -f "dangling=true" -q) 2> /dev/null; true
        docker rmi -f $(IMAGE):latest 2> /dev/null; true
ubuntu@arm:~/builds/midgard$

ubuntu@arm:~/builds/midgard$ ls
api  config.yml  docker-compose.yml  docs    go.sum    LICENSE   midgard.go    README.md
cmd  data        Dockerfile          go.mod  internal  Makefile  README.cn.md  vendor
ubuntu@arm:~/builds/midgard$ make
go build -o mg -ldflags="-X changkun.de/x/midgard/internal/version.GitVersion=v0.0.9 -X changkun.de/x/midgard/internal/version.BuildTime=2023-07-22T12:39:21-0700" -x -work
WORK=/tmp/go-build179609187
midgard.go:8:2: cannot find package "changkun.de/x/midgard/cmd" in any of:
        /usr/lib/go/src/pkg/changkun.de/x/midgard/cmd (from $GOROOT)
        ($GOPATH not set)
midgard.go:9:2: cannot find package "golang.design/x/hotkey/mainthread" in any of:
        /usr/lib/go/src/pkg/golang.design/x/hotkey/mainthread (from $GOROOT)
        ($GOPATH not set)
make: *** [all] Error 1
ubuntu@arm:~/builds/midgard$
ubuntu@arm:~/builds/midgard$ echo $GOPATH

ubuntu@arm:~/builds/midgard$ echo $GOROOT

ubuntu@arm:~/builds/midgard$ ls $GOPATH
api  config.yml  docker-compose.yml  docs    go.sum    LICENSE   midgard.go    README.md
cmd  data        Dockerfile          go.mod  internal  Makefile  README.cn.md  vendor
ubuntu@arm:~/builds/midgard$
ubuntu@arm:~/builds/midgard$ ls cmd
alloc.go  cmd.go  code2img.go  daemon.go  server.go  status.go  version.go
ubuntu@arm:~/builds/midgard$
ubuntu@arm:~/builds/midgard$ ls -al  /usr/lib/go/src/pkg/
total 200
drwxr-xr-x 41 root root  4096 Jul 20 16:47 .
drwxr-xr-x  7 root root  4096 Jul 20 16:47 ..
drwxr-xr-x  4 root root  4096 Jul 20 16:47 archive
drwxr-xr-x  2 root root  4096 Jul 20 16:47 bufio
drwxr-xr-x  2 root root  4096 Jul 20 16:47 builtin
drwxr-xr-x  2 root root  4096 Jul 20 16:47 bytes
drwxr-xr-x  8 root root  4096 Jul 20 16:47 compress
drwxr-xr-x  5 root root  4096 Jul 20 16:47 container
drwxr-xr-x 19 root root  4096 Jul 20 16:47 crypto
drwxr-xr-x  3 root root  4096 Jul 20 16:47 database
drwxr-xr-x  7 root root  4096 Jul 20 16:47 debug
drwxr-xr-x 13 root root  4096 Jul 20 16:47 encoding
drwxr-xr-x  2 root root  4096 Jul 20 16:47 errors
drwxr-xr-x  2 root root  4096 Jul 20 16:47 expvar
drwxr-xr-x  2 root root  4096 Jul 20 16:47 flag
drwxr-xr-x  2 root root  4096 Jul 20 16:47 fmt
drwxr-xr-x 10 root root  4096 Jul 20 16:47 go
drwxr-xr-x  6 root root  4096 Jul 20 16:47 hash
drwxr-xr-x  3 root root  4096 Jul 20 16:47 html
drwxr-xr-x  8 root root  4096 Jul 20 16:47 image
drwxr-xr-x  3 root root  4096 Jul 20 16:47 index
drwxr-xr-x  3 root root  4096 Jul 20 16:47 io
drwxr-xr-x  3 root root  4096 Jul 20 16:47 log
drwxr-xr-x  5 root root  4096 Jul 20 16:47 math
drwxr-xr-x  4 root root  4096 Jul 20 16:47 mime
drwxr-xr-x  9 root root 12288 Jul 20 16:47 net
drwxr-xr-x  5 root root  4096 Jul 20 16:47 os
drwxr-xr-x  3 root root  4096 Jul 20 16:47 path
drwxr-xr-x  2 root root  4096 Jul 20 16:47 reflect
drwxr-xr-x  4 root root  4096 Jul 20 16:47 regexp
drwxr-xr-x  6 root root 24576 Jul 20 16:47 runtime
drwxr-xr-x  2 root root  4096 Jul 20 16:47 sort
drwxr-xr-x  3 root root  4096 Jul 20 16:47 strconv
drwxr-xr-x  2 root root  4096 Jul 20 16:47 strings
drwxr-xr-x  3 root root  4096 Jul 20 16:47 sync
drwxr-xr-x  2 root root 12288 Jul 20 16:47 syscall
drwxr-xr-x  4 root root  4096 Jul 20 16:47 testing
drwxr-xr-x  5 root root  4096 Jul 20 16:47 text
drwxr-xr-x  2 root root  4096 Jul 20 16:47 time
drwxr-xr-x  4 root root  4096 Jul 20 16:47 unicode
drwxr-xr-x  2 root root  4096 Jul 20 16:47 unsafe
ubuntu@arm:~/builds/midgard$
---

Would be fun to learn more about go someday, but right now I need to move on to other projects... I made a system with sshfs and various shortcuts that seems to do what I need.

changkun commented 1 year ago

Close as not an issue.