0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

go install時にis not in stdエラー

Last updated at Posted at 2023-12-27

単純なミスに気が付かずにハマったので備忘録。
検証のためにGoのインストールやアンインストールを繰り返していたら下記エラーが出るようになった。

$ go install golang.org/dl/go1.21.0@latest
../../go/pkg/mod/golang.org/dl@v0.0.0-20231219203010-00f4782d5d4c/internal/version/version.go:9:2: package archive/tar is not in std (/opt/homebrew/Cellar/go/1.21.5/src/archive/tar)
../../go/pkg/mod/golang.org/dl@v0.0.0-20231219203010-00f4782d5d4c/internal/version/version.go:10:2: package archive/zip is not in std (/opt/homebrew/Cellar/go/1.21.5/src/archive/zip)
../../go/pkg/mod/golang.org/dl@v0.0.0-20231219203010-00f4782d5d4c/internal/version/version.go:11:2: package compress/gzip is not in std (/opt/homebrew/Cellar/go/1.21.5/src/compress/gzip)
../../go/pkg/mod/golang.org/dl@v0.0.0-20231219203010-00f4782d5d4c/internal/version/version.go:12:2: package crypto/sha256 is not in std (/opt/homebrew/Cellar/go/1.21.5/src/crypto/sha256)
../../go/pkg/mod/golang.org/dl@v0.0.0-20231219203010-00f4782d5d4c/internal/version/version.go:13:2: package errors is not in std (/opt/homebrew/Cellar/go/1.21.5/src/errors)
../../go/pkg/mod/golang.org/dl@v0.0.0-20231219203010-00f4782d5d4c/internal/version/gotip.go:8:2: package fmt is not in std (/opt/homebrew/Cellar/go/1.21.5/src/fmt)
../../go/pkg/mod/golang.org/dl@v0.0.0-20231219203010-00f4782d5d4c/internal/version/version.go:15:2: package io is not in std (/opt/homebrew/Cellar/go/1.21.5/src/io)
../../go/pkg/mod/golang.org/dl@v0.0.0-20231219203010-00f4782d5d4c/internal/version/gotip.go:9:2: package log is not in std (/opt/homebrew/Cellar/go/1.21.5/src/log)
../../go/pkg/mod/golang.org/dl@v0.0.0-20231219203010-00f4782d5d4c/internal/version/version.go:17:2: package net/http is not in std (/opt/homebrew/Cellar/go/1.21.5/src/net/http)
../../go/pkg/mod/golang.org/dl@v0.0.0-20231219203010-00f4782d5d4c/internal/version/gotip.go:10:2: package os is not in std (/opt/homebrew/Cellar/go/1.21.5/src/os)
../../go/pkg/mod/golang.org/dl@v0.0.0-20231219203010-00f4782d5d4c/internal/version/gotip.go:11:2: package os/exec is not in std (/opt/homebrew/Cellar/go/1.21.5/src/os/exec)
../../go/pkg/mod/golang.org/dl@v0.0.0-20231219203010-00f4782d5d4c/internal/version/version.go:20:2: package os/signal is not in std (/opt/homebrew/Cellar/go/1.21.5/src/os/signal)
../../go/pkg/mod/golang.org/dl@v0.0.0-20231219203010-00f4782d5d4c/internal/version/version.go:21:2: package os/user is not in std (/opt/homebrew/Cellar/go/1.21.5/src/os/user)
../../go/pkg/mod/golang.org/dl@v0.0.0-20231219203010-00f4782d5d4c/internal/version/version.go:22:2: package path is not in std (/opt/homebrew/Cellar/go/1.21.5/src/path)
../../go/pkg/mod/golang.org/dl@v0.0.0-20231219203010-00f4782d5d4c/internal/version/gotip.go:12:2: package path/filepath is not in std (/opt/homebrew/Cellar/go/1.21.5/src/path/filepath)
../../go/pkg/mod/golang.org/dl@v0.0.0-20231219203010-00f4782d5d4c/internal/version/gotip.go:13:2: package regexp is not in std (/opt/homebrew/Cellar/go/1.21.5/src/regexp)
../../go/pkg/mod/golang.org/dl@v0.0.0-20231219203010-00f4782d5d4c/internal/version/gotip.go:14:2: package runtime is not in std (/opt/homebrew/Cellar/go/1.21.5/src/runtime)
../../go/pkg/mod/golang.org/dl@v0.0.0-20231219203010-00f4782d5d4c/internal/version/gotip.go:15:2: package strconv is not in std (/opt/homebrew/Cellar/go/1.21.5/src/strconv)
../../go/pkg/mod/golang.org/dl@v0.0.0-20231219203010-00f4782d5d4c/internal/version/version.go:26:2: package strings is not in std (/opt/homebrew/Cellar/go/1.21.5/src/strings)
../../go/pkg/mod/golang.org/dl@v0.0.0-20231219203010-00f4782d5d4c/internal/version/signal_unix.go:11:2: package syscall is not in std (/opt/homebrew/Cellar/go/1.21.5/src/syscall)
../../go/pkg/mod/golang.org/dl@v0.0.0-20231219203010-00f4782d5d4c/internal/version/version.go:27:2: package time is not in std (/opt/homebrew/Cellar/go/1.21.5/src/time)

Goのインストール方法を変えたり、キャッシュを消したりなど色々と試したが、
結局のところ、Goの切替時に、GOROOTの設定に誤ってGOPATHを設定していた。

$ go env GOROOT
/Users/mitsuaki.ihara/go

下記で解消。
※下記コマンドはHomebrewでインストールしたGoの場合

$ go env -w GOROOT=$(brew --prefix golang)/libexec

再実行。

$ go install golang.org/dl/go1.21.0@latest

参考

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?