-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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: gx-go uw everything #5435
gx: gx-go uw everything #5435
Conversation
@Stebalien #4831 has not been commented on in a while. Was there some discussion on this issue via out of band means? Or is this mostly a proof-of-concept? |
For now, this just rewrites in go-ipfs itself (and doesn't even bother rewriting). While a bit annoying, I consider this the lesser of two evils (compared to keeping the files in the rewritten state). |
I picked this up because I got tired of running into random conflicts when rebasing. |
@Stebalien while I mostly agree, I don't want to rush this p.r. in. I can see a lot of ways this can break things and, at least in my view, this needs some vetting before it lands. |
Of course! CI doesn't even pass yet. However, I don't want to just sit on our asses as is our usual MO when it comes to hard choices with no good solutions; I submitted this PR to get the ball rolling again. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, Please!
Can you separate the non-rewrite/non-extraction changes into separate commits so it's easier to review?
I would be so happy about this being able to land. ❤️ |
yeah, I was just a bit lazy |
Extracted here: #5440 |
I see what you mean. Fixed. |
Yeah, I meant separate commits, not PRs. Will review once ci passes |
@Stebalien updates on this? |
License: MIT Signed-off-by: Steven Allen <steven@stebalien.com>
And add a dummy package that refuses to build unless we're using gx. fixes #4831 License: MIT Signed-off-by: Steven Allen <steven@stebalien.com>
The alternative is to just switch to the lockfile approach. However, we'll then need to modify |
License: MIT Signed-off-by: Steven Allen <steven@stebalien.com>
However, I think we should go with this for now. Regardless, we're going to leave the paths unrewritten so any changes will be small changes to the build system. This is a step in the right direction. |
About the same time this lands we need to modify gitcop to check that they are no rewritten paths, it will be very easy to screw this up. In particular it is still possible for "gx rewrite --fix" to miss some paths. |
mk/gx.mk
Outdated
@@ -2,6 +2,7 @@ gx-path = gx/ipfs/$(shell gx deps find $(1))/$(1) | |||
|
|||
gx-deps: | |||
gx install --global | |||
gx-go rw |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think having the build process modify files in place is a very good idea. The in-place rewrite of the deps in go dependencies already causes me grief in that I have to have emacs automatically reread the files, which doesn't always work. With go deps, I can at control when it is done, here it will be done as part of make build
. It can also cause other problems, for example if you have unsaved changes.
Maybe we should copy everything to a temp dir and build and rewrite from that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the other side, packages on github might not be compatible at the time so you might end up rewriting either way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Kubuxu I think you misunderstand by idea was to (at least by default) not rewrite deps in place but put the rewritten files into a temp directory and build that. This way no inplace modifications are necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am really sorry for blocking this, but I think this needs some careful though before we push this though. It has the potential to break a lot of things.
In addition I see the current changes breaking one of my workflows.
mk/gx.mk
Outdated
@@ -2,6 +2,7 @@ gx-path = gx/ipfs/$(shell gx deps find $(1))/$(1) | |||
|
|||
gx-deps: | |||
gx install --global | |||
gx-go rw |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rewriting as part of the build process will make my workflow of working with a partly rewritten tree impossible or at least difficult.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A quick fix for this might be to provide an official way to build without automatically calling the gx-deps
target.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kevina Could describe how you work with a partly rewritten tree? I can't think of a good use case for this, I am not saying there isn't a good use case for it, I just can't think of it 🙂
Devs can run `make lock` to switch to using a lockfile. Then-on, `make deps` will use this instead of the `package.json`. License: MIT Signed-off-by: Steven Allen <steven@stebalien.com>
@kevina: I've added support for gx "lockfiles". If you run
This way, normal builds (ipfs/distributions) still work but devs don't have to deal with this. |
|
License: MIT Signed-off-by: Steven Allen <steven@stebalien.com>
@Stebalien I will need to test this out later today to familiarize myself with how this will work. |
@lanzafame I used a partly rewritten tree when working on a @Stebalien how will such a process work now? |
@kevina assuming you're using the |
@Stebalien I will need to try this out myself later today to make sense of it all. Since this is a major change I hope you can wait for me. Thanks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See inline comments.
@@ -2,8 +2,7 @@ gx-path = gx/ipfs/$(shell gx deps find $(1))/$(1) | |||
|
|||
# Rebuild the lockfile iff it exists. | |||
gx-deps: $(wildcard gx-lock.json) | |||
gx install --global | |||
if test -e gx-lock.json; then gx-go rw --fix && gx lock-install; else rm -rf vendor && gx-go rw; fi | |||
if test -e gx-lock.json; then gx-go rw --undo && gx lock-install; else rm -rf vendor && gx install --global && gx-go rw; fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would move the dependency installation to the lock
target. Reinstalling the exact same dependency here is redundant. Also, I may be mistaken, but I think it will cause problems if we do as you suggest and (a) remove the vender directory or (b) replace the symlinks in the vendor directory with symlinks to packages in your go path.
Also removing thevender
directory without promoting the user seams dangerous (there might be stuff in there not related to gx) so it seams that it would be a better idea to just abort if the vender
directory exists and let the user deal with it. For clean build this should not be a factor so I don't think this will break anything.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would move the dependency installation to the lock target. Reinstalling the exact same dependency here is redundant.
The lock target just generates the lockfile, nothing more. gx-deps
is the "install the gx-deps" target so it's definitely the right place to put this.
Also, I may be mistaken, but I think it will cause problems if we do as you suggest and (a) remove the vender directory or (b) replace the symlinks in the vendor directory with symlinks to packages in your go path.
Replacing the symlink definitely works.
Removing the entire vendor directory doesn't quite work (intentionally) due to the github.com/gxed/go-require-gx
import in cmd/ipfs/ipfs.go
. However, if you remove that it should work as long as none of our downstream packages have made breaking changes.
Also removing the vender directory without promoting the user seams dangerous (there might be stuff in there not related to gx) so it seams that it would be a better idea to just abort if the vender directory exists and let the user deal with it.
In general, vendor directories are managed by whatever dependency management system is in-place, not manually by the user. I don't expect users will be surprised.
I'm worried that not removing it will lead to even more confusion. If the user does a gx-go uw
, they'll end up using the "locked" deps instead of the normal ones.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The lock target just generates the lockfile, nothing more.
My concern is that gx-deps
target is run automatically by the build
and install
target. I never liked that, and now it may do undesirable things. I would be happier if there was a way to tell the build system not to rerun the gx-deps
target on make build
or make install
for the cases when you are doing something slightly unusual and know what you are doing. Otherwise if this becomes an issue I may end up having to hack the Makefile.
Replacing the symlink definitely works.
So if you replace the symbolic link, running the gx-deps
target won't overright the content that is already in there?
In general, vendor directories are managed by whatever dependency management system is in-place, not manually by the user. I don't expect users will be surprised.
Okay, I withdraw my objection.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So if you replace the symbolic link, running the gx-deps target won't overright the content that is already in there?
It should have worked but apparently we need to fix a bug in gx first.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
License: MIT Signed-off-by: Steven Allen <steven@stebalien.com>
We're probably going to go with go modules instead of this, at this point. |
fixes #4831