heroku / heroku-buildpack-go

Heroku Go Buildpack

Home Page:https://devcenter.heroku.com/categories/go

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Push rejected, failed to compile Go app.

weeebdev opened this issue · comments

image

image

go.mod

module repo_name

go 1.15

require (
	github.com/gorilla/mux v1.8.0
	github.com/joho/godotenv v1.3.0
	go.mongodb.org/mongo-driver v1.4.6
)

Could you say me why it doesn't work? Dockerfile, heroku.yml, Makefile and Procfile were copied from https://github.com/heroku/go-getting-started

Thanks for the report.

The getting started app could use an update. I do notice that in the go.mod you shared, there's a go 1.15 line but no corresponding // +heroku goVersion go1.15 line. This means the buildpack will use the default version, which is still 1.12.

Would you be up for trying to add the goVersion line? Something like:

// +heroku goVersion go1.15

module repo_name

go 1.15

require (
	github.com/gorilla/mux v1.8.0
	github.com/joho/godotenv v1.3.0
	go.mongodb.org/mongo-driver v1.4.6
)

The buildpack should not hide the error here, that is something to be improved.

@danp
I did, but it still doesn't want to install it. I tried without getting started app template, just using go mod, but it still doesn't want to deploy. I asked a question on StackOverflow, so let me copy it here:


I tried to deploy a Go app from monorepo with the help of go mod, but it didn't help. Then, I moved subtree to another repo, but even here it shows me the same error. It seems to me that it cannot find packages, but when I clone and run the repo, it runs. The error:
-----> Building on the Heroku-20 stack
-----> Go app detected
-----> Fetching jq... done
-----> Fetching stdlib.sh.v8... done
-----> 
       Detected go modules via go.mod
-----> 
       Detected Module Name: repo_name
-----> 
-----> New Go Version, clearing old cache
-----> Installing go1.15.8
-----> Fetching go1.15.8.linux-amd64.tar.gz... done
-----> Determining packages to install
 !     Push rejected, failed to compile Go app.
 !     Push failed

File path:

monorepo
├──backend
	├── README.md
	├── go.mod
	├── go.sum
	├── main.go
	├── mongoConnector
	│   └── db.go
	└── vendor
		├── github.com
		├── go.mongodb.org
		├── golang.org
		└── modules.txt

go.mod:

module repo_name

go 1.15

require (
	github.com/gorilla/mux v1.8.0
	github.com/joho/godotenv v1.3.0
	go.mongodb.org/mongo-driver v1.4.6
)

The steps, that I took:

  • Move server code to monorepo/backend dir
  • Run go mod init
  • Run go mod vendor
  • Push it to git repo
  • Push the subtree of prefix backend to Heroku remote
  • Heroku rejects the push

Thanks. Checking: did you try adding // +heroku goVersion go1.15 to your go.mod? The most recent example you gave did not include it.

Could you also please clarify what you mean by:

Push the subtree of prefix backend to Heroku remote

The git commands you're running would be helpful.

Thanks!

@danp Let me explain briefly.
I have a monorepo with the following structure:

monorepo
└──backend
	├── README.md
	├── go.mod
	├── go.sum
	├── main.go
	├── mongoConnector
	│   └── db.go
	└── vendor
		├── github.com
		├── go.mongodb.org
		├── golang.org
		└── modules.txt

I need to deploy it to Heroku, but then I faced some issues with deploying a monorepo to Heroku. So I pushed backend folder
to another repo using git subtree push --prefix backend remote main --squash and from here I tried to deploy it via Heroku's deploy, but it shows me this:

-----> Building on the Heroku-20 stack
-----> Go app detected
-----> Fetching jq... done
-----> Fetching stdlib.sh.v8... done
-----> 
      Detected go modules via go.mod
-----> 
      Detected Module Name: repo_name
-----> 
-----> New Go Version, clearing old cache
-----> Installing go1.15.8
-----> Fetching go1.15.8.linux-amd64.tar.gz... done
-----> Determining packages to install
!     Push rejected, failed to compile Go app.
!     Push failed

Thanks. And I realize now that you are getting go1.15.8 based on the build output.

And double checking: if you run go mod vendor again in the backend directory, does vendor/modules.txt change?

I was able to take https://github.com/heroku/go-getting-started, follow these steps, and then do a successful push:

  1. clone https://github.com/heroku/go-getting-started somewhere and cd into it
  2. mkdir backend
  3. git mv Procfile go* main.go static templates vendor backend
  4. cd backend
  5. replace go 1.12 in go.mod with go 1.15
  6. add // +heroku goVersion go1.15 to go.mod
  7. run go mod vendor
  8. commit results
  9. git subtree push --prefix backend heroku main --squash

@danp do I need to have static folder?

@danp now it shows this:

-----> Building on the Heroku-20 stack
-----> Go app detected
-----> Fetching jq... done
-----> Fetching stdlib.sh.v8... done
-----> 
       Detected go modules via go.mod
-----> 
       Detected Module Name: github.com/heroku/go-getting-started
-----> 
-----> New Go Version, clearing old cache
-----> Installing go
 !!    
 !!    The requested file (go.linux-amd64.tar.gz) is unknown to the buildpack!
 !!    
 !!    The buildpack tracks and validates the SHA256 sums of the files
 !!    it uses. Because the buildpack doesn't know about the file
 !!    it likely won't be able to obtain a copy and validate the SHA.
 !!    
 !!    To find out more info about this error please visit:
 !!        https://devcenter.heroku.com/articles/unknown-go-buildack-files
 !!    
 !     Push rejected, failed to compile Go app.
 !     Push failed

I am sorry, but could you investigate my repo? I think, I'm doing something wrong. Thank you!
https://github.com/Masters-and-Abu/Tolqyn-backend

In go.mod, can you please try changing this:

// +heroku goVersion go 1.15

to this:

// +heroku goVersion go1.15

(note space removed between go and 1.15)

@danp I don't know whether it may be a solution, but I finally deployed it via godep. Followed instructions from the official docs https://devcenter.heroku.com/articles/go-dependencies-via-godep

In go.mod, can you please try changing this:

// +heroku goVersion go 1.15

to this:

// +heroku goVersion go1.15

(note space removed between go and 1.15)

It worked!