英文:
Error on mgo dependency when deploying go app to Heroku
问题
我正在尝试将一个Go应用部署到Heroku,根据他们的文档建议,我正在使用godeps进行依赖管理。
但是当我执行git push heroku master
时,我收到以下错误提示,告诉我文件sasl.go不存在。
remote: # github.com/grsouza/feeng-api/vendor/gopkg.in/mgo.v2/internal/sasl
remote: vendor/gopkg.in/mgo.v2/internal/sasl/sasl.go:15:24: fatal error: sasl/sasl.h: No such file or directory
remote: // #include <sasl/sasl.h>
remote: ^
remote: compilation terminated.
remote: github.com/grsouza/feeng-api/vendor/github.com/onsi/gomega
remote:
remote: ! Push rejected, failed to compile Go app
remote:
remote: Verifying deploy....
remote:
remote: ! Push rejected to limitless-ridge-36512.
remote:
To https://git.heroku.com/limitless-ridge-36512.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/limitless-ridge-36512.git'
有人可以帮我解决这个问题吗?
谢谢。
英文:
I'm trying to deploy a Go App to Heroku, I'm using godeps for dependency management as their docs suggested.
But when I git push heroku master
I get the following error telling that the file sasl.go doesn't exists.
remote: # github.com/grsouza/feeng-api/vendor/gopkg.in/mgo.v2/internal/sasl
remote: vendor/gopkg.in/mgo.v2/internal/sasl/sasl.go:15:24: fatal error: sasl/sasl.h: No such file or directory
remote: // #include <sasl/sasl.h>
remote: ^
remote: compilation terminated.
remote: github.com/grsouza/feeng-api/vendor/github.com/onsi/gomega
remote:
remote: ! Push rejected, failed to compile Go app
remote:
remote: Verifying deploy....
remote:
remote: ! Push rejected to limitless-ridge-36512.
remote:
To https://git.heroku.com/limitless-ridge-36512.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/limitless-ridge-36512.git'
Can anyone help me with this issue?
Thanks.
答案1
得分: 1
你在项目中使用godep save ./...
吗?
如果是的话,删除Godep
和vendor
目录,尝试使用godep save
,不要加上./...
。
我这样做了,对我有效。
英文:
Do you use godep save ./...
in your project?
If yes, delete the Godep
and vendor
directories and try to use godep save
, without ./...
.
I do this and work for me.
答案2
得分: 0
错误提示缺少sasl/sasl.h文件,但没有缺少sasl.go文件。sasl.h头文件是libsasl2-dev软件包的一部分,在Heroku上没有安装,我不知道简单的安装方法。我认为你可以尝试在本地机器上找到sasl头文件(很可能在/usr/include/sasl),然后将其复制到本地Go应用程序源代码的vendor/include/sasl目录中。然后,在Heroku控制台上使用以下命令使它们对CGO可见:
heroku config:set CGO_CFLAGS= -I/app/code/vendor/include/sasl
然后进行git push操作。另外,你还可以在Heroku上寻找libsasl2-dev的构建包,并尝试在应用程序中使用两个构建包,类似于:
heroku buildpacks:add heroku/some_libsasl2-dev
英文:
Error tells sasl/sasl.h missing but not sasl.go. sasl.h header file is part of libsasl2-dev package which not installed on heroku and I don't know simple way to install it. To my mind you can try to find sasl headers on your local machine(most likely /usr/include/sasl)and copy to vendor/include/sasl in your local go app source. Then make them visible for CGO using heroku config vars doing
heroku config:set CGO_CFLAGS= -I/app/code/vendor/include/sasl
in heroku console, and than git push.
Also you can look for libsasl2-dev buildpack for heroku and try to use two buildpacks for your app with something like
heroku buildpacks:add heroku/some_libsasl2-dev
答案3
得分: 0
我终于找到了一个解决方案(来自https://github.com/go-mgo/mgo/issues/220#issuecomment-212658192):
- 运行
godep save ./...
(创建包含所有依赖项的供应商目录) - 然后再次运行
godep save
,不带 ./...(这将删除未使用的文件)
英文:
I finally found a solution (from https://github.com/go-mgo/mgo/issues/220#issuecomment-212658192):
- run
godep save ./...
(to create the vendor directory with all the dependencies) - then re-run
godep save
without ./... (this will remove unused files)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论