elisescu / tty-share

Share your linux or osx terminal over the Internet.
https://tty-share.com/
MIT License
816 stars 87 forks source link

Issues building #39

Closed JanGieseler closed 3 years ago

JanGieseler commented 3 years ago

I am trying to build tty-share on a raspberry pi. Probably this is more an issue of me not understanding golang well enough, but still I am trying to get some help here:

I installed the go following the steps here

        GOVERSION=go1.16.5.linux-armv6l.tar.gz
        mkdir ~/src && cd ~/src
        wget https://golang.org/dl/$GOVERSION
        sudo tar -C /usr/local -xzf $GOVERSION

        # append to .profile
        echo "PATH=\$PATH:/usr/local/go/bin" >> ~/.profile
        echo "GOPATH=\$HOME/go" >> ~/.profile
        # Update your shell with your changes:
        source ~/.profile
        # check version 
        go version

Then I run

go get github.com/elisescu/tty-share

followed by

cd ~/go/pkg/mod/github.com/elisescu/tty-share@v0.6.2
go build

However, this gives me the following error

go build github.com/elisescu/tty-share: copying /tmp/go-build3947162155/b001/exe/a.out: open tty-share: permission denied

What are the steps that I am missing?

Thanks!

JanGieseler commented 3 years ago

Here also more detailed output

