{"action":"created","issue":{"url":"https://api.github.com/repos/golang/go/issues/14196","repository_url":"https://api.github.com/repos/golang/go","labels_url":"https://api.github.com/repos/golang/go/issues/14196/labels{/name}","comments_url":"https://api.github.com/repos/golang/go/issues/14196/comments","events_url":"https://api.github.com/repos/golang/go/issues/14196/events","html_url":"https://github.com/golang/go/issues/14196","id":130749966,"number":14196,"title":"io/ioutil: TempDir fails if \"/tmp\" doesn't exist and first argument is empty","user":{"login":"deweerdt","id":5094,"avatar_url":"https://avatars.githubusercontent.com/u/5094?v=3","gravatar_id":"","url":"https://api.github.com/users/deweerdt","html_url":"https://github.com/deweerdt","followers_url":"https://api.github.com/users/deweerdt/followers","following_url":"https://api.github.com/users/deweerdt/following{/other_user}","gists_url":"https://api.github.com/users/deweerdt/gists{/gist_id}","starred_url":"https://api.github.com/users/deweerdt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/deweerdt/subscriptions","organizations_url":"https://api.github.com/users/deweerdt/orgs","repos_url":"https://api.github.com/users/deweerdt/repos","events_url":"https://api.github.com/users/deweerdt/events{/privacy}","received_events_url":"https://api.github.com/users/deweerdt/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/golang/go/milestones/31","html_url":"https://github.com/golang/go/milestones/Go1.7","labels_url":"https://api.github.com/repos/golang/go/milestones/31/labels","id":1414133,"number":31,"title":"Go1.7","description":"","creator":{"login":"bradfitz","id":2621,"avatar_url":"https://avatars.githubusercontent.com/u/2621?v=3","gravatar_id":"","url":"https://api.github.com/users/bradfitz","html_url":"https://github.com/bradfitz","followers_url":"https://api.github.com/users/bradfitz/followers","following_url":"https://api.github.com/users/bradfitz/following{/other_user}","gists_url":"https://api.github.com/users/bradfitz/gists{/gist_id}","starred_url":"https://api.github.com/users/bradfitz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bradfitz/subscriptions","organizations_url":"https://api.github.com/users/bradfitz/orgs","repos_url":"https://api.github.com/users/bradfitz/repos","events_url":"https://api.github.com/users/bradfitz/events{/privacy}","received_events_url":"https://api.github.com/users/bradfitz/received_events","type":"User","site_admin":false},"open_issues":160,"closed_issues":18,"state":"open","created_at":"2015-11-16T16:57:07Z","updated_at":"2016-02-02T23:53:22Z","due_on":"2016-07-31T07:00:00Z","closed_at":null},"comments":3,"created_at":"2016-02-02T17:13:01Z","updated_at":"2016-02-03T06:44:50Z","closed_at":null,"body":"Seen on go1.5.2 linux/amd64, running a program using io.ioutil.TempDir() inside a docker image that has neither TMPDIR defined nor /tmp created.\r\nCalling io.ioutil.TempDir()  fails with: mkdir ... no such file or directory.\r\n\r\nIn the special case where TempDir (or TempFile) are called with an empty first argument, it feels like we could try to mkdir the directory before erroring out of the function.\r\n\r\nSmall repro case:\r\n```\r\n$ cat test1.go\r\npackage main\r\n\r\nimport (\r\n        \"io/ioutil\"\r\n)\r\n\r\nfunc main() {\r\n        _, err := ioutil.TempDir(\"\", \"blah\")\r\n        if err != nil {\r\n                println(err.Error())\r\n        }\r\n}\r\n$ go build test1.go\r\n$ mkdir dir\r\n$ mv test1 dir\r\n$ sudo chroot ./dir /test1\r\nmkdir /tmp/blah629598329: no such file or directory\r\n$\r\n\r\n```"},"comment":{"url":"https://api.github.com/repos/golang/go/issues/comments/179044293","html_url":"https://github.com/golang/go/issues/14196#issuecomment-179044293","issue_url":"https://api.github.com/repos/golang/go/issues/14196","id":179044293,"user":{"login":"odeke-em","id":4898263,"avatar_url":"https://avatars.githubusercontent.com/u/4898263?v=3","gravatar_id":"","url":"https://api.github.com/users/odeke-em","html_url":"https://github.com/odeke-em","followers_url":"https://api.github.com/users/odeke-em/followers","following_url":"https://api.github.com/users/odeke-em/following{/other_user}","gists_url":"https://api.github.com/users/odeke-em/gists{/gist_id}","starred_url":"https://api.github.com/users/odeke-em/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/odeke-em/subscriptions","organizations_url":"https://api.github.com/users/odeke-em/orgs","repos_url":"https://api.github.com/users/odeke-em/repos","events_url":"https://api.github.com/users/odeke-em/events{/privacy}","received_events_url":"https://api.github.com/users/odeke-em/received_events","type":"User","site_admin":false},"created_at":"2016-02-03T06:44:50Z","updated_at":"2016-02-03T06:44:50Z","body":"I've taken a stab at this with https://go-review.googlesource.com/19178. The only problem is, how could I test this as changing out os.TempDir is impractical. Also a code review is pending."}}