cage1016/alfred-devtoys

clipboard: cannot use when CGO_ENABLED=0

Closed this issue ยท 14 comments

Running on macOS 12.6.1 Macbook Pro M1 and when trying to encode a string I get this alert and no encoded string.

I also had numerous System Security alerts about exe that I had to navigate around.

image

first, for security issue. Please check system/Security & Privacy allow App store and identified developers

CleanShot 2022-10-26 at 17 28 41@2x

second, cause i don't have arm64 Mac, Cloud you provide more information

My Security settings for Apps was set to "App Store and identified developers" but it still popped up with the warnings unfortunately.

As for debugging here is the output from trying to encode a simple string and I also noticed that exe was only compiled for x86/64, I don't know if that plays into this:

[08:34:24.055] Logging Started...
[08:34:28.063] DevToys[Script Filter] Queuing argument '(null)'
[08:34:28.122] DevToys[Script Filter] Script with argv '(null)' finished
[08:34:28.125] ERROR: DevToys[Script Filter] Code 1: ๐Ÿบ
08:34:28 workflow.go:328: ---------- DevToys/1.5.0 (AwGo/0.27.1) -----------
08:34:28 workflow.go:343: ------------------ FATAL ERROR -------------------
08:34:28 workflow.go:344: clipboard: cannot use when CGO_ENABLED=0 : goroutine 1 [running]:
runtime/debug.Stack()
	/Users/runner/hostedtoolcache/go/1.17.13/x64/src/runtime/debug/stack.go:24 +0x88
github.com/deanishe/awgo.(*Workflow).Run.func2(0x1400016aea0)
	/Users/runner/go/pkg/mod/github.com/deanishe/awgo@v0.29.1/workflow.go:344 +0xf0
panic({0x100aca6e0, 0x100b4b578})
	/Users/runner/hostedtoolcache/go/1.17.13/x64/src/runtime/panic.go:1038 +0x21c
golang.design/x/clipboard.read(...)
	/Users/runner/go/pkg/mod/golang.design/x/clipboard@v0.6.2/clipboard_nocgo.go:13
golang.design/x/clipboard.Read(0x0)
	/Users/runner/go/pkg/mod/golang.design/x/clipboard@v0.6.2/clipboard.go:111 +0xa4
github.com/cage1016/alfred-devtoys/cmd.encodeRun(0x100e06820, {0x140001198c0, 0x1, 0x1})
	/Users/runner/work/alfred-devtoys/alfred-devtoys/cmd/encode.go:27 +0x64
github.com/spf13/cobra.(*Command).execute(0x100e06820, {0x140001198b0, 0x1, 0x1})
	/Users/runner/go/pkg/mod/github.com/spf13/cobra@v1.5.0/command.go:876 +0x65c
github.com/spf13/cobra.(*Command).ExecuteC(0x100e08120)
	/Users/runner/go/pkg/mod/github.com/spf13/cobra@v1.5.0/command.go:990 +0x410
github.com/spf13/cobra.(*Command).Execute(...)
	/Users/runner/go/pkg/mod/github.com/spf13/cobra@v1.5.0/command.go:918
github.com/cage1016/alfred-devtoys/cmd.Execute.func1()
	/Users/runner/work/alfred-devtoys/alfred-devtoys/cmd/root.go:57 +0x30
github.com/deanishe/awgo.(*Workflow).Run(0x1400016aea0, 0x100b49b30)
	/Users/runner/go/pkg/mod/github.com/deanishe/awgo@v0.29.1/workflow.go:358 +0x310
github.com/cage1016/alfred-devtoys/cmd.Execute()
	/Users/runner/work/alfred-devtoys/alfred-devtoys/cmd/root.go:56 +0x3c
main.main()
	/Users/runner/work/alfred-devtoys/alfred-devtoys/main.go:14 +0x20
08:34:28 workflow.go:345: ---------------- END STACK TRACE -----------------
08:34:28 feedback.go:509: Sent 1 result(s) to Alfred
08:34:28 workflow.go:376: [ERROR] clipboard: cannot use when CGO_ENABLED=0
08:34:28 workflow.go:379: Get help at cage1016/alfred-devtoys/issues
08:34:28 workflow.go:402: ------------------- 3.058375ms -------------------
[08:34:28.138] DevToys[Script Filter] {
  "variables": {
    "AW_SESSION_ID": "4U8APWN786S91NEBGIVXZ5MN"
  },
  "items": [
    {
      "title": "clipboard: cannot use when CGO_ENABLED=0",
      "valid": false,
      "icon": {
        "path": "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/AlertStopIcon.icns"
      }
    }
  ]
}

Same issue on M1 MacBook. Surprisingly this started when I updated to Ventura. On MacOS Monterey it was fine.

I have disabled Gatekeeper. I am still getting encoding results unlike the above user.

But "cannot use when CGO_ENABLED=0" pops up as subtext always when invoking any command.

[08:58:00.860] DevToys[Script Filter] Queuing argument '(null)'
[08:58:00.922] DevToys[Script Filter] Script with argv '(null)' finished
[08:58:00.927] ERROR: DevToys[Script Filter] Code 1: ๐Ÿบ
08:58:00 workflow.go:328: ---------- DevToys/1.5.0 (AwGo/0.27.1) -----------
08:58:00 workflow.go:343: ------------------ FATAL ERROR -------------------
08:58:00 workflow.go:344: clipboard: cannot use when CGO_ENABLED=0 : goroutine 1 [running]:
runtime/debug.Stack()
	/Users/runner/hostedtoolcache/go/1.17.13/x64/src/runtime/debug/stack.go:24 +0x88
github.com/deanishe/awgo.(*Workflow).Run.func2(0x1400016ad80)
	/Users/runner/go/pkg/mod/github.com/deanishe/awgo@v0.29.1/workflow.go:344 +0xf0
panic({0x1010aa6e0, 0x10112b578})
	/Users/runner/hostedtoolcache/go/1.17.13/x64/src/runtime/panic.go:1038 +0x21c
golang.design/x/clipboard.read(...)
	/Users/runner/go/pkg/mod/golang.design/x/clipboard@v0.6.2/clipboard_nocgo.go:13
golang.design/x/clipboard.Read(0x0)
	/Users/runner/go/pkg/mod/golang.design/x/clipboard@v0.6.2/clipboard.go:111 +0xa4
github.com/cage1016/alfred-devtoys/cmd.runQrcode(0x1013e7ea0, {0x140001198c0, 0x1, 0x1})
	/Users/runner/work/alfred-devtoys/alfred-devtoys/cmd/qrcode.go:59 +0x64
github.com/spf13/cobra.(*Command).execute(0x1013e7ea0, {0x140001198b0, 0x1, 0x1})
	/Users/runner/go/pkg/mod/github.com/spf13/cobra@v1.5.0/command.go:876 +0x65c
github.com/spf13/cobra.(*Command).ExecuteC(0x1013e8120)
	/Users/runner/go/pkg/mod/github.com/spf13/cobra@v1.5.0/command.go:990 +0x410
github.com/spf13/cobra.(*Command).Execute(...)
	/Users/runner/go/pkg/mod/github.com/spf13/cobra@v1.5.0/command.go:918
github.com/cage1016/alfred-devtoys/cmd.Execute.func1()
	/Users/runner/work/alfred-devtoys/alfred-devtoys/cmd/root.go:57 +0x30
github.com/deanishe/awgo.(*Workflow).Run(0x1400016ad80, 0x101129b30)
	/Users/runner/go/pkg/mod/github.com/deanishe/awgo@v0.29.1/workflow.go:358 +0x310
github.com/cage1016/alfred-devtoys/cmd.Execute()
	/Users/runner/work/alfred-devtoys/alfred-devtoys/cmd/root.go:56 +0x3c
main.main()
	/Users/runner/work/alfred-devtoys/alfred-devtoys/main.go:14 +0x20
08:58:00 workflow.go:345: ---------------- END STACK TRACE -----------------
08:58:00 feedback.go:509: Sent 1 result(s) to Alfred
08:58:00 workflow.go:376: [ERROR] clipboard: cannot use when CGO_ENABLED=0
08:58:00 workflow.go:379: Get help at cage1016/alfred-devtoys/issues
08:58:00 workflow.go:402: -------------------- 3.141ms ---------------------
[08:58:00.931] DevToys[Script Filter] {
  "variables": {
    "AW_SESSION_ID": "NS7ZO94LEKXAKPYV5300R2PY"
  },
  "items": [
    {
      "title": "clipboard: cannot use when CGO_ENABLED=0",
      "valid": false,
      "icon": {
        "path": "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/AlertStopIcon.icns"
      }
    }
  ]
}
	query := args[0]
	if strings.TrimSpace(query) == "" {
		query = string(clipboard.Read(clipboard.FmtText))  ๐Ÿ‘ˆ๏ธ๐Ÿ‘ˆ๏ธ๐Ÿ‘ˆ๏ธ
	}
	log.Println(query)

In v1.5, whatever encode or qrcode command, every command will use latest clipboard value if input is empty by default. The root cause is due to https://github.com/golang-design/clipboard error

@bmorgenthaler @LampPrinter Cloud both of you provide your Mac system info (OS, Processor etc.). I will deep dive to check if any issue at M1 for use this third-party package

Apple M1 MacBook Air
MacOS Ventura 13.0 (22A380)

Gatekeeper disabled.
Anything else?

iShot_2022-10-27_11 17 21

iShot_2022-10-27_11 17 36

MacBookPro18,1
M1 MacBook Pro (16-inch, 2021)
16GB
macOS Monterey 12.6.1

SIP / Gatekeeper enabled

exe.zip

@bmorgenthaler @LampPrinter I try another 3-rd party clipboard. I build an ./exe to read clipboard. Please help me to give a try if this clipboard library works as expected at M1

exe.zip

@bmorgenthaler @LampPrinter I try another 3-rd party clipboard. I build an ./exe to read clipboard. Please help me to give a try if this clipboard library works as expected at M1

ERROR: DevToys[Script Filter] JSON error: JSON text did not start with array or object and option to allow fragments not set. around line 1, column 0. in JSON:

Same issue as @LampPrinter

[11:30:55.815] ERROR: DevToys[Script Filter] JSON error: JSON text did not start with array or object and option to allow fragments not set. around line 1, column 0. in JSON: CAB6A31E-1AA3-4BDC-9C4B-6B43ADA97100

Where do both of you execute ./exe? Download exe.zip and unzip. This one is individual execution binary for reading clipboard testing.

copy any text before execute binary

$ ./exe 
# should output latest clipboard text

Where do both of you execute ./exe? Download exe.zip and unzip. This one is individual execution binary for reading clipboard testing.

copy any text before execute binary

$ ./exe 
# should output latest clipboard text

Oh.
Yeah, its working fine in terminal. โœ…

Earlier, I replaced the "exe" file in workflow with the new one.

@LampPrinter Thanks for your feedback. I will deliver revised version workflow to give you a try. If everything works as expected and i will adopt this solution and push a new release to fix clipboard issue at Apple M1.

@bmorgenthaler @LampPrinter

Release v1.5.1 Pre release ยท cage1016/alfred-devtoys

Please have a try pre release version and make sure everything work as expected. Thanks.

@cage1016
Working fine now.

Some typos to be fixed.

iShot_2022-11-03_09 40 06

iShot_2022-11-03_09 40 36