cursorless-dev / cursorless

Don't let the cursor slow you down
https://www.cursorless.org/
MIT License
1.15k stars 81 forks source link

max() arg is an empty sequence #543

Open ParetoOptimalDev opened 2 years ago

ParetoOptimalDev commented 2 years ago

Talon: v0.2.0-305-g968a (305) Knausj: 3e57e0165257cf07b0e21880d44a91e79cb3ef16 pokey/talon: 0.2.0 pokey/parse-tree: 0.14.0 pokey/cursorless: 0.25.271

2022-02-02 20:55:56 DEBUG User modules loaded at 1.6050s
2022-02-02 20:55:57    IO dired-mode
2022-02-02 20:55:58  INFO (SpeechSystem) Activating speech engine: W2lEngine(fast Conformer b108 (2021-09-15))
2022-02-02 20:55:58    IO Error finding color enablement; falling back to full enablement
2022-02-02 20:55:58    IO Traceback (most recent call last):
2022-02-02 20:55:58    IO   File "/home/nixos/.talon/user/cursorless-talon/src/marks/vscode_settings.py", line 59, in vscode_get_setting_with_fallback
    return actions.user.vscode_get_setting(key, default_value), False
2022-02-02 20:55:58    IO   File "talon/scripting/actions.py", line 78, in __call__
2022-02-02 20:55:58    IO   File "talon/scripting/types.py", line 383, in call
2022-02-02 20:55:58    IO   File "/home/nixos/.talon/user/cursorless-talon/src/marks/vscode_settings.py", line 33, in vscode_get_setting
    path: Path = actions.user.vscode_settings_path()
