dkulchenko / bunch

npm-like tool for managing Go dependencies
MIT License
79 stars 13 forks source link

Bunchfile.lock versions not being respected during rebuild #25

Closed tamird closed 9 years ago

tamird commented 9 years ago

consider the following Bunchfile:

github.com/cockroachdb/cockroach-prod !self
github.com/awslabs/aws-sdk-go/service/ec2
github.com/awslabs/aws-sdk-go/service/elb

and the following Bunchfile.lock:

{
    "github.com/awslabs/aws-sdk-go/service/ec2": "deaa78b60cfd55045252c52f4f7840c6d697c491",
    "github.com/awslabs/aws-sdk-go/service/elb": "deaa78b60cfd55045252c52f4f7840c6d697c491"
}

Also consider:

$ pwd && git rev-parse head
/Users/tamird/src/go/src/github.com/cockroachdb/cockroach-prod/.vendor/src/github.com/awslabs/aws-sdk-go
29717a72a2fc649e790ce97dc2c4d96e32950844

In other words, the checked-out ref on disk does not match the ref specified in Bunchfile.lock. Now, consider the output of various bunch commands:

$ bunch --verbose install
skipping github.com/cockroachdb/cockroach-prod, up to date
skipping github.com/awslabs/aws-sdk-go/service/ec2, up to date
skipping github.com/awslabs/aws-sdk-go/service/elb, up to date
$ bunch --verbose rebuild
installing github.com/cockroachdb/cockroach-prod ...
successfully installed github.com/cockroachdb/cockroach-prod

installing github.com/awslabs/aws-sdk-go/service/ec2 ...
  - setting version of github.com/awslabs/aws-sdk-go/service/ec2 to  (resolved as master) ... done
  - building package github.com/awslabs/aws-sdk-go/service/ec2 ... done
  - installing package github.com/awslabs/aws-sdk-go/service/ec2 ... done
successfully installed github.com/awslabs/aws-sdk-go/service/ec2

installing github.com/awslabs/aws-sdk-go/service/elb ...
  - setting version of github.com/awslabs/aws-sdk-go/service/elb to  (resolved as master) ... done
  - building package github.com/awslabs/aws-sdk-go/service/elb ... done
  - installing package github.com/awslabs/aws-sdk-go/service/elb ... done
successfully installed github.com/awslabs/aws-sdk-go/service/elb

Am I doing something wrong? cc @MBerhault

tamird commented 9 years ago

@dkulchenko the title should be "Bunchfile.lock versions not being respected during install"

dkulchenko commented 9 years ago

Copied your Bunchfile/.lock verbatim into a test dir:

daniilk:~/test ∞ bunch i
setting up github.com/cockroachdb/cockroach-prod link ... done
fetching github.com/awslabs/aws-sdk-go/service/ec2 ... done
fetching github.com/awslabs/aws-sdk-go/service/elb ... done
installing github.com/awslabs/aws-sdk-go/service/ec2 ... done
installing github.com/awslabs/aws-sdk-go/service/elb ... done
daniilk:~/test ∞ (cd .vendor/src/github.com/awslabs/aws-sdk-go; git rev-parse HEAD)
deaa78b60cfd55045252c52f4f7840c6d697c491
daniilk:~/test ∞

What you're running is a rebuild (which is just an alias for bunch update). An update forces a checkout of the latest version and will ignore pinned versions in the Bunchfile.lock, exactly as rubygems and npm behave.

But now that I think about it, a "rebuild" should probably not have that behavior, only an "update" proper should. Done in 3d071d52f.

tamird commented 9 years ago

Your change fixed bunch rebuild, but bunch install is still broken.

dkulchenko commented 9 years ago

Your change fixed bunch rebuild, but bunch install is still broken.

How so? My comment above shows version pinning during an install working perfectly fine with your provided Bunchfile.

tamird commented 9 years ago

