Closed gopherbot closed 9 years ago
I have no problem with Go Tour on windows: C:\a\code\src>go get -v -d code.google.com/p/go-tour/ code.google.com/p/go-tour (download) package code.google.com/p/go-tour imports code.google.com/p/go-tour imports code.google.com/p/go-tour: no Go source files in C:\a\code\src\code.google.com\p\go tour C:\a\code\src>cd code.google.com\p\go-tour\gotour C:\a\code\src\code.google.com\p\go-tour\gotour>go build -v code.google.com/p/go-tour/pic code.google.com/p/go-tour/tree code.google.com/p/go-tour/wc code.google.com/p/go-tour/gotour C:\a\code\src\code.google.com\p\go-tour\gotour>dir Volume in drive C has no label. Volume Serial Number is AAAA-BBBB Directory of C:\a\code\src\code.google.com\p\go-tour\gotour 02/05/2012 10:13 AM <DIR> . 02/05/2012 10:13 AM <DIR> .. 02/05/2012 10:11 AM 710 goplay.go 02/05/2012 10:13 AM 4,990,464 gotour.exe 02/05/2012 10:11 AM 4,169 local.go 3 File(s) 4,995,343 bytes 2 Dir(s) 132,038,553,600 bytes free C:\a\code\src\code.google.com\p\go-tour\gotour>gotour.exe -help Usage of gotour.exe: -html=false: render program output as HTML -http="127.0.0.1:3999": host:port to listen on C:\a\code\src\code.google.com\p\go-tour\gotour>gotour.exe 2012/05/02 10:13:42 Serving content from C:\a\code\src\code.google.com\p\go-tour 2012/05/02 10:13:42 Open your web browser and visit http://127.0.0.1:3999/ C:\a\code\src\code.google.com\p\go-tour\gotour>set | find "GO" GOPATH=C:\a\code GOROOT=C:\a\go LOGONSERVER=\\AURDC002 C:\a\code\src\code.google.com\p\go-tour\gotour> I can open web browser on http://127.0.0.1:3999/ once gotour.exe is running. I can see first page with "Hello ..." example. I can press "Run" button. I can see "Hello ..." output printed in my browser. Can you, please, tell us what steps you did, and which of the steps you got something you didn't expect to get. Thank you. Alex
Status changed to WaitingForReply.
Comment 2 by simonedichiara@maior.biz:
Since the instructions only say: You can also run it locally. First install Go and then use go to install gotour: go get code.google.com/p/go-tour/gotour and run the gotour executable. I didn't have done this: C:\a\code\src\code.google.com\p\go-tour\gotour>go build -v. And that way it didn't work for me. As you described, it works. Thank you. I think this http://code.google.com/p/go-tour/issues/detail?id=33 is a similar problem.
Comment 4 by simonedichiara@maior.biz:
I was using this C:\Go\bin\gotour.exe and it didn't work. I assumed that "use go to install gotour" simply meant to run this: "go get code.google.com/p/go-tour/gotour". It actually generated the executable that I was using (C:\Go\bin\gotour.exe) and so I thought that that was the way it was meant to be. Anyway, thank you very much. :)
Using C:\Go\bin\gotour.exe should work too. If you build and install it with C:\a\code\src\code.google.com\p\go-tour\gotour>go install command. Please note, my GOPATH=C:\a\code, so my gotour.exe will end up in C:\a\code\bin\gotour.exe. Is it similar with you? Maybe you are running wrong gotour.exe, and it is out of date. Alex
Status changed to WaitingForReply.
Comment 6 by simonedichiara@maior.biz:
I installed go. Then in the cmd shell I wrote "go get code.google.com/p/go-tour/gotour" and hit Enter. No message displayed since I didn't use any parameter. Then I executed the file C:\Go\bin\gotour.exe and it didn't work, as I described in my first post. Then I wrote here and, after your answer, I tried this: "C:\Go\src\pkg\code.google.com\p\go-tour\gotour go build -v" It compiled a gotour.exe in the same folder (C:\Go\src\pkg\code.google.com\p\go-tour\gotour in my case). This new executable worked fine for me. I don't know if the other one, placed in C:\Go\bin\gotour.exe after "go get code.google.com/p/go-tour/gotour", is and older version. But it's existence in that folder confounded me, as it didn't work. I know my english is not so good, so if you need any clarification, I can try to write it out. xD
> > Comment #6 on issue #3583 by simonedichiara@maior.biz: Local Go Tour doesn't > compile > https://golang.org/issue/3583 > > I installed go. > Then in the cmd shell I wrote "go get code.google.com/p/go-tour/gotour" and > hit Enter. > No message displayed since I didn't use any parameter. That means that "go get" command worked successfully. Otherwise, it would complain. If you want to see what "go get" command is doing in details, use "-x" flag. > Then I executed the file C:\Go\bin\gotour.exe and it didn't work, as I > described in my first post. If you delete C:\Go\bin\gotour.exe file and try to build and install it again: go install -x code.google.com/p/go-tour/gotour you will see (because of -x) what "go install" command is doing and where it is installing resulting executable. Perhaps it is doing something you do not expect. Please, also run these commands C:\a\code\src>go env set GOROOT=C:\a\go set GOBIN= set GOARCH=386 set GOCHAR=8 set GOOS=windows set GOEXE=.exe set GOHOSTARCH=386 set GOHOSTOS=windows set GOTOOLDIR=C:\a\go\pkg\tool\windows_386 set GOGCCFLAGS=-g -O2 -m32 -mthreads set CGO_ENABLED=1 C:\a\code\src>set | find "GO" GOPATH=C:\a\code GOROOT=C:\a\go and show results, to help us understand your environment. > Then I wrote here and, after your answer, I tried this: > "C:\Go\src\pkg\code.google.com\p\go-tour\gotour go build -v" > It compiled a gotour.exe in the same folder > (C:\Go\src\pkg\code.google.com\p\go-tour\gotour in my case). This new > executable worked fine for me. If you run "go build" command in C:\Go\src\pkg\code.google.com\p\go-tour\gotour, it will just build gotour program and save it in the same folder where source files are. Unlike "go install", it does not install its results into %GOPATH%\bin or %GOPATH%\pkg directories. If you want to use "go" command, you should, probably, read some manuals about it. For example: http://golang.org/doc/code.html http://golang.org/cmd/go/ Alex
Comment 8 by simonedichiara@maior.biz:
Ok, I think we reproduced the problem. Here my environment: C:\Users\WIT>go env set GOROOT=C:\Go set GOBIN= set GOARCH=amd64 set GOCHAR=6 set GOOS=windows set GOEXE=.exe set GOHOSTARCH=amd64 set GOHOSTOS=windows set GOTOOLDIR=C:\Go\pkg\ set GOGCCFLAGS=-g -O2 -m set CGO_ENABLED=1 Then I deleted the following file: C:\Go\bin\gotour.exe Then I used the "go install": C:\Users\WIT>go install -x code.google.com/p/go-tour/gotour WORK=C:\Users\WIT\AppData\Local\Temp\go-build796384398 mkdir -p $WORK\code.google.com\p\go-tour\gotour\_obj\ cd C:\Go\src\pkg\code.google.com\p\go-tour\gotour C:\Go\pkg\tool\windows_amd64\6g.exe -o $WORK\code.google.com\p\go-tour\gotour\_obj\_go_.6 -p code.google.com/p/go-tour/gotour -D _/C_/Go/src/pkg/code.google.com/p/go-tour/gotour -I $WORK .\goplay.go .\local.go C:\Go\pkg\tool\windows_amd64\pack.exe grc $WORK\code.google.com\p\go-tour\gotour.a $WORK\code.google.com\p\go-tour\gotour\_obj\_go_.6 cd . C:\Go\pkg\tool\windows_amd64\6l.exe -o $WORK\code.google.com\p\go-tour\gotour\_obj\a.out.exe -L $WORK $WORK\code.google.com\p\go-tour\gotour.a mkdir -p C:\Go\bin\ cp $WORK\code.google.com\p\go-tour\gotour\_obj\a.out.exe C:\Go\bin\gotour.exe It, as expected, recreated the file C:\Go\bin\gotour.exe. But this file doesn't work for me. It gives me the problem I described in my first post here. I compile e nothing happens. So: - C:\a\code\src\code.google.com\p\go-tour\gotour>go build -v <-- THIS WORKS FOR ME - go install -x code.google.com/p/go-tour/gotour <-- THIS DOESN'T WORK
I can't reproduce your problem. And I have no good ideas where to look. The only thing that looks suspicious in your setup is your GOTOOLDIR value - mine is GOTOOLDIR=c:\go\pkg\tool\windows_386. The only good suggestion I have is for you to look at gotour program itself, to see where and why it breaks. You should be able to put print statements to make sure all code is executed as expected. Leaving it for others. Alex
Status changed to Accepted.
Comment 10 by simonedichiara@maior.biz:
I don't know if this could help, but: I changed this: if err != nil { if out != nil { resp.Errors = string(out) } else { resp.Errors = err.Error() } } else { resp.Output = string(out) } To this: if err != nil { if out != nil { log.Println("out != nil") log.Println(string(out)) resp.Errors = string(out) } else { log.Println("out == nil") log.Println(err.Error()) resp.Errors = err.Error() } } else { log.Println("err == nil") log.Println(string(out)) resp.Output = string(out) } The output is in the attached file.
Attachments:
Comment 12 by simonedichiara@maior.biz:
I printed err.Error() if out != nil { log.Println("out != nil") log.Println(string(out)) log.Println(err.Error()) resp.Errors = string(out) } The output is in the attached file.
Attachments:
Comment 13 by simonedichiara@maior.biz:
The error in the preceding posts happens only when I use "go install -x code.google.com/p/go-tour/gotour". It doesn't happen if I use "C:\Go\src\pkg\code.google.com\p\go-tour\gotour>go build -v".
Attachments:
Comment 15 by simonedichiara@maior.biz:
I think that goplay.go should at least be changed like this, to ensure it always return an error when there is one, and doesn't return the empty output: if out != nil && string(out) != "" { resp.Errors = string(out) } else { resp.Errors = err.Error() } I don't know if this is the correct way to do it, but that's the idea.
Attachments:
Your last findings do help. But I need more information. Please show us output of all these commands: dir C:\Go\src\pkg\code.google.com\p\go-tour\gotour dir C:\Go\bin\gotour.exe echo %PATH% Thank you. There are many problems you are seeing. It seems, gotour sometimes can't find go.exe to be able to compile code samples from web browser. We do not know why yet, but if you answer my request, I might make some suggestions. You do not see error message, because gotour.exe does not show it to you (as you have discovered). It is not correct behavior, so I have asked to change gotour (http://golang.org/cl/6201066/). Hopefully, if my change is accepted, you will be able to see your error message properly. Next problem is the error message: ".\go.exe: error 2 (Format Message failed with err=15100)". My message now says "exec: "go": executable file not found in %PATH%". So, I wonder, why yours is different. Also, it seems syscall.FormatMessage winapi function failed to fetch English error message for your error #2 (ERROR_FILE_NOT_FOUND). That is another mystery to investigate. But one thing at a time. :-) Alex
Comment 17 by simonedichiara@maior.biz:
Output of the commands, as you requested: Microsoft Windows [Versione 6.1.7601] Copyright (c) 2009 Microsoft Corporation. Tutti i diritti riservati. C:\Users\WIT>dir C:\Go\src\pkg\code.google.com\p\go-tour\gotour Il volume nell'unità C non ha etichetta. Numero di serie del volume: D6B2-D948 Directory di C:\Go\src\pkg\code.google.com\p\go-tour\gotour 08/05/2012 23:21 <DIR> . 08/05/2012 23:21 <DIR> .. 09/05/2012 08:45 792 goplay.go 08/05/2012 21:05 4.169 local.go 2 File 4.961 byte 2 Directory 61.870.792.704 byte disponibili C:\Users\WIT>dir C:\Go\bin\gotour.exe Il volume nell'unità C non ha etichetta. Numero di serie del volume: D6B2-D948 Directory di C:\Go\bin 09/05/2012 08:24 5.435.392 gotour.exe 1 File 5.435.392 byte 0 Directory 61.870.559.232 byte disponibili C:\Users\WIT>echo %PATH% C:\Program Files (x86)\AMD APP\bin\x86_64;C:\Program Files (x86)\AMD APP\bin\x86 ;C:\Program Files (x86)\PC Connectivity Solution\;C:\Program Files (x86)\MiKTeX 2.9\miktex\bin;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Pr ogram Files (x86)\Common Files\Microsoft Shared\Windows Live;C:\Windows\system32 ;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\ ;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files (x 86)\Windows Live\Shared;C:\Program Files (x86)\Common Files\Acronis\SnapAPI\;C:\ Program Files\Mercurial;C:\Program Files\TortoiseHg\;C:\Program Files (x86)\Micr osoft SQL Server\100\Tools\Binn\;C:\Program Files\Microsoft SQL Server\100\Tools \Binn\;C:\Program Files\Microsoft SQL Server\100\DTS\Binn\;C:\Program Files (x86 )\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\;C:\Program Files (x86)\Calibre2\;C:\ Go\bin
Comment 18 by simonedichiara@maior.biz:
This resolved my problem about the path of gotour, but doesn't make it more understandable. I modified code.google.com/p/go-tour/gotour/local.go From this: out, err = run(dir, "go", "build", "-o", bin, file) To this: var goroot = runtime.GOROOT() var gobin = goroot + "bin\\go" out, err = run(dir, gobin, "build", "-o", bin, file)
Comment 20 by simonedichiara@maior.biz:
I tried, as far as I can, to track down the problem. I modified os/exec/exec.go like this: log.Println("START FILE: " + c.Path), so that I could look at the file it was trying to execute. So, when gotour.exe is in the following dir "C:\Go\bin" the executed file is this: ".\go.exe". This doesn't work. When gotour.exe is, for example, on the desktop, the executed file is this: "C:\Go\bin\go.exe". And this works. The same is when I put gotour.exe on C: and so on.
Your problem is you can't run go.exe. But sometimes you can. Perhaps, your go.exe is not in your PATH. But sometimes it happens to be in your "current" directory. The way Windows finds executables to run, it looks in the current directory first, then it searches every directory listed in PATH environment variable in turn. Your PATH is quite long, but the only one that looks like Go related is C:\Go\bin in the very end. Please, run dir C:\Go\bin\ to see if go.exe is in there. Also, if you run this: package main import ( "fmt" "log" "os/exec" ) func main() { exe, err := exec.LookPath("go") if err != nil { log.Fatal(err) } fmt.Printf("go program lives in %s\n", exe) } it should tell you where your go.exe lives. If you have go.exe in C:\Go\bin\, then you should be able to run it from there, like this cd c:\go\bin .\go.exe Try it from command line see if that works. Perhaps, your c:\go\bin\go.exe is corrupted or something, and you are actually running go.exe from some other directory. But when you are in c:\go\bin then go.exe there has to be tried first, and it fails. Try my little program above and run it from different places and see what it does. Thank you. Alex
Comment 23 by simonedichiara@maior.biz:
I tested with your app from various paths (desktop, c:, c:\go\bin). Output is in the attached files. All the log print is from my other tests. I hope it doesn't bother you. I tried this: cd c:\go\bin .\go.exe and it works without problems. > Perhaps, your c:\go\bin\go.exe is corrupted or something, and you are actually running go.exe from some other directory. From my previous tests I think it runs the right go.exe: when I put "gotour.exe" in a directory that is not "c:\go\bin", it tries to run "C:\Go\bin\go.exe" and this works. When "gotour.exe" is in "c:\go\bin", it tries to run ".\go.exe" and this doesn't work.
Attachments:
Comment 24 by simonedichiara@maior.biz:
One screenshot for all the tests. The previous were done wrong. I'm sorry. :)
Attachments:
I think I can recreate your problem now. I started new https://golang.org/issue/3622, because, I think, it is Go related (not go-tour). I also do not like the error message you are getting, so I started https://golang.org/issue/3623 to track it separately too. Please run program listed there and post your results in https://golang.org/issue/3623. Thank you. Alex
by simonedichiara@maior.biz:
Attachments: