sballin / alfred-search-notes-app

Use Alfred to quickly open notes in iCloud/Apple Notes.
https://www.alfredforum.com/topic/11716-search-appleicloud-notes/
MIT License
502 stars 23 forks source link

Stopped working after MacOS 11.4 upgrade #39

Closed axhamre closed 3 years ago

axhamre commented 3 years ago

To Reproduce

  1. I'm getting the error message described in "Required setup": https://github.com/sballin/alfred-search-notes-app#required-setup'
  2. Step 3 in the instructions doesn't work, as the "Open Anyway" button doesn't appear.

Info

panic: unable to open database file: operation not permitted

goroutine 1 [running]:
main.PanicOnErr(...)
    github.com/sballin/alfred-search-notes-app/main.go:394
main.main()
    github.com/sballin/alfred-search-notes-app/main.go:407 +0x789
panic: unable to open database file: operation not permitted

goroutine 1 [running]:
main.PanicOnErr(...)
    github.com/sballin/alfred-search-notes-app/main.go:394
main.main()
    github.com/sballin/alfred-search-notes-app/main.go:407 +0x789
panic: unable to open database file: operation not permitted

goroutine 1 [running]:
main.PanicOnErr(...)
    github.com/sballin/alfred-search-notes-app/main.go:394
main.main()
    github.com/sballin/alfred-search-notes-app/main.go:407 +0x789
panic: unable to open database file: operation not permitted

goroutine 1 [running]:
main.PanicOnErr(...)
    github.com/sballin/alfred-search-notes-app/main.go:394
main.main()
    github.com/sballin/alfred-search-notes-app/main.go:407 +0x789
panic: unable to open database file: operation not permitted

goroutine 1 [running]:
main.PanicOnErr(...)
    github.com/sballin/alfred-search-notes-app/main.go:394
main.main()
    github.com/sballin/alfred-search-notes-app/main.go:407 +0x789
panic: unable to open database file: operation not permitted

goroutine 1 [running]:
main.PanicOnErr(...)
    github.com/sballin/alfred-search-notes-app/main.go:394
main.main()
    github.com/sballin/alfred-search-notes-app/main.go:407 +0x789
panic: unable to open database file: operation not permitted

goroutine 1 [running]:
main.PanicOnErr(...)
    github.com/sballin/alfred-search-notes-app/main.go:394
main.main()
    github.com/sballin/alfred-search-notes-app/main.go:407 +0x789
panic: unable to open database file: operation not permitted

goroutine 1 [running]:
main.PanicOnErr(...)
    github.com/sballin/alfred-search-notes-app/main.go:394
main.main()
    github.com/sballin/alfred-search-notes-app/main.go:407 +0x789

Additional context Add any other context about the problem here.

sballin commented 3 years ago

The popup message suggests the most common problem people have, which is with setup, regardless of the real error. I think your setup is fine, because the error is coming from a line inside the code.

Did you change the file permissions of the executable search_notes? It's inside a directory of the same name in the workflow directory which you can access by right-clicking on the workflow in Alfred and selecting "Open in Finder".

In your terminal, can you tell me the output of

stat -x ~/Library/Group\ Containers/group.com.apple.notes/NoteStore.sqlite

And also (after cding into the workflow directory)

stat -x search_notes/search_notes
solintllc-robert commented 3 years ago

I ran into the same problem after upgrading to 11.4.

From the plugin directory, I ran the search I was trying to run from Alfred, namely ./search_notes title NI. It brought back valid search results.

{ "items": [ { "title": "NI Hiring", "subtitle": "NI Hiring", "arg": "x-coredata://34D75F64-A28E-4E94-B9EA-A44B6E3F0EB5/ICNote/p19?NI", "quicklookurl": null }, ...

So I don't think it is actually permissions issue.

(also, THANK YOU for developing this plugin. I use it every day. It's great.)

sballin commented 3 years ago

You're welcome! And thanks for confirming this is a widespread issue. The latest version I've been using has some changes in the binary and it's been working for me on 11.4, so could either of you install the attached and let me know if it works when searching through Alfred?

Search Notes.alfredworkflow.zip

solintllc-robert commented 3 years ago

I tried it and still got the same error. Well, slightly different. The offset is different. (+0x644 (new) vs +0x789(old)).

The error for me is:

  1. Open the Alfred bar with ⌘+space.
  2. Type letter n.
  3. Immediate error.
solintllc-robert commented 3 years ago

Also, I can confirm that I can still successfully run the script from the command line.

The perms are: -rwxr-xr-x 1 myuser staff 13478770 May 30 09:27 search_notes/search_notes

Unfortunately, I don't know where to find the "database" referenced by the error log, so I can't look up the perms on it. Either way, it's strange since the script runs fine when run as a script from the command line.

sballin commented 3 years ago

The database is here: ~/Library/Group\ Containers/group.com.apple.notes/NoteStore.sqlite

Would be good to know your permissions on that too.

solintllc-robert commented 3 years ago
ls -la ~/Library/Group\ Containers/group.com.apple.notes/NoteStore.sqlite
-rw-r--r--  1 myuser  staff  15757312 Jun  4 01:13 /Users/myuser/Library/Group Containers/group.com.apple.notes/NoteStore.sqlite
solintllc-robert commented 3 years ago

I am able to access that sqlite file with sqlite3 and read the tables.

solintllc-robert commented 3 years ago

I compiled the project in Golang 1.16 for my M1 Mac, and Alfred still throws up this error (and only this error. not the others depicted in OP's link): image

I tried replacing the search_notes binary with my own binary that simply writes "Hello World" to stderr. That binary runs fine.

solintllc-robert commented 3 years ago

Some tweaking of your search_notes, and I extracted the long SELECT query. I verified I was able to run that query successfully in sqlite3. I also verified that NewLiteDB and NewNotesDB do not generate err values.

solintllc-robert commented 3 years ago

Well, I finally figured it out. Alfred didn't have Full Disk Access checked in the Security & Privacy → Privacy pane. Once I check off Full Disk access it worked fine.

sballin commented 3 years ago

When you tested search_notes from the command line, did you have a search string? If not, the executable doesn’t really do anything. This is how to search:

./search_notes body "search string"

On Jun 4, 2021, at 6:59 AM, gitrobert42 @.***> wrote:

 Some tweaking of your search_notes, and I extracted the long SELECT query. I verified I was able to run that query successfully in sqlite3. I also verified that NewLiteDB and NewNotesDB do not generate err values.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

sballin commented 3 years ago

Ah, that makes sense! I will make this more explicit in the setup instructions.

Still not sure why that would have changed during the upgrade to 11.4

On Jun 4, 2021, at 8:46 AM, Sean Ballinger @.***> wrote:

 When you tested search_notes from the command line, did you have a search string? If not, the executable doesn’t really do anything. This is how to search:

./search_notes body "search string"

On Jun 4, 2021, at 6:59 AM, gitrobert42 @.***> wrote:

 Some tweaking of your search_notes, and I extracted the long SELECT query. I verified I was able to run that query successfully in sqlite3. I also verified that NewLiteDB and NewNotesDB do not generate err values.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

solintllc-robert commented 3 years ago

I'm not sure either. Maybe 11.4 tightened up the sandbox.

axhamre commented 3 years ago

Well, I finally figured it out. Alfred didn't have Full Disk Access checked in the Security & Privacy → Privacy pane. Once I check off Full Disk access it worked fine.

This solved it for me as well, thank you!

And thank you @gitrobert42 for an amazing plugin.

petemaunder91 commented 3 years ago

Alfred does have full disk access for me, however the issue still persists.