Right, install does the right thing the first time - if you create a drift between what's in Bunchfile.lock and what's on disk (as would happen when someone updates a project's dependencies), bunch install will happily report that everything is up to date.

dkulchenko commented 9 years ago

I'm not seeing it. Set a new version in the Bunchfile.lock:

daniilk:~/test ∞ cat Bunchfile.lock
{
    "github.com/awslabs/aws-sdk-go/service/ec2": "b7d25c610b45f96dd22ed98469a0a05b85d7a54f",
    "github.com/awslabs/aws-sdk-go/service/elb": "b7d25c610b45f96dd22ed98469a0a05b85d7a54f"
}
daniilk:~/test ∞ bunch i
fetching github.com/awslabs/aws-sdk-go/service/ec2 ... done
installing github.com/awslabs/aws-sdk-go/service/ec2 ... done
daniilk:~/test ∞ (cd .vendor/src/github.com/awslabs/aws-sdk-go; git rev-parse HEAD)
b7d25c610b45f96dd22ed98469a0a05b85d7a54f
daniilk:~/test ∞

And changing it back...

daniilk:~/test ∞ cat Bunchfile.lock
{
    "github.com/awslabs/aws-sdk-go/service/ec2": "deaa78b60cfd55045252c52f4f7840c6d697c491",
    "github.com/awslabs/aws-sdk-go/service/elb": "deaa78b60cfd55045252c52f4f7840c6d697c491"
}
daniilk:~/test ∞ bunch i
fetching github.com/awslabs/aws-sdk-go/service/ec2 ... done
installing github.com/awslabs/aws-sdk-go/service/ec2 ... done
daniilk:~/test ∞ (cd .vendor/src/github.com/awslabs/aws-sdk-go; git rev-parse HEAD)
deaa78b60cfd55045252c52f4f7840c6d697c491
daniilk:~/test ∞
tamird commented 9 years ago
$ go get -u github.com/dkulchenko/bunch
$ cat Bunchfile.lock
{
    "github.com/awslabs/aws-sdk-go/service/ec2": "deaa78b60cfd55045252c52f4f7840c6d697c491",
    "github.com/awslabs/aws-sdk-go/service/elb": "deaa78b60cfd55045252c52f4f7840c6d697c491"
}
$ (cd .vendor/src/github.com/awslabs/aws-sdk-go; git rev-parse HEAD)
29717a72a2fc649e790ce97dc2c4d96e32950844
$ bunch i
up to date (use 'bunch update' to force update)
$ (cd .vendor/src/github.com/awslabs/aws-sdk-go; git rev-parse HEAD)
29717a72a2fc649e790ce97dc2c4d96e32950844
$ bunch --verbose i
skipping github.com/cockroachdb/cockroach-prod, up to date
skipping github.com/awslabs/aws-sdk-go/service/ec2, up to date
skipping github.com/awslabs/aws-sdk-go/service/elb, up to date
$ (cd .vendor/src/github.com/awslabs/aws-sdk-go; git rev-parse HEAD)
29717a72a2fc649e790ce97dc2c4d96e32950844
tamird commented 9 years ago

Ah, here's the reason:

$ (cd .vendor/src/github.com/awslabs/aws-sdk-go; git branch)
* master 29717a7 Updated service examples to do nil check before using err
$ (cd .vendor/src/github.com/awslabs/aws-sdk-go; git status)
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working directory clean
$ bunch i
up to date (use 'bunch update' to force update)
$ (cd .vendor/src/github.com/awslabs/aws-sdk-go; git checkout head^)
Note: checking out 'head^'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

  git checkout -b <new-branch-name>

HEAD is now at 38194d5... aws/awserr: Cleaned up Error examples
$ (cd .vendor/src/github.com/awslabs/aws-sdk-go; git status)
HEAD detached at 38194d5
nothing to commit, working directory clean
$ bunch i
fetching github.com/awslabs/aws-sdk-go/service/ec2 ... done
installing github.com/awslabs/aws-sdk-go/service/ec2 ... done

So when things are sitting on master, bunch gets confused and decides they're all up to date.

dkulchenko commented 9 years ago

Good catch, thanks! Should be fixed in 75101f3.

tamird commented 9 years ago

Works. Thanks.