screenshot icon indicating copy to clipboard operation
screenshot copied to clipboard

Exception while taking screenshot on Ubuntu

Open kashishm opened this issue 8 years ago • 1 comments

I am getting the following exception while taking a screenshot on Ubuntu.

XGB: conn.go:47: Could not get authority info: open /var/go/.Xauthority: no such file or directory
XGB: conn.go:48: Trying connection without authority info...
XGB: conn.go:47: Could not get authority info: open /var/go/.Xauthority: no such file or directory
XGB: conn.go:48: Trying connection without authority info...
panic: runtime error: index out of range

goroutine 1 [running]:
panic(0x556a40, 0xc420014130)
	/usr/local/Cellar/go/1.7.4/libexec/src/runtime/panic.go:500 +0x1a1
image.(*RGBA).Opaque(0xc42065c000, 0x62e340)
	/usr/local/Cellar/go/1.7.4/libexec/src/image/image.go:141 +0xc3
image/png.opaque(0x62e340, 0xc42065c000, 0x62c240)
	/usr/local/Cellar/go/1.7.4/libexec/src/image/png/writer.go:60 +0x162
image/png.(*Encoder).Encode(0xc4200e6010, 0x62c5c0, 0xc420054000, 0x62e340, 0xc42065c000, 0x0, 0x0)
	/usr/local/Cellar/go/1.7.4/libexec/src/image/png/writer.go:508 +0x505
image/png.Encode(0x62c5c0, 0xc420054000, 0x62e340, 0xc42065c000, 0x0, 0x0)
	/usr/local/Cellar/go/1.7.4/libexec/src/image/png/writer.go:476 +0x6a
main.main()
	/Users/kashishm/Documents/go/src/github.com/sample/example/main.go:42 +0x155

code(from example folder)

func main() {
	img, err := screenshot.CaptureScreen()
	if err != nil {
		panic(err)
	}
	f, err := os.Create("./ss.png")
	if err != nil {
		panic(err)
	}
	err = png.Encode(f, img)
	if err != nil {
		panic(err)
	}
	f.Close()
}

kashishm avatar Jan 11 '17 09:01 kashishm

Looks like its searching for /var/go/.Xauthority and its not founded, and the path looks like not $HOME/.Xauthority, can you check if $HOME/.Xauthority exists? if it does you can try to remove $XAUTHORITY. or maybe create new .Xauthority file? Found this one for creating Xauthority http://superuser.com/a/941244

vova616 avatar Jan 11 '17 20:01 vova616