Golang dep ensureがハングした時にやったこと
はじめに
たまにGolangを使います。最近は依存関係のマネージメントツールは Glide
ではなく dep
を使っているのですが dep ensure
が延々と終わらない状況となり、一応の解決を迎えたので備忘録です。
起こったこと
以下のようなコードを書き dep ensure
をしたところ、10分以上処理が終わらない状況になりました。
package main import ( "fmt" _ "github.com/aws/aws-sdk-go" ) func main() { fmt.Println("hello world") }
depのバージョンはこちらです。
$ dep version dep: version : v0.4.1-161-g8b166f24 build date : 2018-05-02 git hash : 8b166f24 go version : go1.10 go compiler : gc platform : darwin/amd64 features : ImportDuringSolve=false
対応
まずは詳細情報を得るため dep ensure -v
を実行してみたところ、以下の表示でハングしていました。
$ dep ensure -v Root project is "xxxx/xxxx" 1 transitively valid internal packages 1 external packages imported from 1 projects (0) ✓ select (root)
この状態でどのようなプロセスが起動されているのか調査した結果がこちらです。
$ pstree | \-+= 94723 ginyon dep ensure -v | \-+= 94805 ginyon git ls-remote ssh://git@github.com/aws/aws-sdk-go | \--- 94806 ginyon /usr/bin/ssh git@github.com git-upload-pack '/aws/aws-sdk-go'
試しに git ls-remote ssh://git@github.com/aws/aws-sdk-go
を叩いたところホストキーの受け入れを確認されました。
$ git ls-remote ssh://git@github.com/aws/aws-sdk-go The authenticity of host 'github.com (192.30.255.112)' can't be established. RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8. Are you sure you want to continue connecting (yes/no)?
yes
としてホストキー受け入れ後、再度 dep ensure -v
を実行した結果がこちらです。
$ dep ensure -v Root project is "xxxx/xxxx" 1 transitively valid internal packages 1 external packages imported from 1 projects (0) ✓ select (root) (1) ? attempt github.com/aws/aws-sdk-go with 1 pkgs; 410 versions to try (1) try github.com/aws/aws-sdk-go@v1.13.54 (1) ✓ select github.com/aws/aws-sdk-go@v1.13.54 w/1 pkgs ✓ found solution with 1 packages from 1 projects Solver wall times by segment: b-source-exists: 5.001233802s b-list-pkgs: 3.256008604s b-gmal: 3.198661178s b-list-versions: 2.016181548s satisfy: 13.335691ms select-atom: 11.367302ms new-atom: 82.554µs select-root: 61.103µs other: 18.659µs b-deduce-proj-root: 2.296µs TOTAL: 13.496952737s (1/1) Wrote github.com/aws/aws-sdk-go@v1.13.54
無事に導入できました。というメモです。