Thanks to visit codestin.com
Credit goes to github.com

Skip to content

gopherjs build error on Windows #875

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

Closed
EchoofthePast opened this issue Nov 2, 2018 · 9 comments
Closed

gopherjs build error on Windows #875

EchoofthePast opened this issue Nov 2, 2018 · 9 comments
Labels

Comments

@EchoofthePast
Copy link

I am using windows 7 for my operating system and have the most up to date version of Go at the moment version 1.11.1.
I have just recently reinstalled all the packages hoping that it would rectify my problem but has not

My problem seems to be consistent and no solution exists that i can find, I have searched extensively and have found that others are having similar problems and the solutions have not corrected my problem.

I am trying to transpile a gopherjs file. when i run gopherjs build filename.go I receive an error in terminal

←[31m/src/syscall/syscall_nonlinux.go:5:18: undeclared name: SYS_EXIT
←[39m←[31m/src/syscall/syscall.go:53:39: too few arguments in call to Syscall
←[39m

The first problem that i see with this is that the syscall_nonlinux.go file doesn't even exist in the go root directory and the second error denotes a function with in syscall.go (the file does exist) but the error makes no sense.

I have been stuck on this for some time now and have tried all I can do.
Please help if possible,

@theclapp
Copy link

theclapp commented Nov 2, 2018

Running on Windows requires a bit of a hack. From the README:

gopherjs uses your platform's default GOOS value when generating code. Supported GOOS values are: linux, darwin. If you're on a different platform (e.g., Windows or FreeBSD), you'll need to set the GOOS environment variable to a supported value. For example, GOOS=linux gopherjs build [package].

So, try

GOOS=linux gopherjs build filename.go

@inliquid
Copy link

inliquid commented Nov 2, 2018

What a non-sense. Can you just fix that?

@EchoofthePast
Copy link
Author

I added GOOS=linux to my system environment variables and the restarted VSC and then ran gopherjs build filename.go and it worked!!
Thank you with all my heart.

@EchoofthePast
Copy link
Author

EchoofthePast commented Nov 2, 2018

Although now suddenly after making those changes I have now tried go run filename.go fails to compile go files with error exec: "C:\Users\me\AppData\Local\Temp\go-build012283026\b001\exe\filename": file does not exist

I have not seen this error until now and assume that it must be related to the changes that have occurred . I assume that some how these few changes have now confused Go and caused the problems has this happened to anyone else, and yet again I am stuck.

removing the added GOOS=linux variable from my system variables allows go run to work correctly again. Is there not a solution where i can have both Go and Gopherjs working at the same time or is it so extreme that i will have to wait for some one out there to make gopherjs compatible with windows or worse resort to changing my operating system !!

@theclapp
Copy link

theclapp commented Nov 2, 2018

Don't set GOOS system wide, only set it for that session. I think the command is

set GOOS=linux
gopherjs build filename.go

but it might be setenv. I imagine you could easily write a script, even in Windows, to do this on a command-by-command basis.

This has been working this way (or broken this way, if you like) for a while. I think if the maintainers were going to fix it, they would have.

@inliquid
Copy link

inliquid commented Nov 2, 2018

@EchoofthePast do not add GOOS=linux to your system. As the result you will get ELF binaries when you compile regular *.go programs instead of Windows binaries, so they won't run on Windows. This problem is bug and must be fixed.

@EchoofthePast
Copy link
Author

using set GOOS=linux works its the correct command and works to build the files.
This may only be a small problem and once you have the solution to it can be easy to remember but I think this problem can also prove to discourage newer programmers from using Go and Gopherjs,
I thank you both for your help . I am truly grateful.

@dmitshur dmitshur changed the title gopherjs build error gopherjs build error on Windows Nov 4, 2018
@inkeliz
Copy link
Contributor

inkeliz commented Nov 9, 2018

I hit the same issue in the past. I think it can be mitigated. I don't know if have any side-effect, I didn't test it in all cases, but for simply gopherjs build it works. Running the go test all tests works, with the exception of the fixedbugs/*, which all fails.

Just include this 4 lines at func init():

if build.Default.GOOS == "windows" {
	fmt.Fprintf(os.Stderr, "GOOS is Windows. The GopherJS is falling back to GOOS=linux\n")
	build.Default.GOOS = "linux"
}

Showing a message for the use is good, in my option, so this change is noticible and not silent.

@EchoofthePast
Copy link
Author

Thank you to everyone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants