I've tried 2 methods to include goose to my golang project and it fails during the heroku build. I first tried this method: https://bitbucket.org/liamstask/goose/
I added 2 packages to the vendor.json file:
{
"checksumSHA1": "rmNwGgFJAcDxUGF5yB/zqhQPxCA=",
"path": "bitbucket.org/liamstask/goose/cmd/goose",
"revision": "8488cc47d90c8a502b1c41a462a6d9cc8ee0a895",
"revisionTime": "2015-01-15T23:40:39Z"
},
{
"checksumSHA1": "jdqLDQw64kBjkU7LPK7C+Qwj7W8=",
"path": "bitbucket.org/liamstask/goose/lib/goose",
"revision": "8488cc47d90c8a502b1c41a462a6d9cc8ee0a895",
"revisionTime": "2015-01-15T23:40:39Z"
}
and got the error:
can't load package: package bitbucket.org/liamstask/goose/cmd/goose: cannot find package "bitbucket.org/liamstask/goose/cmd/goose" in any of:
/app/tmp/cache/go1.7.5/go/src/bitbucket.org/liamstask/goose/cmd/goose (from $GOROOT)
/tmp/tmp.Pqgwxz8KyN/.go/src/bitbucket.org/liamstask/goose/cmd/goose (from $GOPATH)
! Push rejected, failed to compile Go app.
I then found these directions: https://bitbucket.org/liamstask/goose/issues/55/heroku-instructions-no-longer-works-on-go
and tried updating my vendor file to include:
"install": [
"./...",
"bitbucket.org/liamstask/goose/cmd/goose"
]
I'm still getting the same error message above. Any thoughts?
edit: Here's the full error message:
-----> Go app detected
-----> Checking vendor/vendor.json file.
-----> Using go1.7.5
-----> Fetching any unsaved dependencies (govendor sync)
-----> Running: go install -v -tags heroku ./... vendor/bitbucket.org/liamstask/goose/cmd/goose
can't load package: package vendor/bitbucket.org/liamstask/goose/cmd/goose: cannot find package "vendor/bitbucket.org/liamstask/goose/\u200c\u200bcmd/goose" in any of:
/app/tmp/cache/go1.7.5/go/src/vendor/bitbucket.org/liamstask/goose/cmd/goose (from $GOROOT)
/tmp/tmp.IJd3qxVYqW/.go/src/vendor/bitbucket.org/liamstask/goose/cmd/goose (from $GOPATH)
! Push rejected, failed to compile Go app.
! Push failed
Related
I have been working on a Go project and deploying it successfully with Heroku up until I added more packages. My Heroku app is set up to deploy the main branch of my github repo, but it fails to build the app each time I push. This is the build log:
-----> Using buildpack: heroku/go
-----> Go app detected
-----> Fetching stdlib.sh.v8... done
----->
Detected go modules via go.mod
----->
Detected Module Name: my-heroku-app
----->
-----> New Go Version, clearing old cache
-----> Installing go1.17.3
-----> Fetching go1.17.3.linux-amd64.tar.gz... done
-----> Determining packages to install
Detected the following main packages to install:
my-heroku-app
-----> Running: go install -v -tags heroku -mod=vendor my-heroku-app
webapp.go:6:2: cannot find package "." in:
/tmp/build_1bdd9ef1/vendor/github.com/go-sql-driver/mysql
webapp.go:7:2: cannot find package "." in:
/tmp/build_1bdd9ef1/vendor/github.com/gorilla/context
webapp.go:8:2: cannot find package "." in:
/tmp/build_1bdd9ef1/vendor/github.com/gorilla/sessions
webapp.go:9:2: cannot find package "." in:
/tmp/build_1bdd9ef1/vendor/golang.org/x/crypto/bcrypt
! Push rejected, failed to compile Go app.
! Push failed
Here is what my import statement looks like
import (
"database/sql"
"fmt"
_ "github.com/go-sql-driver/mysql"
"github.com/gorilla/context"
"github.com/gorilla/sessions"
"golang.org/x/crypto/bcrypt"
"html/template"
"log"
"net/http"
"time"
"unicode"
)
I have tried reading through the guides and documentation about govendor both at Heroku and on their github page, and as far as I can tell, I have done my setup correctly. I am currently using govendor and I have a vendor folder containing a json file in my repo that has the info for the dependencies. Everything works when I run it locally
update: I made a fresh repo with minimal code but as soon as I add a dependency I got the same error. I also tried deploying on Digital Ocean as well but I think they use the open source Heroku buildpack so I got the same error
update 2: I got a pared down version of the app working. The repo has no vendor directory or vendor json whatsoever despite using an external package (build log shows successful install of external package)
I have a PDF conversion package in my Go project which relies upon "wkhtmltox" debian package. I install "wkhtmltopdf" (similar to "wkhtmltox") through APT buildpack before running a Go buildpack. The "wkhtmltopdf" has been tested locally, and in this case Go project builds perfectly. But when I do it in Heroku, it does not work out, and fails with the same error as would pop out in case no "wkhtmltox" nor "wkhtmltopdf" was installed. The successfully installed "wkhtmltopdf" :
remote: -----> Installing wkhtmltopdf_0.12.5-1build1_amd64.deb
The error :
remote: ../codon/tmp/cache/go-path/pkg/mod/github.com/adrg/go-wkhtmltopdf#v0.2.2/converter.go:7:10: fatal error: wkhtmltox/pdf.h: No such file or directory
remote: 7 | #include <wkhtmltox/pdf.h>
remote: | ^~~~~~~~~~~~~~~~~
remote: compilation terminated.
Is there someone with similar experience ? Is it possible that for Go the installed package is simply not available without some additional manipulations ?
Is anyone able to tell me why this build has failed on heroku?
I've tried finding substitute packages and tidying the mod file, even deleting it and redoing it.
here is my build log
Overview Resources Deploy Metrics Activity Access Settings
Activity Feed Build LogID f8e9d5ce-0d8f-4e8e-8b2a-661c4d1f68f7
-----> Building on the Heroku-20 stack
-----> Go app detected
-----> Fetching stdlib.sh.v8... done
----->
Detected go modules via go.mod
----->
Detected Module Name: github.com/xxxxxx/xxxxxx-xxxxxx
----->
!! The go.mod file for this project does not specify a Go version
!!
!! Defaulting to go1.12.17
!!
!! For more details see: https://devcenter.heroku.com/articles/go-apps-with-modules#build-configuration
!!
-----> Using go1.12.17
-----> Determining packages to install
Detected the following main packages to install:
github.com/xxxxxx/xxxxxx-xxxxxx
-----> Running: go install -v -tags heroku github.com/xxxxxx/xxxxxx-companion
github.com/vektah/gqlparser/v2/ast
github.com/agnivade/levenshtein
github.com/mitchellh/mapstructure
github.com/vektah/gqlparser/v2/gqlerror
github.com/99designs/gqlgen/graphql
# github.com/99designs/gqlgen/graphql
../codon/tmp/cache/go-path/pkg/mod/github.com/99designs/gqlgen#v0.13.0/graphql/error.go:21:5: undefined: errors.As
github.com/99designs/gqlgen/graphql/errcode
github.com/vektah/gqlparser/v2/lexer
github.com/hashicorp/golang-lru/simplelru
github.com/vektah/gqlparser/v2/parser
github.com/hashicorp/golang-lru
github.com/gorilla/websocket
github.com/vektah/gqlparser/v2/validator
github.com/99designs/gqlgen/graphql/playground
github.com/xxxxxx/xxxxxx-xxxxxx/graph/model
github.com/xxxxxx/xxxxxx-xxxxxx/database
github.com/99designs/gqlgen/graphql/introspection
github.com/vektah/gqlparser/v2/validator/rules
github.com/go-sql-driver/mysql
github.com/vektah/gqlparser/v2
! Push rejected, failed to compile Go app.
! Push failed
Here is my go.mod file:
module github.com/xxxxxx/xxxxxx-xxxxxx
go 1.15
require (
github.com/99designs/gqlgen v0.13.0
github.com/go-sql-driver/mysql v1.5.0
github.com/hashicorp/golang-lru v0.5.1 // indirect
github.com/mitchellh/mapstructure v0.0.0-20180220230111-00c29f56e238 // indirect
github.com/stretchr/testify v1.5.1 // indirect
github.com/vektah/gqlparser/v2 v2.1.0
gopkg.in/yaml.v2 v2.2.8 // indirect
)
I'm at a complete loss, I suspect it has to do with an incorrect version, but the build log doesn't give me much to go on. How can I diagnose this kind of issue in the future?
Thank you.
You could add a directive // +heroku goVersion go1.15 in your go.mod file.
module somemodule
// +heroku goVersion go1.15
go 1.15
require (
// ...
)
Then it should look like this.
remote: Detected go modules via go.mod
remote: ----->
remote: Detected Module Name: somemodule
remote: ----->
remote: -----> New Go Version, clearing old cache
remote: -----> Installing go1.15
Documentation: https://github.com/heroku/heroku-buildpack-go#go-module-specifics
Go Module Specifics
You can specify specific package spec(s) via the go.mod file's // +heroku install directive (see below).
// +heroku goVersion <version>: the major version of go you would
like Heroku to use when compiling your code. If not specified this
defaults to the buildpack's [DefaultVersion].
Coming back to mark this one complete, I figured out that by specifying in the go mod file
// +heroku goVersion go1.15
Go buildback supports arbitrary comments specifiying versioning before build.
https://github.com/heroku/heroku-buildpack-go#go-module-specifics
Thank you as well to user #JimB for pointing me in the right direction.
I am trying to install chaincode. I used cid package inside my chaincode When I try to install chaincode, I got the following error:
cannot load package:
package github.com/hyperledger/fabric/core/chaincode/lib/cid: cannot find package "github.com/hyperledger/fabric/core/chaincode/lib/cid" in any of:
/opt/go/src/github.com/hyperledger/fabric/core/chaincode/lib/cid (from $GOROOT)
/opt/gopath/src/github.com/hyperledger/fabric/core/chaincode/lib/cid (from $GOPATH)
I have used glide tool( here https://github.com/Masterminds/glide) to fix it,
now i see another error that I couldn't fix which is:
Error: could not assemble transaction, err proposal response was not successful, error code 500, msg error starting container: error starting container: Failed to generate platform-specific docker build: Error returned from build: 1 "chaincode/input/src/github.com/chaincode/vendor/github.com/hyperledger/fabric/core/chaincode/lib/cid/cid.go:29:2: cannot find package "github.com/hyperledger/fabric/common/attrmgr" in any of:
/chaincode/input/src/github.com/chaincode/vendor/github.com/hyperledger/fabric/vendor/github.com/hyperledger/fabric/common/attrmgr (vendor tree)
/chaincode/input/src/github.com/chaincode/vendor/github.com/hyperledger/fabric/common/attrmgr
/opt/go/src/github.com/hyperledger/fabric/common/attrmgr (from $GOROOT)
/chaincode/input/src/github.com/hyperledger/fabric/common/attrmgr (from $GOPATH)
/opt/gopath/src/github.com/hyperledger/fabric/common/attrmgr
Any suggestion؟
Install the fabric dependency in your GOPATH, go get -u github.com/hyperledger/fabric
I am trying to add an external package to my go smartcontract (for installation , I ran : go get github.com/stripe/stripe-go) . I then imported files stripe "github.com/stripe/stripe-go" and charge "github.com/stripe/stripe-go/charge" , in my smartcontract (https://github.com/stripe/stripe-go). However, when I try to bring up my chaincode , I am getting the error :
Error: Error getting chaincode code chaincode: Error getting chaincode package bytes: Error obtaining dependencies for github.com/stripe/stripe-go: : failed with error: "exit status 1"
can't load package: package github.com/stripe/stripe-go: cannot find package "github.com/stripe/stripe-go" in any of:
/opt/go/src/github.com/stripe/stripe-go (from $GOROOT)
/opt/gopath/src/github.com/stripe/stripe-go (from $GOPATH)
I tried adding the package through govendor (http://hyperledger-fabric.readthedocs.io/en/release-1.0/Style-guides/go-style.html) , but that also is not working .
Request you all to please hep me on this . Thanks in advance.
I had the similar issue.
Govendor worked for me:
error getting chaincode package bytes: Error obtaining dependencies for github.com/go-ozzo/ozzo-validation/is
govendor add github.com/go-ozzo/ozzo-validation/is
govendor update +v
go build
And result was good:
Chaincode is installed on remote peer PEER2
UPDATE:
If you have a problem with vendor packages setup, here you go:
create folder vendor in project root directory with empty valid json file (vendor.json)
run command govendor add +external from root directory
you can also update all dependencies with update command.