go build -x
WORK=/tmp/go-build1776756444
mkdir -p $WORK/b001/
cat >$WORK/b001/importcfg.link << 'EOF' # internal
packagefile github.com/elisescu/tty-share=/home/pi/.cache/go-build/33/3398d3a9cdcac0e40b552876b8ec4ae4c106c777b74c94d385ad2ae803c8e2d6-d
packagefile crypto/tls=/home/pi/.cache/go-build/5e/5ef15941dc2e0ea2a8d94682d2926c1d695a7c16b095c7d0261b371a6052ddf1-d
packagefile crypto/x509=/home/pi/.cache/go-build/08/08c992741edf8fa5b4bb1717d9f886cf328e3fb8ebf2d5c2ca9ec0ea543c8e00-d
packagefile encoding/json=/usr/local/go/pkg/linux_arm/encoding/json.a
packagefile errors=/usr/local/go/pkg/linux_arm/errors.a
packagefile flag=/usr/local/go/pkg/linux_arm/flag.a
packagefile fmt=/usr/local/go/pkg/linux_arm/fmt.a
packagefile github.com/elisescu/pty=/home/pi/.cache/go-build/b0/b02526a252484c6027fd034965c296ea2fb0aababc0945b07123ced661fa12c8-d
packagefile github.com/sirupsen/logrus=/home/pi/.cache/go-build/64/6458b309fce1b2cf4b36b3829fa71a20914b52a7c3afaa371153b0d372d3eb98-d
packagefile golang.org/x/crypto/ssh/terminal=/home/pi/.cache/go-build/96/96530ea39b99d1b0f8bdf1a0f810301d6082e70a83afe7f1d2b56542b986a24d-d
packagefile io=/usr/local/go/pkg/linux_arm/io.a
packagefile net=/home/pi/.cache/go-build/c3/c3b1df9afbb083cfc40a12fed423db4995598a7124ffdab7fc37af97c198dda3-d
packagefile os=/usr/local/go/pkg/linux_arm/os.a
packagefile os/exec=/usr/local/go/pkg/linux_arm/os/exec.a
packagefile os/signal=/usr/local/go/pkg/linux_arm/os/signal.a
packagefile strings=/usr/local/go/pkg/linux_arm/strings.a
packagefile syscall=/usr/local/go/pkg/linux_arm/syscall.a
packagefile time=/usr/local/go/pkg/linux_arm/time.a
packagefile runtime=/usr/local/go/pkg/linux_arm/runtime.a
packagefile math=/usr/local/go/pkg/linux_arm/math.a
packagefile bytes=/usr/local/go/pkg/linux_arm/bytes.a
packagefile container/list=/usr/local/go/pkg/linux_arm/container/list.a
packagefile context=/usr/local/go/pkg/linux_arm/context.a
packagefile crypto=/usr/local/go/pkg/linux_arm/crypto.a
packagefile crypto/aes=/usr/local/go/pkg/linux_arm/crypto/aes.a
packagefile crypto/cipher=/usr/local/go/pkg/linux_arm/crypto/cipher.a
packagefile crypto/des=/usr/local/go/pkg/linux_arm/crypto/des.a
packagefile crypto/ecdsa=/usr/local/go/pkg/linux_arm/crypto/ecdsa.a
packagefile crypto/ed25519=/usr/local/go/pkg/linux_arm/crypto/ed25519.a
packagefile crypto/elliptic=/usr/local/go/pkg/linux_arm/crypto/elliptic.a
packagefile crypto/hmac=/usr/local/go/pkg/linux_arm/crypto/hmac.a
packagefile crypto/md5=/usr/local/go/pkg/linux_arm/crypto/md5.a
packagefile crypto/rand=/usr/local/go/pkg/linux_arm/crypto/rand.a
packagefile crypto/rc4=/usr/local/go/pkg/linux_arm/crypto/rc4.a
packagefile crypto/rsa=/usr/local/go/pkg/linux_arm/crypto/rsa.a
packagefile crypto/sha1=/usr/local/go/pkg/linux_arm/crypto/sha1.a
packagefile crypto/sha256=/usr/local/go/pkg/linux_arm/crypto/sha256.a
packagefile crypto/sha512=/usr/local/go/pkg/linux_arm/crypto/sha512.a
packagefile crypto/subtle=/usr/local/go/pkg/linux_arm/crypto/subtle.a
packagefile encoding/pem=/usr/local/go/pkg/linux_arm/encoding/pem.a
packagefile vendor/golang.org/x/crypto/chacha20poly1305=/usr/local/go/pkg/linux_arm/vendor/golang.org/x/crypto/chacha20poly1305.a
packagefile vendor/golang.org/x/crypto/cryptobyte=/usr/local/go/pkg/linux_arm/vendor/golang.org/x/crypto/cryptobyte.a
packagefile vendor/golang.org/x/crypto/curve25519=/usr/local/go/pkg/linux_arm/vendor/golang.org/x/crypto/curve25519.a
packagefile vendor/golang.org/x/crypto/hkdf=/usr/local/go/pkg/linux_arm/vendor/golang.org/x/crypto/hkdf.a
packagefile hash=/usr/local/go/pkg/linux_arm/hash.a
packagefile internal/cpu=/usr/local/go/pkg/linux_arm/internal/cpu.a
packagefile math/big=/usr/local/go/pkg/linux_arm/math/big.a
packagefile sort=/usr/local/go/pkg/linux_arm/sort.a
packagefile strconv=/usr/local/go/pkg/linux_arm/strconv.a
packagefile sync=/usr/local/go/pkg/linux_arm/sync.a
packagefile sync/atomic=/usr/local/go/pkg/linux_arm/sync/atomic.a
packagefile crypto/dsa=/usr/local/go/pkg/linux_arm/crypto/dsa.a
packagefile crypto/x509/pkix=/usr/local/go/pkg/linux_arm/crypto/x509/pkix.a
packagefile encoding/asn1=/usr/local/go/pkg/linux_arm/encoding/asn1.a
packagefile encoding/hex=/usr/local/go/pkg/linux_arm/encoding/hex.a
packagefile vendor/golang.org/x/crypto/cryptobyte/asn1=/usr/local/go/pkg/linux_arm/vendor/golang.org/x/crypto/cryptobyte/asn1.a
packagefile io/fs=/usr/local/go/pkg/linux_arm/io/fs.a
packagefile net/url=/usr/local/go/pkg/linux_arm/net/url.a
packagefile path/filepath=/usr/local/go/pkg/linux_arm/path/filepath.a
packagefile reflect=/usr/local/go/pkg/linux_arm/reflect.a
packagefile unicode=/usr/local/go/pkg/linux_arm/unicode.a
packagefile unicode/utf8=/usr/local/go/pkg/linux_arm/unicode/utf8.a
packagefile encoding=/usr/local/go/pkg/linux_arm/encoding.a
packagefile encoding/base64=/usr/local/go/pkg/linux_arm/encoding/base64.a
packagefile unicode/utf16=/usr/local/go/pkg/linux_arm/unicode/utf16.a
packagefile internal/reflectlite=/usr/local/go/pkg/linux_arm/internal/reflectlite.a
packagefile internal/fmtsort=/usr/local/go/pkg/linux_arm/internal/fmtsort.a
packagefile bufio=/usr/local/go/pkg/linux_arm/bufio.a
packagefile golang.org/x/sys/unix=/home/pi/.cache/go-build/99/9979b313ff8804cc938b6aaa5accb791f89977cddc5ac21c319787f752897faf-d
packagefile log=/usr/local/go/pkg/linux_arm/log.a
packagefile vendor/golang.org/x/net/dns/dnsmessage=/usr/local/go/pkg/linux_arm/vendor/golang.org/x/net/dns/dnsmessage.a
packagefile internal/bytealg=/usr/local/go/pkg/linux_arm/internal/bytealg.a
packagefile internal/nettrace=/usr/local/go/pkg/linux_arm/internal/nettrace.a
packagefile internal/poll=/usr/local/go/pkg/linux_arm/internal/poll.a
packagefile internal/singleflight=/usr/local/go/pkg/linux_arm/internal/singleflight.a
packagefile runtime/cgo=/home/pi/.cache/go-build/07/07f4842d137dc0939b43af0810cf5f9735e232a15e1a8dc1e8f7fecf70382aa8-d
packagefile internal/oserror=/usr/local/go/pkg/linux_arm/internal/oserror.a
packagefile internal/syscall/execenv=/usr/local/go/pkg/linux_arm/internal/syscall/execenv.a
packagefile internal/syscall/unix=/usr/local/go/pkg/linux_arm/internal/syscall/unix.a
packagefile internal/testlog=/usr/local/go/pkg/linux_arm/internal/testlog.a
packagefile internal/race=/usr/local/go/pkg/linux_arm/internal/race.a
packagefile internal/unsafeheader=/usr/local/go/pkg/linux_arm/internal/unsafeheader.a
packagefile runtime/internal/atomic=/usr/local/go/pkg/linux_arm/runtime/internal/atomic.a
packagefile runtime/internal/math=/usr/local/go/pkg/linux_arm/runtime/internal/math.a
packagefile runtime/internal/sys=/usr/local/go/pkg/linux_arm/runtime/internal/sys.a
packagefile math/bits=/usr/local/go/pkg/linux_arm/math/bits.a
packagefile crypto/internal/subtle=/usr/local/go/pkg/linux_arm/crypto/internal/subtle.a
packagefile encoding/binary=/usr/local/go/pkg/linux_arm/encoding/binary.a
packagefile crypto/internal/randutil=/usr/local/go/pkg/linux_arm/crypto/internal/randutil.a
packagefile crypto/ed25519/internal/edwards25519=/usr/local/go/pkg/linux_arm/crypto/ed25519/internal/edwards25519.a
packagefile vendor/golang.org/x/crypto/chacha20=/usr/local/go/pkg/linux_arm/vendor/golang.org/x/crypto/chacha20.a
packagefile vendor/golang.org/x/crypto/internal/subtle=/usr/local/go/pkg/linux_arm/vendor/golang.org/x/crypto/internal/subtle.a
packagefile vendor/golang.org/x/crypto/poly1305=/usr/local/go/pkg/linux_arm/vendor/golang.org/x/crypto/poly1305.a
packagefile math/rand=/usr/local/go/pkg/linux_arm/math/rand.a
packagefile path=/usr/local/go/pkg/linux_arm/path.a
EOF
mkdir -p $WORK/b001/exe/
cd .
/usr/local/go/pkg/tool/linux_arm/link -o $WORK/b001/exe/a.out -importcfg $WORK/b001/importcfg.link -buildmode=exe -buildid=1cwhf8CO4wwrvCD_tFu5/qo7Qttv5Nrl4f75jN7qQ/msBMaDSRMcvqHlBKbzqV/1cwhf8CO4wwrvCD_tFu5 -extld=gcc /home/pi/.cache/go-build/33/3398d3a9cdcac0e40b552876b8ec4ae4c106c777b74c94d385ad2ae803c8e2d6-d
/usr/local/go/pkg/tool/linux_arm/buildid -w $WORK/b001/exe/a.out # internal
cp $WORK/b001/exe/a.out tty-share
rm -r $WORK/b001/
go build github.com/elisescu/tty-share: copying /tmp/go-build1776756444/b001/exe/a.out: open tty-share: permission denied
elisescu commented 3 years ago

