LoginSignup
2
1

More than 3 years have passed since last update.

$GOPATH/pkg/mod配下のファイルが消せない

Posted at

$GOPATHを変更した話

Goのインストール時に$GOPATH~/workspace/goな感じにしたら扱いにくかったのでデフォルト~に戻して、元のディレクトリをrmしようとしたときに消せなかったのでメモ

terminal
$ echo $GOPATH #変更後
/Users/usr/go

$ rm -rf ~/workspace/go
rm: cannot remove '/Users/usr/workspace/go/pkg/mod/golang.org/x/crypto@v0.0.0-20190308221718-c2843e01d9a2/internal/subtle/aliasing.go': Permission denied
rm: cannot remove '/Users/usr/workspace/go/pkg/mod/golang.org/x/crypto@v0.0.0-20190308221718-c2843e01d9a2/internal/subtle/aliasing_test.go': Permission denied
rm: cannot remove '/Users/usr/workspace/go/pkg/mod/golang.org/x/crypto@v0.0.0-20190308221718-c2843e01d9a2/internal/subtle/aliasing_appengine.go': Permission denied
rm: cannot remove '/Users/usr/workspace/go/pkg/mod/golang.org/x/crypto@v0.0.0-20190308221718-c2843e01d9a2/internal/chacha20/chacha_s390x.s': Permission denied
[...]

パーミッションがREAD_ONLY

ゴミプロセスが掴んでるのかと思ったら仕様らしい

解決策

go modは以下で消せとのこと。

terminal
$ go clean -modcache

めんどくさいのでwパーミッションつけて消しました。

terminal
$ find ~/workspace/go/pkg/mod -exec chmod u+w {} \;
$ rm -rf ~/workspace/go

めでたし、めでたし。

Links

2
1
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
2
1