willfarrell / alfred-pkgman-workflow

Package Repo Search
MIT License
699 stars 57 forks source link

Rubygems search errors out #170

Closed gee-forr closed 2 years ago

gee-forr commented 2 years ago

Hi there,

I'm seeing a problem with the rubygems.org package search included with this amazing workflow. Whenever I search for a gem, it immediately fails on the first character submitted, and falls back to web search.

I've switched on debugging, and here's the output that shows the error. I'm unfortunately not a PHP developer, so I really have no clue on how to go about fixing this.

I hope you can help... This is my most used workflow :) Thank you for it.

[13:47:45.845] Package Managers[Script Filter] Queuing argument ''
[13:47:45.869] Package Managers[Script Filter] Script with argv '(null)' finished
[13:47:45.872] Package Managers[Script Filter] {"items":[{"arg":"https:\/\/rubygems.org\/","icon":{"path":"icon-cache\/gems.png"},"subtitle":"https:\/\/rubygems.org","title":"Go to the website","uid":"gems-www-1665488865","valid":"yes"}]}
[13:47:47.657] Package Managers[Script Filter] Queuing argument 'x'
[13:47:47.702] Package Managers[Script Filter] Script with argv '(null)' finished
[13:47:47.705] STDERR: Package Managers[Script Filter] PHP Warning:  foreach() argument must be of type array|object, null given in /Users/gabrielf/Dropbox/Alfred/Alfred.alfredpreferences/workflows/user.workflow.4540627A-E3A0-491B-9076-63437332DB56/src/Gems.php on line 24
[13:47:47.706] Package Managers[Script Filter] Warning: foreach() argument must be of type array|object, null given in /Users/gabrielf/Dropbox/Alfred/Alfred.alfredpreferences/workflows/user.workflow.4540627A-E3A0-491B-9076-63437332DB56/src/Gems.php on line 24
{"items":[{"arg":"https:\/\/rubygems.org\/search?utf8=%E2%9C%93&query=x","icon":{"path":"icon-cache\/gems.png"},"subtitle":"Click to see the results for yourself","title":"No gems were found that matched \"x\"","uid":"gems-search","valid":"yes"},{"arg":"https:\/\/rubygems.org\/","icon":{"path":"icon-cache\/gems.png"},"subtitle":"https:\/\/rubygems.org","title":"Go to the website","uid":"gems-www-1665488867","valid":"yes"}]}
[13:47:47.707] ERROR: Package Managers[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:
Warning: foreach() argument must be of type array|object, null given in /Users/gabrielf/Dropbox/Alfred/Alfred.alfredpreferences/workflows/user.workflow.4540627A-E3A0-491B-9076-63437332DB56/src/Gems.php on line 24
{"items":[{"arg":"https:\/\/rubygems.org\/search?utf8=%E2%9C%93&query=x","icon":{"path":"icon-cache\/gems.png"},"subtitle":"Click to see the results for yourself","title":"No gems were found that matched \"x\"","uid":"gems-search","valid":"yes"},{"arg":"https:\/\/rubygems.org\/","icon":{"path":"icon-cache\/gems.png"},"subtitle":"https:\/\/rubygems.org","title":"Go to the website","uid":"gems-www-1665488867","valid":"yes"}]}
jeffbyrnes commented 2 years ago

@gee-forr hmm! I’m pretty sure I fixed that bug… would you make sure you’ve got the latest version of the workflow & try again?

gee-forr commented 2 years ago

howdy... Sorry, I should've told you that info upfront. My bad.

I experienced this error on a previous version, upgraded to 6.0.0, and noticed it was still a problem, which is when I raised this issue.

Is there an unpublished version I should use instead?

image

jeffbyrnes commented 2 years ago

Hmm. I’m also using v6.0.0, but maybe I neglected to publish things properly. I’ll grab a copy from the Releases page & see what’s up.

jeffbyrnes commented 2 years ago

So I just grabbed the workflow from the v6.0.0 release and it works well for me searching Rubygems.

gee-forr commented 2 years ago

This is really strange. I'll find the actual PHP script and run it manually from my shell and see what could be going on. Thanks for double checking :)

gee-forr commented 2 years ago

OK - so I noticed that it failed on almost all search queries, except a few, which led me down a few rabbit holes until it dawned on me that the broken searches might be returning badly cached data.

I ran a pkgman clear cache command, and everything is working again.

Sorry for wasting your time on a wild goose chase. Thanks for your help :)

jeffbyrnes commented 2 years ago

No prob, glad to hear it’s not a bug with the workflow!