@JanGieseler have you tried building other go packages/tools in your raspberrypi environment/installation? The error you get doesn't seem to be related to tty-share, or at least I don't see a connection.

Btw, you can cross-build tty-share for raspberrypi on your working machine, no need to install golang on your raspberrypi. You can use the GOOS GOARCH and GOARM environment variables, like I do here: https://github.com/elisescu/tty-share/blob/5ab9061d22520a271ff07fe053074fa79a5fe787/scripts/release.sh#L6

Please let me know if it was indeed with your golang installation/setup and other tools didn't build either.

JanGieseler commented 3 years ago

Thanks for the quick response. I checked with the simple hello world example

mkdir tmp
cd tmp
go mod init example.com/tmp

then I created a main.go file with

cat main.go 
package main

import "fmt"

func main() {
        fmt.Println("Hello, 世界")
}

and built it go build -x output: WORK=/tmp/go-build2634473080

This works fine:

./tmp
Hello, 世界
JanGieseler commented 3 years ago

ok, at the end it was quite simple. The folder didn't have write rights. The following worked for me

chmod +w tty-share@v0.6.2/
elisescu commented 3 years ago

Hmm..this is pretty weird. This line

go build github.com/elisescu/tty-share: copying /tmp/go-build1776756444/b001/exe/a.out: open tty-share: permission denied

makes me think that maybe it cannot write in the folder cd ~/go/pkg/mod/github.com/elisescu/tty-share@v0.6.2? Can you try to see if that's the case (i.e.: the user running your go build command can write to that path?). Maybe also try with another package that you would build the same way: go get <package url> && cd <path> && go build. If these two work well, then I don't really know what could go wrong in your case. Let me know if you figured that something's wrong with tty-share .