Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gx-go rewrite and undo should yield the same result #663

Closed
phritz opened this issue Jul 26, 2018 · 4 comments
Closed

gx-go rewrite and undo should yield the same result #663

phritz opened this issue Jul 26, 2018 · 4 comments

Comments

@phritz
Copy link
Contributor

phritz commented Jul 26, 2018

  1. Check out master
  2. Run gx-go rewrite --undo
  3. Run gx-go rewrite
  4. Notice you now have diffs

This is the result of dupe dependencies. You can see dups by running gx deps dupes. The task here is to update our deps, or the deps of our deps, so that the packages that use a different version in step 4 above use the same version. That is, update our depds or our deps deps such that undo and then rewrite again is a nop.

This is vaguely related to #599 as it was noticed in #643.

@ZenGround0
Copy link
Contributor

ZenGround0 commented Aug 1, 2018

@phritz suggested I share a related gx-go rewrite problem here.

After #695 was merged I experienced several problems getting my local setup to build master.

After running smartdeps I saw build errors stemming from non-gxed packages that the project imports as gx packages. These build errors were all expected from having improperly versioned packages interacting. The root issue was that a gx package was being improperly rewritten so that these github.com dvc imports were leaking into the build dependencies.

With help from @whyrusleeping I realized that my version of gx-go was compiled with the wrong version of go. This led to source files with type aliases (type x = y) not being rewritten. I observed that after rebuilding gx-go and rerunning rewrite many more github dvc imports were correctly rewritten to gx than before.

After rebuilding gx-go and rewriting the filecoin project I still had build errors of the same type as before. Upon closer inspection gx-go rewrite was not actually rewriting certain github dvc imports to gx imports. Specifically the libp2p/go-libp2p/libp2p.go's github.com/libp2p/go-libp2p/config import and go-libp2p/libp2p/config's github.com/libp2p/go-libp2p/p2p/host/basic import were not being rewritten. Attempting to rewrite the go-libp2p package directly did not change anything. I rewrote both imports manually and the many build errors caused by the github import paths disappeared.

Finally I was still left with a few build errors due to the gxed go-reuseport dependency: go-sockaddr not being properly rewritten. Curiously I could not resolve the errors by rewriting from go-filecoin but could resolve them by running gx-go rewrite within the gxed go-sockaddr/net dependency.

A few things stood out about the imports that could not be rewritten as expected. All such imports resided in a file that included a type alias and therefore was not rewritten properly when I was using the out of date gx-go, also all imports existed within subpackages of a gxed dependency.

I am not sure of the exact mechanism behind gx-go's inability to rewrite properly upon being updated to golang 1.10, however the takeaway is that rewriting with an older version of gx-go puts the repos in a bad state such that when running an updated gx-go rewrite things will not be rewritten properly. To reproduce this issue you should downgrade to a gx-go compiled in go version 1.9, and freshly download the go-filecoin repo.

For completeness here is the output of gx deps dupes in the version of filecoin where the above behavior was observed:

package go-net imported as both QmTEmsyNnckEq8rEfALfdhLHjrEHGoSGFDrAYReuetn7MC and QmRvYNctevGUW52urgmoFZscT6buMKqhHezLUS64WepGWn
package go-text imported as both Qmaau1d1WjnQdTYfRYfFVsCS97cgD8ATyrKuNoEfexL7JZ and QmVcxhXDbXjNoAdmYBWbY1eU67kQ8eZUHjG4mAYZUtZZu3
package sys imported as both QmVGjyM9i2msKvLXwh9VosCTgP4mL91kC7hDmqnwTTx6Hu and QmPXvegq26x982cQjSfbTvSzZXn7GiaMwhhVPHkeTEhrPT
package go-ipld-cbor imported as both QmSyK1ZiAP98YvnxsTfQpb669V2xeTHRbG4Y6fgKS3vVSd and QmWrbExtUaQQHjJ8FVVDAWj5o1MRAELDUV3VmoQsZHHb6L

@whyrusleeping
Copy link
Member

set the go version in the package.json like we do in ipfs here: https://github.com/ipfs/go-ipfs/blob/master/package.json#L7

@whyrusleeping
Copy link
Member

As for the original issue, i fixed almost all of these. Until we can get the cbor updates pushed through, a relatively simple solution is just running a sed over the whole directory replacing QmWrbExtUaQQHjJ8FVVDAWj5o1MRAELDUV3VmoQsZHHb6L with QmSyK1ZiAP98YvnxsTfQpb669V2xeTHRbG4Y6fgKS3vVSd

@phritz
Copy link
Contributor Author

phritz commented Mar 27, 2019

we are moving to go modules, no longer relevant

@phritz phritz closed this as completed Mar 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants