-
Notifications
You must be signed in to change notification settings - Fork 570
Vendoring gopherjs code causes generated js to fail #415
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
Comments
Thanks for reporting. I'm guessing it happens because the |
Quick question related to this -- if I vendor the stdlib overrides(gopherjs/compiler/natives/...) into vendor/github.com/gopherjs/gopherjs will those be used instead of looking for them in $GOPATH ? |
It will always use those form the GOPATH. Vendoring in this context not possible on a theoretical level, unless we come up with some special vendoring rule. E.g. when GopherJS wants to compile And yes, the |
I want to vendor all of gopherjs and my build process will build gopherjs from the vendored version. Then there will never be mismatched versions :) |
I guess our build process could take the vendored version and copy it back into the GOPATH during the build but that seems bad to me. |
@neelance As @benechols-wf notes, one hits that bug even when one wants to simply vendor the whole of github.com/gopherjs/gopherjs into a project (which should be a pretty common use case), which would not make github.com/gopherjs/gopherjs/js out of sync wrt to github.com/gopherjs/gopherjs. So it should definitely be fixed imho. |
Because it makes full integration with gopherjs impossible (without polluting the user's GOPATH), as long as gopherjs/gopherjs#415 is not fixed. Also it is kind of antithetical with the point of make.go anyway. We still rely on CAMLI_MAKE_USEGOPATH for the integration tests that run make.go to know that they shouldn't recursively create another temp GOPATH (when they're already in such a temp dir, because they're started through devcam test). Change-Id: Icc6af46ec5976fdf08e9b8bf4249e307a15499cf
This will probably still run into #462. Working on it. |
@neelance jsyk, I was hoping f627518 and 2e16c68 had fixed this , so I've just retried, and it still does not seem to work for me. Layout is like this:
using gopherjs as:
and getting this error:
So it seems like it's still not looking for github.com/gopherjs/gopherjs/js in the vendor dir of my project. |
* Determines whether there is an import path to a vendored version of gopherjs * If so, updates all import paths to gopherjs in generated code to use the vendored version * Updates runtime/runtime.go to use a string constant for its static reference to the gopherjs import path * Adds logic to update the string constant to be the vendored path during generation Fixes gopherjs#415
I ran into this as well and was interested in fixing this so made a fix locally. It can still use some iteration, but wanted to verify that the general approach is acceptable. The main issue seems to be resolving the
This approach solves all of the import resolution. The last issue is that the I tried this approach locally on one of my own projects that use The part of the solution that needs the most work right now is determining when PR for this is at #678 -- feedback very much appreciated. |
* Determines whether there is an import path to a vendored version of gopherjs * If so, updates all import paths to gopherjs in generated code to use the vendored version * Updates runtime/runtime.go to use a string constant for its static reference to the gopherjs import path * Adds logic to update the string constant to be the vendored path during generation Fixes gopherjs#415
* Determines whether there is an import path to a vendored version of gopherjs * If so, updates all import paths to gopherjs in generated code to use the vendored version * Updates runtime/runtime.go to use a string constant for its static reference to the gopherjs import path * Adds logic to update the string constant to be the vendored path during generation Fixes gopherjs#415
Thanks a lot for looking at this @nmiyake and sending a PR. It's very valuable for us to know the cause of the issue and what it takes to resolve it, so thanks for doing the investigation. I'll be able to review the PR shortly. |
@shurcooL Any update on this? |
There are no updates from my side. My last comment on the PR said:
That continues to be true, unfortunately. |
Also ignore github.com/gopherjs/gopherjs/js -- it cannot be vendored See: gopherjs/gopherjs#415 Fixes https://gitlab.com/agamigo/material/issues/16 CI: Don't need to go get dependencies anymore
@shurcooL I'm sure you're still busy, but I was curious if there was any update for this issue? |
Now that GopherJS 1.10-1 is out, I'll be prioritizing resolving this issue in the coming weeks. I think it's becoming more important to be able to vendor GopherJS, and be able to use fixed versions of it (rather than always counting on the latest). The PR just needs to be reviewed and tested. |
Thanks! |
@shurcooL That would be fantastic! Thank you. |
Great! I should be able to iterate on or answer any questions about the PR once it gets a chance to be reviewed (I see that there are some merge conflicts now -- I'll take a look at fixing those after receiving initial feedback). |
@shurcooL, this is holding up Perkeep getting rid of its hacky Can we incentivize you to fix this? We have some budget (https://opencollective.com/perkeep) and could pay for your time. |
You already have! I will make this issue my priority for the coming weekend.
You should be able to use Go 1.10 even before this is resolved. I'll want to chime in on that issue when I'm working on this.
Thank you very much, but I'd be worried that I only did a part of all the work required to resolve this issue (I've never been paid to work on an open source issue before, so I'm not sure how to deal with it). Maybe you'd want to buy me a coffee instead. But this weekend is still the soonest I can get to it, because I'll need a large continuous time block. |
The Go stdlib overrides (i.e., compiler/natives package) are already embedded into the GopherJS build system. This makes it possible for the gopherjs binary to access them even if the gopherjs repository is not present in GOPATH (e.g., because it was deleted, or because it's vendored). Doing that for natives but not the js, nosync packages makes little sense, since the gopherjs repository still needs to exist in GOPATH. This change fixes that. By embedding the core GopherJS packages analogously to natives, the gopherjs binary becomes more standalone. Now, it only requires GOROOT/src to contain the matching version of Go source code. Non-core GopherJS packages are not embedded (e.g., the GopherJS compiler itself). That means it needs to exist in GOPATH to be buildable (otherwise, the user gets a "cannot find package" error). This is expected just like with any other normal Go package. Fixes #462. Helps #415.
…nosync. These core GopherJS packages are already embedded into the GopherJS build system via the gopherjspkg virtual filesystem. The gopherjspkg package can be safely vendored. Therefore, there's no need to try to use vendor directory to resolve those packages. This change makes it possible to use a vendored copy of GopherJS in a project, and use it to build any Go code. Fixes #415.
The Go stdlib overrides (i.e., compiler/natives package) are already embedded into the GopherJS build system. This makes it possible for the gopherjs binary to access them even if the gopherjs repository is not present in GOPATH (e.g., because it was deleted, or because it's vendored). Doing that for natives but not the js, nosync packages makes little sense, since the gopherjs repository still needs to exist in GOPATH. This change fixes that. By embedding the core GopherJS packages analogously to natives, the gopherjs binary becomes more standalone. Now, it only requires GOROOT/src to contain the matching version of Go source code. Non-core GopherJS packages are not embedded (e.g., the GopherJS compiler itself). That means it needs to exist in GOPATH to be buildable (otherwise, the user gets a "cannot find package" error). This is expected just like with any other normal Go package. Fixes #462. Helps #415.
…nosync. These core GopherJS packages are already embedded into the GopherJS build system via the gopherjspkg virtual filesystem. The gopherjspkg package can be safely vendored. Therefore, there's no need to try to use vendor directory to resolve those packages. This change makes it possible to use a vendored copy of GopherJS in a project, and use it to build any Go code. Fixes #415.
The Go stdlib overrides (i.e., compiler/natives package) are already embedded into the GopherJS build system. This makes it possible for the gopherjs binary to access them even if the gopherjs repository is not present in GOPATH (e.g., because it was deleted, or because it's vendored). Doing that for natives but not the js, nosync packages makes little sense, since the gopherjs repository still needs to exist in GOPATH. This change fixes that. By embedding the core GopherJS packages analogously to natives, the gopherjs binary becomes more standalone. Now, it only requires GOROOT/src to contain the matching version of Go source code. Non-core GopherJS packages are not embedded (e.g., the GopherJS compiler itself). That means it needs to exist in GOPATH to be buildable (otherwise, the user gets a "cannot find package" error). This is expected just like with any other normal Go package. Fixes #462. Helps #415.
…nosync. These core GopherJS packages are already embedded into the GopherJS build system via the gopherjspkg virtual filesystem. The gopherjspkg package can be safely vendored. Therefore, there's no need to try to use vendor directory to resolve those packages. This change makes it possible to use a vendored copy of GopherJS in a project, and use it to build any Go code. Fixes #415.
I've created PR #787 that should resolve this issue. In my testing, I was able to vendor the entire GopherJS project in another Go project, and then used it to successfully build Go code (including Go code that imports I think everything should work, but it's possible I'm not aware of some other ways people are vendoring GopherJS. Please feel free to test the PR and let me know if vendoring doesn't work for you. |
The Go stdlib overrides (i.e., compiler/natives package) are already embedded into the GopherJS build system. This makes it possible for the gopherjs binary to access them even if the gopherjs repository is not present in GOPATH (e.g., because it was deleted, or because it's vendored). Doing that for natives but not the js, nosync packages makes little sense, since the gopherjs repository still needs to exist in GOPATH. This change fixes that. By embedding the core GopherJS packages analogously to natives, the gopherjs binary becomes more standalone. Now, it only requires GOROOT/src to contain the matching version of Go source code. Non-core GopherJS packages are not embedded (e.g., the GopherJS compiler itself). That means it needs to exist in GOPATH to be buildable (otherwise, the user gets a "cannot find package" error). This is expected just like with any other normal Go package. Fixes #462. Helps #415.
…nosync. These core GopherJS packages are already embedded into the GopherJS build system via the gopherjspkg virtual filesystem. The gopherjspkg package can be safely vendored. Therefore, there's no need to try to use vendor directory to resolve those packages. This change makes it possible to use a vendored copy of GopherJS in a project, and use it to build any Go code. Fixes #415.
This way, we get more information when/if TestGopherJSCanBeVendored fails. Before: $ go test -v -run=TestGopherJSCanBeVendored === RUN TestGopherJSCanBeVendored --- FAIL: TestGopherJSCanBeVendored (5.20s) gorepo_test.go:38: exit status 1 FAIL exit status 1 FAIL github.com/gopherjs/gopherjs/tests 5.203s After: $ go test -v -run=TestGopherJSCanBeVendored === RUN TestGopherJSCanBeVendored vendoring github.com/gopherjs/gopherjs/js package is not supported, see #415 --- FAIL: TestGopherJSCanBeVendored (5.19s) gorepo_test.go:40: exit status 1 FAIL exit status 1 FAIL github.com/gopherjs/gopherjs/tests 5.190s
This way, we get more information when/if TestGopherJSCanBeVendored fails. Before: $ go test -v -run=TestGopherJSCanBeVendored === RUN TestGopherJSCanBeVendored --- FAIL: TestGopherJSCanBeVendored (5.20s) gorepo_test.go:38: exit status 1 FAIL exit status 1 FAIL github.com/gopherjs/gopherjs/tests 5.203s After: $ go test -v -run=TestGopherJSCanBeVendored === RUN TestGopherJSCanBeVendored vendoring github.com/gopherjs/gopherjs/js package is not supported, see #415 --- FAIL: TestGopherJSCanBeVendored (5.19s) gorepo_test.go:40: exit status 1 FAIL exit status 1 FAIL github.com/gopherjs/gopherjs/tests 5.190s
The Go stdlib overrides (i.e., compiler/natives package) are already embedded into the GopherJS build system. This makes it possible for the gopherjs binary to access them even if the gopherjs repository is not present in GOPATH (e.g., because it was deleted, or because it's vendored). Doing that for natives but not the js, nosync packages makes little sense, since the gopherjs repository still needs to exist in GOPATH. This change fixes that. By embedding the core GopherJS packages analogously to natives, the gopherjs binary becomes more standalone. Now, it only requires GOROOT/src to contain the matching version of Go source code. Non-core GopherJS packages are not embedded (e.g., the GopherJS compiler itself). That means it needs to exist in GOPATH to be buildable (otherwise, the user gets a "cannot find package" error). This is expected just like with any other normal Go package. Fixes #462. Helps #415.
…nosync. These core GopherJS packages are already embedded into the GopherJS build system via the gopherjspkg virtual filesystem. The gopherjspkg package can be safely vendored. Therefore, there's no need to try to use vendor directory to resolve those packages. This change makes it possible to use a vendored copy of GopherJS in a project, and use it to build any Go code. Fixes #415.
I have a piece of go that imports gopherjs
I then vendor gopherjs and try to do a gopherjs build. the command succeeds but the generated code fails as soon as it tries to use 'js.Global.Set' because of nil pointer.
If I then delete the vendor/ directory and rebuild everything works fine.
Is there something else I should be vendoring in order for this to work? Or what is the expected workflow?
The text was updated successfully, but these errors were encountered: