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

Using WSL Ubuntu 20.04.5 LTS #183

Open
Kuchiriel opened this issue Nov 26, 2022 · 2 comments
Open

Using WSL Ubuntu 20.04.5 LTS #183

Kuchiriel opened this issue Nov 26, 2022 · 2 comments

Comments

@Kuchiriel
Copy link

go get github.com/ericchiang/pup

golang.org/x/sys/unix

go/src/golang.org/x/sys/unix/syscall.go:83:16: undefined: unsafe.Slice
go/src/golang.org/x/sys/unix/syscall_linux.go:2256:9: undefined: unsafe.Slice
go/src/golang.org/x/sys/unix/syscall_unix.go:118:7: undefined: unsafe.Slice
go/src/golang.org/x/sys/unix/sysvshm_unix.go:33:7: undefined: unsafe.Slice

@ernstki
Copy link

ernstki commented Dec 22, 2022

Unsafe.slice was added in Go 1.17. There appears to be nothing you can do except find a way to get Go ≥ 1.17 on your system.

Update: See below.

Here are the steps I used, as a normal user, using /usr/bin/go which was version 1.13:

# temporary; you will want to add $HOME/go/bin to PATH in your login scripts
PATH=$HOME/go/bin:$PATH

# get a more recent release
GO111MODULE=on go get golang.org/dl/go1.18.9@latest

# download the full SDK
go1.18.9 download

# get pup
go1.18.9 install github.com/ericchiang/pup@latest

# make sure it worked
which pup
# result: /home/me/go/bin/pup

As a disclaimer, I am not a Go developer, and I don't claim to understand why GO111MODULE is required, why @latest seems to be required, nor why (for the second-to-last step), go get no longer works "outside a module." I just tried several things until I found something that got me a pup. I hope this can still help you, though.

References

  1. https://stackoverflow.com/questions/74049351/gcloud-functions-deploy-go-runtime-error-undefined-unsafe-slice-error-id-2f5#comment130746093_74049351
  2. https://go.dev/doc/manage-install
  3. https://stackoverflow.com/questions/54415733/getting-gopath-error-go-cannot-use-pathversion-syntax-in-gopath-mode-in-ubun/56249926#56249926

@ernstki
Copy link

ernstki commented Jun 21, 2023

At the time, I didn't realize that there were other versions of golang in the Ubuntu 20.04 repositories. Here's an alternative, using packages already available in the repositories:

sudo apt install golang-1.18

Then, in your ~/.profile (assuming the default shell on Debian/Ubuntu):

# this is just a personal preference; the default on Unix is ~/go
export GOPATH=$HOME/.local/go
export GOROOT=/usr/lib/go-1.18
export PATH="$GOROOT/bin:$GOPATH/bin:$PATH"

Log out and back in, or . ~/.profile in your current shell session, then:

go install -v github.com/ericchiang/pup@latest

Test to make sure it worked:

$ which pup
/home/yourusername/.local/go/bin/pup

$ pup --help

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

No branches or pull requests

2 participants