Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Heroku local is not using my latest code. Why?

I'm trying to get a very simple database-backed golang heroku app working as a hello world.

The deployed Heroku version of my app is working perfectly, and if I manually test it locally, it works perfectly, but heroku local is stubbornly using an old version of my code. Specifically:

$ heroku local
forego | starting web.1 on port 8080

works, but unexpectedly serves an older version of the app. On the other hand, this:

$ go run web.go

and this:

$ git push heroku master
Everything up-to-date
$ heroku open

both serve what I expect, which is the latest version of my code.

This is really confusing me. I've read all the documentation and double checked the state of everything, and can't find anything that indicates what is going on, or which could cause it.

My best guess are that heroku local is using a compiled slug from somewhere that is not getting updated.

like image 773
WolfTivy Avatar asked Mar 22 '16 22:03

WolfTivy


1 Answers

The problem is that golang is a compiled language, and heroku local just uses the last build and does not initiate the rebuild on its own. The fix is to simply remember to compile before running heroku local:

$ go install

It is easy to forget this if you use go run web.go for testing, because that doesn't need a recompile, and heroku itself automatically does the build, so you could get away with never running go install until you try to use heroku local.

(I actually figured this out as soon as I had the whole question written out, but I figured I should post anyways for future reference.)

like image 192
WolfTivy Avatar answered Oct 21 '22 16:10

WolfTivy