{"action":"created","issue":{"url":"https://api.github.com/repos/golang/go/issues/10928","labels_url":"https://api.github.com/repos/golang/go/issues/10928/labels{/name}","comments_url":"https://api.github.com/repos/golang/go/issues/10928/comments","events_url":"https://api.github.com/repos/golang/go/issues/10928/events","html_url":"https://github.com/golang/go/issues/10928","id":79129359,"number":10928,"title":"x/mobile/cmd/gomobile: not setting TMP directory on Windows","user":{"login":"merickson","id":734363,"avatar_url":"https://avatars.githubusercontent.com/u/734363?v=3","gravatar_id":"","url":"https://api.github.com/users/merickson","html_url":"https://github.com/merickson","followers_url":"https://api.github.com/users/merickson/followers","following_url":"https://api.github.com/users/merickson/following{/other_user}","gists_url":"https://api.github.com/users/merickson/gists{/gist_id}","starred_url":"https://api.github.com/users/merickson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/merickson/subscriptions","organizations_url":"https://api.github.com/users/merickson/orgs","repos_url":"https://api.github.com/users/merickson/repos","events_url":"https://api.github.com/users/merickson/events{/privacy}","received_events_url":"https://api.github.com/users/merickson/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/golang/go/labels/OS-Windows","name":"OS-Windows","color":"ededed"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-05-21T19:28:07Z","updated_at":"2015-05-26T19:33:17Z","closed_at":null,"body":"# Bug Report\r\n## What version of Go are you using (go version)?\r\n\r\nI'm using `go version devel +3a3773c Fri May 8 17:01:24 2015 +0000 windows/amd64`\r\n\r\n## What operating system and processor architecture are you using?\r\n\r\nWindows 8.1 Pro, x86_64.\r\n\r\n## What did you do?\r\n\r\nAfter setting up a development tip GOROOT, I installed gomobile and attempted to run `gomobile init`. I have successfully been able to do this on Linux / x86_64.\r\n\r\n## What did you expect to see?\r\n\r\nThe Android NDK setup and gomobile ready to bind packages.\r\n\r\n## What did you see instead?\r\n\r\nI got the following error after running `gomobile init -x -v`:\r\n\r\n```\r\ngomobile: cannot get cmd/dist version: exit status 2 (go tool dist: mkdir C:\\Windows\\go-tool-dist-506627087: Access is denied.\r\n```\r\n\r\n# Resolution\r\nI discovered the problem's root with `checkVersionMatch()` at https://github.com/golang/mobile/blob/master/cmd/gomobile/init.go#L394 . Running `dist.exe`, as `checkVersionMatch()` attempts to do, will try to create a temporary file as part of its init process (see https://github.com/golang/go/blob/master/src/cmd/dist/build.go#L216 ). On Windows, os.TempDir will use [GetTempPath](https://msdn.microsoft.com/en-us/library/windows/desktop/aa364992%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396) to resolve where to create its temporary directory.\r\n\r\nNote, then, the configuration of `cmd.Env` in `checkVersionMatch()` above. It lacks the appropriate envars for Windows to steer it correctly to the appropriate temp directory. I added the following code immediately after setting `cmd.Env`:\r\n```go\r\n\tif goos == \"windows\" {\r\n\t\tcmd.Env = append(cmd.Env, \"TMP=\" + os.Getenv(\"TMP\"))\r\n\t}\r\n```\r\nOne quick gomobile rebuild later, and `gomobile init` ran to completion successfully and as expected."},"comment":{"url":"https://api.github.com/repos/golang/go/issues/comments/105642874","html_url":"https://github.com/golang/go/issues/10928#issuecomment-105642874","issue_url":"https://api.github.com/repos/golang/go/issues/10928","id":105642874,"user":{"login":"crawshaw","id":161319,"avatar_url":"https://avatars.githubusercontent.com/u/161319?v=3","gravatar_id":"","url":"https://api.github.com/users/crawshaw","html_url":"https://github.com/crawshaw","followers_url":"https://api.github.com/users/crawshaw/followers","following_url":"https://api.github.com/users/crawshaw/following{/other_user}","gists_url":"https://api.github.com/users/crawshaw/gists{/gist_id}","starred_url":"https://api.github.com/users/crawshaw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/crawshaw/subscriptions","organizations_url":"https://api.github.com/users/crawshaw/orgs","repos_url":"https://api.github.com/users/crawshaw/repos","events_url":"https://api.github.com/users/crawshaw/events{/privacy}","received_events_url":"https://api.github.com/users/crawshaw/received_events","type":"User","site_admin":false},"created_at":"2015-05-26T19:33:17Z","updated_at":"2015-05-26T19:33:17Z","body":"Thanks for the detailed bug report. I believe golang.org/cl/10401 will fix this, but my windows setup currently isn't working to test it. (Hana has a working setup, I'll ask for login details when she gets back.)"}}