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

playground: go generate fails when GOROOT is user-writeable. #69

Closed
myitcv opened this issue Apr 24, 2018 · 6 comments · Fixed by #72
Closed

playground: go generate fails when GOROOT is user-writeable. #69

myitcv opened this issue Apr 24, 2018 · 6 comments · Fixed by #72
Assignees
Labels
bug

Comments

@myitcv
Copy link
Member

@myitcv myitcv commented Apr 24, 2018

Following gopherjs/gopherjs#787 I'm seeing the playground fail to regenerate:

cd `mktemp -d`
export GOPATH=$PWD
go get github.com/gopherjs/gopherjs
go get github.com/gopherjs/gopherjs.github.io/playground
export PATH=$PWD/bin:$PATH
cd src/github.com/gopherjs/gopherjs.github.io/playground
gopherjs --version
go generate

with:

cp: cannot stat '/tmp/gopherjs_playground.QXOsmkSXHw/gopath/pkg/*_js_min/github.com/gopherjs/gopherjs/js.a': No such file or directory

This is, I believe, because js and nosync are fully vendored.

@shurcooL - what do you think is going on here?

myitcv added a commit to myitcv/gopherjs.github.io that referenced this issue Apr 24, 2018
Fixes gopherjs#69
@dmitshur

This comment has been minimized.

Copy link
Member

@dmitshur dmitshur commented Apr 24, 2018

This is, I believe, because js and nosync are fully vendored.

I don't believe that is the case. Only the source code of those packages is embedded, not their built archives. Please see commit message of cbdec89.

@shurcooL - what do you think is going on here?

I have a hunch. Is your GOROOT directory writeable by user (i.e., can you modify GOROOT contents without having to use sudo)?

@myitcv

This comment has been minimized.

Copy link
Member Author

@myitcv myitcv commented Apr 24, 2018

I have a hunch. Is your GOROOT directory writeable by user (i.e., can you modify GOROOT contents without having to use sudo)?

Yes, it is.

@dmitshur

This comment has been minimized.

Copy link
Member

@dmitshur dmitshur commented Apr 24, 2018

That must be why then. The current update.sh assumes it's not. If it is, GopherJS compiler installs the js.a and nosync.a into your GOROOT instead of GOPATH, so lines 33 and 34 won't be able to copy the archives:

# Use an empty GOPATH workspace with just gopherjs,
# so that all the standard library packages get written to GOROOT/pkg.
export GOPATH="$tmp/gopath"
mkdir -p "$GOPATH"/src/github.com/gopherjs/gopherjs
cp -a "$gopherjsgopath"/src/github.com/gopherjs/gopherjs/* "$GOPATH"/src/github.com/gopherjs/gopherjs
gopherjs install -m github.com/gopherjs/gopherjs/js github.com/gopherjs/gopherjs/nosync
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

I noticed the comment on line 26 is wrong, it should say "GOPATH/pkg" there.

To fix this, we need to find a way of making it work regardless of whether GOROOT is user-writeable or not.

@dmitshur dmitshur changed the title go generate fails with gopherjs 1.10-3 go generate fails when GOROOT is user-writeable. Apr 24, 2018
@myitcv

This comment has been minimized.

Copy link
Member Author

@myitcv myitcv commented Apr 24, 2018

If it is, GopherJS compiler installs the js.a and nosync.a into your GOROOT instead of GOPATH

Out of interest, why does it do that?

@dmitshur

This comment has been minimized.

Copy link
Member

@dmitshur dmitshur commented Apr 24, 2018

That was the behavior Richard implemented about 5 years ago. His GOROOT was user writeable, and he wanted GopherJS to install its archives of the standard library into GOROOT/pkg.

Back then, it would fail to work if GOROOT was not user-writeable.

I prefer my GOROOT not to be user-writeable and not contain any extraneous files, so I reported it as gopherjs/gopherjs#4. Richard worked on a fix that would make GopherJS fall back to writing the standard library archives to GOPATH/pkg if it failed to write to GOROOT/pkg.

That has been the behavior since.

(Later on, I worked on a fix to make it support GOPATH that consisted of more than workspace, see gopherjs/gopherjs#60.)

@dmitshur

This comment has been minimized.

Copy link
Member

@dmitshur dmitshur commented Apr 24, 2018

Also note that this behavior is documented, see last paragraph of https://github.com/gopherjs/gopherjs#installation-and-usage.

@dmitshur dmitshur added the bug label Apr 24, 2018
@dmitshur dmitshur changed the title go generate fails when GOROOT is user-writeable. playground: go generate fails when GOROOT is user-writeable. Apr 24, 2018
@dmitshur dmitshur self-assigned this Dec 1, 2019
dmitshur added a commit that referenced this issue Dec 1, 2019
Also modify the default "hello world" snippet to use it,
since it's a more general API.

Modernize update.sh slightly to handle variability in
environments better.

Updates #69
dmitshur added a commit that referenced this issue Dec 1, 2019
Previously, the script relied on GOROOT not being user-writable and
failed when that wasn't the case. This change makes it succeed in
both cases.

Fixes #69
@dmitshur dmitshur closed this in #72 Dec 2, 2019
dmitshur added a commit that referenced this issue Dec 2, 2019
Also modify the default "hello world" snippet to use it,
since it's a more general API.

Modernize update.sh slightly to handle variability in
environments better.

Updates #69
dmitshur added a commit that referenced this issue Dec 2, 2019
Previously, the script relied on GOROOT not being user-writable and
failed when that wasn't the case. This change makes it succeed in
both cases.

Fixes #69
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.