ttscoff / searchlink

MIT License
57 stars 5 forks source link

Safari History/Bookmarks #3

Open miklb opened 1 year ago

miklb commented 1 year ago

attempting to use On Trying (Safari history shows "On Trying | danksinker.com" with link to https://dansinker.com/posts/trying/ ) I receive this error

The action “Run Shell Script” encountered an error: “-e:2088:in `get_safari_bookmarks': undefined method `[]' for nil:NilClass (NoMethodError)
from -e:2066:in `search_safari_bookmarks'
from -e:2104:in `block in search_history'
from -e:2103:in `each'
from -e:2103:in `search_history'
from -e:2883:in `do_search'
from -e:1059:in `block (2 levels) in parse'
from -e:862:in `gsub!'
from -e:862:in `block in parse'
from -e:836:in `each'
from -e:836:in `each_with_index'
from -e:836:in `parse'
from -e:3089:in `<main>'”

I can confirm I have a .searchlink file in my root user directory and includes the default

history_types:
- safari_bookmarks
- safari_history

Do I need to grant permission to the service for bookmarks/history? FWIW I'm running 13.2 Beta (22D5038i)

ttscoff commented 1 year ago

Hrm. That's going to be hard to track down. It indicates that it's not reading the xml file properly to begin with, but I'd have to be able to replicate the error to figure out exactly where the issue is.

What do you get if you open Terminal and run:

plutil -convert xml1 -o - ~/Library/Safari/Bookmarks.plist
miklb commented 1 year ago

It outputs quite a bit of data as XML.

I attempted the action again and I get a new error

The action “Run Shell Script” encountered an error: “-e:1711: warning: found `= literal' in conditional, should be ==
-e:1485:in `get_safari_bookmarks': undefined method `[]' for nil:NilClass (NoMethodError)
ttscoff commented 1 year ago

This would be easier to debug on the command line. It works great for me, but that error your getting doesn't narrow down where the issue would be. Are you technically able to download the source and install the gem for testing?

I can add a debugging branch to the code if you're able to clone the repo and build the gem (or just run the compile script). Let me know and I'll provide directions.

-Brett

On 22 Jan 2023, at 19:40, Michael Bishop wrote:

It outputs quite a bit of data as XML.

I attempted the action again and I get a new error

The action “Run Shell Script” encountered an error: “-e:1711: 
warning: found `= literal' in conditional, should be ==
-e:1485:in `get_safari_bookmarks': undefined method `[]' for 
nil:NilClass (NoMethodError)

-- Reply to this email directly or view it on GitHub: https://github.com/ttscoff/searchlink/issues/3#issuecomment-1399680766 You are receiving this because you commented.

Message ID: @.***>

ttscoff commented 1 year ago

I made some changes to the Safari bookmarks search in an update this morning. I didn't change anything that I think would directly affect this issue, but do please test with the latest release.

-Brett

On 22 Jan 2023, at 19:40, Michael Bishop wrote:

It outputs quite a bit of data as XML.

I attempted the action again and I get a new error

The action “Run Shell Script” encountered an error: “-e:1711: 
warning: found `= literal' in conditional, should be ==
-e:1485:in `get_safari_bookmarks': undefined method `[]' for 
nil:NilClass (NoMethodError)

-- Reply to this email directly or view it on GitHub: https://github.com/ttscoff/searchlink/issues/3#issuecomment-1399680766 You are receiving this because you commented.

Message ID: @.***>

miklb commented 1 year ago

I tested the latest zip with similar results. I read the release notes on building the gem locally and nothing too daunting there so I'm happy to try and help with deeper debugging next chance I get.

Latest full error message

The action “Run Shell Script” encountered an error: “-e:2359:in `get_safari_bookmarks': undefined method `[]' for nil:NilClass (NoMethodError)
from -e:2303:in `search_safari_bookmarks'
from -e:2503:in `block in search_history'
from -e:2502:in `each'
from -e:2502:in `search_history'
from -e:2487:in `search'
from -e:1104:in `block (2 levels) in do_search'
from -e:69:in `block in search_with_timeout'
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/timeout.rb:93:in `block in timeout'
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/timeout.rb:33:in `block in catch'
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/timeout.rb:33:in `catch'
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/timeout.rb:33:in `catch'
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/timeout.rb:108:in `timeout'
from -e:68:in `search_with_timeout'
from -e:1105:in `block in do_search'
from -e:1102:in `each'
from -e:1102:in `do_search'
from -e:3389:in `do_search'
from -e:3921:in `block (2 levels) in parse'
from -e:3678:in `gsub!'
from -e:3678:in `block in parse'
from -e:3652:in `each'
from -e:3652:in `each_with_index'
from -e:3652:in `parse'
from -e:4432:in `<main>'”
miklb commented 1 year ago

I tried installing an updated version of Ruby (3.2.0) using Homebrew - rbenv and ruby-build but it seems the service defaults to using /System/Library/Frameworks/Ruby.framework/Versions/2.6/ regardless.

ttscoff commented 1 year ago

Do you mean the Automator version, or are you running it from the command line now? The automator version will always default to the system ruby.

-Brett

On 24 Jan 2023, at 21:57, Michael Bishop wrote:

I tried installing an updated version of Ruby (3.2.0) using Homebrew - rbenv and ruby-build but it seems the service defaults to using
/System/Library/Frameworks/Ruby.framework/Versions/2.6/ regardless.

-- Reply to this email directly or view it on GitHub: https://github.com/ttscoff/searchlink/issues/3#issuecomment-1403062411 You are receiving this because you commented.

Message ID: @.***>

ttscoff commented 1 year ago

Oh, you did mean the service version. It's actually good that it uses a consistent ruby, makes my life easier :).

ttscoff commented 1 year ago

I tested the latest zip with similar results. I read the release notes on building the gem locally and nothing too daunting there so I'm happy to try and help with deeper debugging next chance I get.

Latest full error message


The action “Run Shell Script” encountered an error: “-e:2359:in `get_safari_bookmarks': undefined method `[]' for nil:NilClass (NoMethodError)

So I can prevent this error from being thrown, but the fact that the object is nil indicates it's not finding the bookmarks to begin with, or that the format is unexpected. It's working fine for me locally, but I literally only have one variation of the bookmarks file to examine. Try this version and see if you get at least a different error.