2022-02-02 20:55:58    IO   File "talon/scripting/actions.py", line 78, in __call__
2022-02-02 20:55:58    IO   File "talon/scripting/types.py", line 383, in call
2022-02-02 20:55:58    IO   File "/home/nixos/.talon/user/cursorless-talon/src/marks/vscode_settings.py", line 89, in vscode_settings_path
    return pick_path(
2022-02-02 20:55:58    IO   File "/home/nixos/.talon/user/cursorless-talon/src/marks/vscode_settings.py", line 68, in pick_path
    return max(existing_paths, key=lambda path: path.stat().st_mtime)
2022-02-02 20:55:58    IO ValueError: max() arg is an empty sequence
2022-02-02 20:55:58    IO Error finding shape enablement; falling back to full enablement
2022-02-02 20:55:58    IO Traceback (most recent call last):
2022-02-02 20:55:58    IO   File "/home/nixos/.talon/user/cursorless-talon/src/marks/vscode_settings.py", line 59, in vscode_get_setting_with_fallback
    return actions.user.vscode_get_setting(key, default_value), False
2022-02-02 20:55:58    IO   File "talon/scripting/actions.py", line 78, in __call__
2022-02-02 20:55:58    IO   File "talon/scripting/types.py", line 383, in call
2022-02-02 20:55:58    IO   File "/home/nixos/.talon/user/cursorless-talon/src/marks/vscode_settings.py", line 33, in vscode_get_setting
    path: Path = actions.user.vscode_settings_path()
2022-02-02 20:55:58    IO   File "talon/scripting/actions.py", line 78, in __call__
2022-02-02 20:55:58    IO   File "talon/scripting/types.py", line 383, in call
2022-02-02 20:55:58    IO   File "/home/nixos/.talon/user/cursorless-talon/src/marks/vscode_settings.py", line 89, in vscode_settings_path
    return pick_path(
2022-02-02 20:55:58    IO   File "/home/nixos/.talon/user/cursorless-talon/src/marks/vscode_settings.py", line 68, in pick_path
    return max(existing_paths, key=lambda path: path.stat().st_mtime)
2022-02-02 20:55:58    IO ValueError: max() arg is an empty sequence
2022-02-02 20:55:58 ERROR cb error topic="ready" cb=<function on_ready at 0x7fae65c94ca0>
   15:                         lib/python3.9/threading.py:930* # loader thread
   14:                         lib/python3.9/threading.py:973* 
   13:                         lib/python3.9/threading.py:910* 
   12:                            app/resources/loader.py:805| 
   11:                            app/resources/loader.py:755| 
   10:                        talon/scripting/dispatch.py:105| 
    9:                        talon/scripting/dispatch.py:144| 
    8:                        talon/scripting/dispatch.py:135| 
    7: ------------------------------------------------------# loader thread
    6:                            talon/scripting/rctx.py:233| # 'ready' user.cursorless-talon.src.marks.mark:on_ready()
    5:            user/cursorless-talon/src/marks/mark.py:223| vscode_settings_path: Path = actions.u..
    4:                         talon/scripting/actions.py:78 | 
    3:                           talon/scripting/types.py:383| 
    2: user/cursorless-talon/src/marks/vscode_settings.py:89 | return pick_path(
    1: user/cursorless-talon/src/marks/vscode_settings.py:68 | return max(existing_paths, key=lambda path: path.stat().st_mtime)
ValueError: max() arg is an empty sequence
ParetoOptimalDev commented 2 years ago

I just installed vscode and didn't have a ~/.config/Code/User/settings.json file. This seemed to fix things:

echo "{}" > ~/.config/Code/User/settings.json

At least no errors on talon startup, will report back after trying more stuff.

pokey commented 2 years ago

Yes sorry that's a known issue that should be fixed soon. Just to check: was everything still working even though you had this error in your logs?

ParetoOptimalDev commented 2 years ago

I got another error after that one, but I think maybe users installing extensions the expected vscode way might not run into the error below where I don't have command-server.

For context to understand how I run into it I'm installing vscode with nixos where I list out the extensions and only had talon, parse-tree, and cursorless.

2022-02-03 16:22:14  INFO Startup warnings displayed at 3.5035s
2022-02-03 16:22:40 WARNING list 'user.punctuation' skipped unknown tokens: [',', '`']
2022-02-03 16:22:40 WARNING list 'user.symbol_key' skipped unknown tokens: [',', '`']
2022-02-03 16:23:28 ERROR    19:                                talon/scripting/talon_script.py:590| 
   18:                                talon/scripting/talon_script.py:297| 
   17:                                talon/scripting/talon_script.py:557| 
   16:                                     talon/scripting/actions.py:78 | 
   15:                                       talon/scripting/types.py:383| 
   14:                   user/cursorless-talon/src/actions/actions.py:65 | return actions.user.cursorless_command..
   13:                                     talon/scripting/actions.py:78 | 
   12:                                       talon/scripting/types.py:383| 
   11:                   user/cursorless-talon/src/actions/actions.py:54 | return actions.user.cursorless_single_..
   10:                                     talon/scripting/actions.py:78 | 
    9:                                       talon/scripting/types.py:383| 
    8:                           user/cursorless-talon/src/command.py:32 | actions.user.cursorless_multiple_targe..
    7:                                     talon/scripting/actions.py:78 | 
    6:                                       talon/scripting/types.py:383| 
    5:                           user/cursorless-talon/src/command.py:93 | actions.user.vscode_with_plugin_and_wa..
    4:                                     talon/scripting/actions.py:78 | 
    3:                                       talon/scripting/types.py:383| 
    2: user/knausj_talon/apps/vscode/command_client/command_client.py:331| run_vscode_command(
    1: user/knausj_talon/apps/vscode/command_client/command_client.py:154| raise Exception("Must use command-server extension for advanced commands")
Exception: Must use command-server extension for advanced commands
ParetoOptimalDev commented 2 years ago

My latest issue is:

2022-02-03 16:51:55 WARNING actions: skipped because they have no matching declaration: (user.code_type_dictionary)

That appears to be in knausj_talon under the javascript tag, so I'll add that to settings.talon.

ParetoOptimalDev commented 2 years ago

I'm still getting:

2022-02-03 17:10:05 WARNING actions: skipped because they have no matching declaration: (user.code_type_dictionary)

Even though I've enabled that tag and restarted talon:

$ cat ~/.talon/user/settings.talon 
settings():
    speech.record_all = 1
tag(): user.i3wm
tag(): user.javascript
ParetoOptimalDev commented 2 years ago

Things seem to work now despite that warning, but I'm just slow at understanding how to use things :)

ParetoOptimalDev commented 2 years ago

Should I close this or leave it open until the fix you referred to is merged?

pokey commented 2 years ago

I got another error after that one, but I think maybe users installing extensions the expected vscode way might not run into the error below where I don't have command-server.

For context to understand how I run into it I'm installing vscode with nixos where I list out the extensions and only had talon, parse-tree, and cursorless.

I'm a bit surprised you have the talon extension but not command-server. The talon extension bundles the command-server extension

pokey commented 2 years ago

I'm still getting:

2022-02-03 17:10:05 WARNING actions: skipped because they have no matching declaration: (user.code_type_dictionary)

Yes, as you discovered, that warning isn't actually a problem. It's actually a knausj thing, so you might file that there

Even though I've enabled that tag and restarted talon:

$ cat ~/.talon/user/settings.talon 
settings():
    speech.record_all = 1
tag(): user.i3wm
tag(): user.javascript

You should remove that user.javascript tag. Talon will automatically detect when you're in a javascript file and activate the user.javascript tag for you

pokey commented 2 years ago

Should I close this or leave it open until the fix you referred to is merged?

Yeah I think we can close this one; Cursorless already does its best to handle this case using the current infrastructure, and it won't be a problem with the next version, which should be shipping soon

adabru commented 2 years ago

I am still getting this warning. In my Linux distribution (Arch) the settings paths are ~/.config/Code - OSS/User/settings.json for the stable and ~/.config/Code - Insiders/User/settings.json for the beta version. I guess this is not covered yet: https://github.com/cursorless-dev/cursorless/blob/main/cursorless-talon/src/marks/vscode_settings.py#L87-L94 . Despite the warning everything is working fine.

ajyoon commented 2 years ago

I'm also getting this warning on arch Linux, similarly as far as I can tell everything is working

pokey commented 2 years ago

Yeah maybe let's reopen, since this one is still an issue, even though it's not severe

pokey commented 1 year ago

I think probably the thing to do for now is to show a better error / warning, with an explanation and a link to this issue

saidelike commented 1 year ago

Just to say that i had this error with latest talon beta and latest cursorless on a Ubuntu 22.04 and it was indeed due to the missing vscode setting file:

2023-05-10 12:23:01    IO Error finding color enablement; falling back to full enablement
2023-05-10 12:23:01    IO Traceback (most recent call last):
2023-05-10 12:23:01    IO   File "/home/user/.talon/user/cursorless-talon/src/apps/vscode_settings.py", line 60, in vscode_get_setting_with_fallback
    return actions.user.vscode_get_setting(key, default_value), False
2023-05-10 12:23:01    IO   File "talon/scripting/actions.py", line 88, in __call__
2023-05-10 12:23:01    IO   File "/home/user/.talon/user/cursorless-talon/src/apps/vscode_settings.py", line 34, in vscode_get_setting
    path: Path = actions.user.vscode_settings_path()
2023-05-10 12:23:01    IO   File "talon/scripting/actions.py", line 88, in __call__
2023-05-10 12:23:01    IO   File "/home/user/.talon/user/cursorless-talon/src/apps/vscode_settings.py", line 91, in vscode_settings_path
    return pick_path(
2023-05-10 12:23:01    IO   File "/home/user/.talon/user/cursorless-talon/src/apps/vscode_settings.py", line 69, in pick_path
    return max(existing_paths, key=lambda path: path.stat().st_mtime)
2023-05-10 12:23:01    IO ValueError: max() arg is an empty sequence
2023-05-10 12:23:01    IO Error finding shape enablement; falling back to full enablement
2023-05-10 12:23:01    IO Traceback (most recent call last):
2023-05-10 12:23:01    IO   File "/home/user/.talon/user/cursorless-talon/src/apps/vscode_settings.py", line 60, in vscode_get_setting_with_fallback
    return actions.user.vscode_get_setting(key, default_value), False
2023-05-10 12:23:01    IO   File "talon/scripting/actions.py", line 88, in __call__
2023-05-10 12:23:01    IO   File "/home/user/.talon/user/cursorless-talon/src/apps/vscode_settings.py", line 34, in vscode_get_setting
    path: Path = actions.user.vscode_settings_path()
2023-05-10 12:23:01    IO   File "talon/scripting/actions.py", line 88, in __call__
2023-05-10 12:23:01    IO   File "/home/user/.talon/user/cursorless-talon/src/apps/vscode_settings.py", line 91, in vscode_settings_path
    return pick_path(
2023-05-10 12:23:01    IO   File "/home/user/.talon/user/cursorless-talon/src/apps/vscode_settings.py", line 69, in pick_path
    return max(existing_paths, key=lambda path: path.stat().st_mtime)
2023-05-10 12:23:01    IO ValueError: max() arg is an empty sequence
2023-05-10 12:23:01 ERROR cb error topic="ready" cb=on_ready
   11:                        lib/python3.9/threading.py:937* # loader thread
   10:                        lib/python3.9/threading.py:980* 
    9:                        lib/python3.9/threading.py:917* 
    8:                           app/resources/loader.py:889| 
    7:                           app/resources/loader.py:835| 
    6: -----------------------------------------------------# [stack splice]
    5:                       talon/scripting/dispatch.py:134| # 'ready' user.cursorless-talon.src.marks.mark:on_ready()
    4:           user/cursorless-talon/src/marks/mark.py:242| vscode_settings_path: Path = actions.u..
    3:                        talon/scripting/actions.py:88 | 
    2: user/cursorless-talon/src/apps/vscode_settings.py:91 | return pick_path(
    1: user/cursorless-talon/src/apps/vscode_settings.py:69 | return max(existing_paths, key=lambda path: path.stat().st_mtime)
ValueError: max() arg is an empty sequence
2023-05-10 12:23:02 DEBUG Dispatched launch events at 6.8212s, done at 11.5318s
2023-05-10 12:23:02 ERROR [!] 1 error(s) during startup (shown earlier in log)

The fix:

$ echo "{}" > ~/.config/Code/User/settings.json
pokey commented 1 year ago

I would be a bit careful with that fix, though, because the message can appear for one of two reasons:

  1. You don't have any custom VSCode settings. Your fix is fine in that case
  2. You are using a VSCode version that is using some weird settings location. I think we've fixed that problem in all cases, but there were some pretty weird corner cases, so I'd be hesitant to blanket apply your fix in case we missed something. Also in this case your fix will only work until you actually change your enabled hats

@auscompgeek @AndreasArvidsson does that sound right?

auscompgeek commented 1 year ago

Sounds right. In any case, opening the VSCode user settings JSON using the VSCode command and saving it would be the guaranteed correct way to create the settings file.

pokey commented 1 year ago

Yeah good call. Can just say "show settings json" with VSCode focused and then save it. Not sure if it automatically inserts a {}, but can just say "inside braces" and then save if not

nathanheffley commented 1 year ago

In case anyone else is using VS Code Insiders on a Mac, you will get this error as well, as src/apps/vscode_settings.py does not check for the Insiders settings which are at Code - Insiders/User/settings.json instead of Code/User/settings.json

Not sure if anything should be done about it officially, as Insiders is beta for a reason, but good to know that it's an easy manual fix.

pokey commented 1 year ago

Oh yeah that's a bug we should file and fix separately. should be super easy

juliatuttle commented 3 months ago

Hi! I just helped a friend who's getting into coding set up Cursorless and fae ran into this same bug -- Talon wouldn't start up because cursorless-talon couldn't find settings.json.

Changing a setting in VS Code created the file and fixed the problem, but I had to dig into cursorless-talon's source code a little to figure out what it was looking for, and guess that changing a setting would fix it.

It would be nice if you could add a quick note to the installation page making sure that users have changed a setting -- even just flipping the color scheme back and forth -- so other folks don't get caught on this.

pokey commented 3 months ago

@AndreasArvidsson I wonder if we could actually ensure the file is there automatically. Eg on Cursorless start-up the first time, just set and unset some dummy cursorless setting to make sure the file appears?

AndreasArvidsson commented 3 months ago

Or we could just gracefully handle that it doesn't exist?

pokey commented 3 months ago

The thing is we don't actually know that it doesn't exist, because there are several places it could be, including places we don't know about, as has happened before

That's not to say we shouldn't also gracefully handle it not existing, but ensuring it exists should help too

AndreasArvidsson commented 3 months ago

Sure. We can just toggle the Cursorless debug setting or something.

pokey commented 3 months ago

I guess we should check that toggling leaves an empty (or just {}) file there. I would guess it does tho