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

update.sh: fix to work with all shells and gopherjs 1.10-3. #70

Closed
wants to merge 1 commit into from

Conversation

@myitcv
Copy link
Member

myitcv commented Apr 24, 2018

Fixes #69

Fixes #69
@@ -8,7 +8,7 @@ cleanup() {
exit
}

trap cleanup EXIT SIGHUP SIGINT SIGTERM
trap cleanup EXIT HUP INT TERM

This comment has been minimized.

Copy link
@myitcv

myitcv Apr 24, 2018

Author Member

Not all shells understand the SIG prefix.

This comment has been minimized.

Copy link
@dmitshur

dmitshur Apr 24, 2018

Member

This change is good.

@@ -20,18 +20,15 @@ gopherjs build -m
# The GOPATH workspace where the GopherJS project is.
gopherjsgopath=$(go list -f '{{.Root}}' github.com/gopherjs/gopherjs)

rm -r pkg/
rm -rf pkg/

This comment has been minimized.

Copy link
@myitcv

myitcv Apr 24, 2018

Author Member

If the previous go generate failed before pkg was recreated this step fails otherwise.

This comment has been minimized.

Copy link
@dmitshur

dmitshur Apr 24, 2018

Member

This change is good.

@@ -8,7 +8,7 @@ cleanup() {
exit
}

trap cleanup EXIT SIGHUP SIGINT SIGTERM
trap cleanup EXIT HUP INT TERM

This comment has been minimized.

Copy link
@dmitshur

dmitshur Apr 24, 2018

Member

This change is good.

@@ -20,18 +20,15 @@ gopherjs build -m
# The GOPATH workspace where the GopherJS project is.
gopherjsgopath=$(go list -f '{{.Root}}' github.com/gopherjs/gopherjs)

rm -r pkg/
rm -rf pkg/

This comment has been minimized.

Copy link
@dmitshur

dmitshur Apr 24, 2018

Member

This change is good.

mkdir -p pkg/github.com/gopherjs/gopherjs
cp "$GOPATH"/pkg/*_js_min/github.com/gopherjs/gopherjs/js.a pkg/github.com/gopherjs/gopherjs/js.a
cp "$GOPATH"/pkg/*_js_min/github.com/gopherjs/gopherjs/nosync.a pkg/github.com/gopherjs/gopherjs/nosync.a
mkdir pkg

This comment has been minimized.

Copy link
@dmitshur

dmitshur Apr 24, 2018

Member

I believe this change would break the playground. Have you tested that it works?

I tested a similar change when I was working on cbdec89, and it resulted in failed to load package "github.com/gopherjs/gopherjs/js" errors for me. Is it not the case for you?

See my comment in #69 for more info.

This comment has been minimized.

Copy link
@myitcv

myitcv Apr 24, 2018

Author Member

Yes, worked fine locally for me. But I suspect my answer has something to do with that?

This comment has been minimized.

Copy link
@dmitshur

dmitshur Apr 24, 2018

Member

Yes, worked fine locally for me.

I see. Can you elaborate on how you tested it locally?

This comment has been minimized.

Copy link
@myitcv

myitcv Apr 24, 2018

Author Member

Subject to the SIG change in update.sh, I ran go generate then gopherjs serve (per the README) and everything worked just fine in my browser.

This comment has been minimized.

Copy link
@dmitshur

dmitshur Apr 24, 2018

Member

I can't reproduce your results.

If I remove the js.a.js file from pkg and use gopherjs serve, the playground fails to run the initial program.

playground $ rm ./pkg/github.com/gopherjs/gopherjs/js.a.js 
playground $ gopherjs serve
serving at http://localhost:8080 and on port 8080 of any available addresses

image

Maybe you didn't clear your browser's cache?

This comment has been minimized.

Copy link
@myitcv

myitcv Apr 24, 2018

Author Member

I did the following (recreating the root-owned $GOROOT for fair comparison):

cd $GOROOT
sudo chown -R root:root .
cd `mktemp -d`
export GOPATH=$PWD
export PATH=$GOPATH/bin:$PATH
go get github.com/gopherjs/gopherjs
go get github.com/gopherjs/gopherjs.github.io/playground
cd $(go list -f "{{.Dir}}" github.com/gopherjs/gopherjs.github.io/playground)
git fetch origin pull/70/head
git checkout -q FETCH_HEAD
which gopherjs
go generate
gopherjs serve

Then went to http://localhost:8080/github.com/gopherjs/gopherjs.github.io/playground/ and did an "Empty Cache and Hard Reload" in Chrome and that page, which imports js, works fine for me: I see the alert as well as the console log and the in-page "console" log.

Am I following the right steps?

For me github.com/gopherjs/gopherjs/js is compiled into playground.js:

$ grep '^\$packages\["github.com/gopherjs/gopherjs/js"\]' playground.js | cut -c 1-80
$packages["github.com/gopherjs/gopherjs/js"]=(function(){var $pkg={},$init,A,B,I

This comment has been minimized.

Copy link
@dmitshur

dmitshur Apr 24, 2018

Member

Thanks for providing more information.

Can you check, after you do go generate, are there 2 files in ./pkg/github.com/gopherjs/gopherjs directory?

Based on the steps you're following... Maybe what's happening is that you already have a built js.a and nosync.a in your GOROOT/pkg from before (when your GOROOT was user-writeable), and it gets copied from there?

This comment has been minimized.

Copy link
@dmitshur

dmitshur Apr 24, 2018

Member

For me github.com/gopherjs/gopherjs/js is compiled into playground.js:

That's expected, it's there for the playground itself. github.com/gopherjs/gopherjs/compiler will also be there, etc. But it doesn't mean it would be used from there during compilation of playground programs.

This comment has been minimized.

Copy link
@myitcv

myitcv Apr 25, 2018

Author Member

That's expected, it's there for the playground itself. github.com/gopherjs/gopherjs/compiler will also be there, etc. But it doesn't mean it would be used from there during compilation of playground programs.

Good point.

Can you check, after you do go generate, are there 2 files in ./pkg/github.com/gopherjs/gopherjs directory?

Yes there are.

I've also just run the steps above but with a writable GOROOT; success again.

But I don't think this is surprising because after the gopherjs install in the fake GOROOT we do:

cp -a "$GOROOT"/pkg/*_js_min/* pkg/
cp -a "$GOROOT"/pkg/*_amd64_js_min/* pkg/

and because some of the natives depend on github.com/gopherjs/gopherjs/js it also gets installed (because gopherjs installs all dependencies, unlike Go 1.10).

I think this adds up now?

Incidentally, do the steps in #70 (comment) not work for you?

@dmitshur

This comment has been minimized.

Copy link
Member

dmitshur commented Aug 25, 2018

I'm going to cherry pick the "fix to work with all shells" changes. We'll leave the rest for later. Fixing #69 has to be done in a way that doesn't break playground if GOROOT is non-writeable.

@dmitshur

This comment has been minimized.

Copy link
Member

dmitshur commented Dec 2, 2019

Closing because #69 has been resolved. Please let me know if there are any issues. Thanks for the work here.

@dmitshur dmitshur closed this Dec 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.