LoginSignup
0
0

More than 5 years have passed since last update.

[未解決]Wercker で dep を使った Golang のビルドが Wercker CLI の Local Mode では動くが、Wercker では動かない問題

Last updated at Posted at 2018-01-02

背景

dep を使った Golang のビルドで同じ wercker.yml を使っているのに Wercker CLI の Local Mode では wercker build が通るのに、Wercker の Web 側では通らなかった。

調査

エラーログ

go build の段階で失敗し、そのログは

go build
main.go:x:x: cannot find package "github.com/pkg/errors" in any of:
    /usr/local/go/src/github.com/pkg/errors (from $GOROOT)
    /go/src/github.com/pkg/errors (from $GOPATH)
make: *** [build] Error 1

と、パッケージが GOROOT および GOPATH で見つからないとのこと。

dep を使ってプロジェクトのルートフォルダに vendor ディレクトリで入れているので、上記パスにないのは当然。

プロジェクトルートフォルダを調べて見る。

プロジェクトルートフォルダ

よい方法がわからなかったので、 dep ensure した次の step で ls する。

  • ローカル
/go/src/<PATH_TO_PROJECT_ROOT>:
total 28
-rw-r--r-- 1 root root  259 Jan  2 05:08 main_test.go
-rw-r--r-- 1 root root  251 Jan  2 05:08 main.go
-rw-r--r-- 1 root root  121 Jan  2 05:08 Makefile
-rw-r--r-- 1 root root  604 Jan  2 05:08 Gopkg.toml
-rw-r--r-- 1 root root  429 Jan  2 05:08 Gopkg.lock
drwxr-xr-x 3 root root 4096 Jan  2 05:08 vendor
-rw-r--r-- 1 root root  653 Jan  2 05:08 wercker.yml
  • Web
/go/src/<PATH_TO_PROJECT_ROOT>:
total 24
-rw-r--r--. 1 root root 251 Jan  2 04:53 main.go
-rw-r--r--. 1 root root 121 Jan  2 04:53 Makefile
-rw-r--r--. 1 root root 604 Jan  2 04:53 Gopkg.toml
-rw-r--r--. 1 root root 429 Jan  2 04:53 Gopkg.lock
-rw-r--r--. 1 root root 653 Jan  2 04:53 wercker.yml
-rw-r--r--. 1 root root 259 Jan  2 04:53 main_test.go

Web 側だと vendor ディレクトリがない。

調べてみると /go/src/github.com/golang/dep/vendor/github.com/pkg/errors に入っていた。

Wercker Web で作成しているコンテナを取得する

dep が Wercker Web 側で作成しているコンテナでの挙動が期待通りではないことがわかったので、Web 側で作成したコンテナを取得する。

を参考にするが、GitHub 認証をしていると wercker login が通らず

  • パスワード再発行
  • ~/.wercker/token に Personal Token を置く
    • ダメだったので --auth-token で直接 Personal Token を指定して認証は通ったが、今度は以下のエラーメッセージが出てダウンロードできない
ERROR No finished builds found for this application
FATAL Exiting.

よく読むと、参考にした記事でもこの方法は同じくできずで、DockerHub にイメージを Push する方法が紹介されていた。

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