tools / godep

dependency tool for go
http://godoc.org/github.com/tools/godep
BSD 3-Clause "New" or "Revised" License
5.55k stars 455 forks source link

Godep Bluemix Cloud Foundry #534

Closed olliephillips closed 7 years ago

olliephillips commented 7 years ago

I'm seeing an issue with Godep on Bluemix CF. godep save gives me godeps.json as below:-

{
    "ImportPath": "github.com/olliephillips/test",
    "GoVersion": "go1.7.5",
    "GodepVersion": "v78",
    "Deps": [
        {
            "ImportPath": "github.com/olliephillips/gotcha",
            "Rev": "e587e430850ff8dbefe2eeab643fc87b52d6e256"
        }
    ]
}

As is, I cannot push the app to Bluemix with this file. The errors are Bluemix related, and not very informative.

After a long process of elimination, I've found I need to modify godeps.json to match the application name in the appprocfile in order to be able to push the app. Note the first line.

{
    "ImportPath": "gohelloworld",
    "GoVersion": "go1.7.5",
    "GodepVersion": "v78",
    "Deps": [
        {
            "ImportPath": "github.com/olliephillips/gotcha",
            "Rev": "e587e430850ff8dbefe2eeab643fc87b52d6e256"
        }
    ]
}

I'm using the CF Go build pack here https://github.com/cloudfoundry/go-buildpack.git

godep version output is godep v78 (darwin/amd64/go1.7.4)

Am I doing something wrong, is this an issue with Godep or Bluemix or just how it is. I'm happy to modify godeps.json every time I run godep save but if there's a fix or workaround that would be great?

freeformz commented 7 years ago

This seems wrong to me on BlueMix's part.

The ImportPath recorded is the package name of the project you are saving dependencies for. If you send the code to them and they use the app name as the package name then code that uses sub packages will break as the names are different. For instance, your application is located in the package named github.com/olliephillips/test, which is stored in $GOPATH/src/github.com/olliephillips/test. Let's say github.com/olliephillips/test imports github.com/olliephillips/test/lib/stuff but Bluemix actually puts the code in $GOPATH/src/gohelloworld when it's compiling the software. The import will break unless BlueMix also looks through your code and fixes up imports. And even then, panics, traces and error messages will also be changed.

Maybe Bluemix is doing something different, IDK, but this seems strange to me.

PS: This isn't really a bug with godep, so I'm going to close this, sorry. If Bluemix support would like to weigh in please have them re-open this issue. Thx.

olliephillips commented 7 years ago

Yes, thanks. I'm trying to raise with Bluemix. Looking back through old repos that I have had working on Bluemix Cloud Foundry I can see that full package path has always been stored in the ImportPath var, so it has to be something changed with Bluemix. Thanks for taking a look at this though. I'll update if/when get answer.

olliephillips commented 7 years ago

I'm a bit further on with this. Nothing from Bluemix, but it appears that this could be down to the inclusion of `test in my package directory.

for example godeps.json:

{
    "ImportPath": "github.com/olliephillips/test",
    "GoVersion": "go1.7.5",
...

and Procfile:

web: test

Will NOT push

Build godeps.json from cftest directory, such that test is replaced with cftest and replace test in Procfile with cftest and it pushes just fine.

So this is nothing to do with Godeps, and all the problems appear to be down to a poor choice of directory name when setting this up to test.