Skip to content

Failure on startup when user has no vscode settings.json #543

Closed

Description

@ParetoOptimalDev

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

Activity

  1. ParetoOptimalDev commented on Feb 3, 2022

    @ParetoOptimalDev
    Author

    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.

  2. pokey commented on Feb 3, 2022

    @pokey
    Member

    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?

  3. ParetoOptimalDev commented on Feb 3, 2022

    @ParetoOptimalDev
    Author

    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
    
  4. ParetoOptimalDev commented on Feb 3, 2022

    @ParetoOptimalDev
    Author

    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.

  5. ParetoOptimalDev commented on Feb 3, 2022

    @ParetoOptimalDev
    Author

    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
    
  6. ParetoOptimalDev commented on Feb 3, 2022

    @ParetoOptimalDev
    Author

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

  7. ParetoOptimalDev commented on Feb 4, 2022

    @ParetoOptimalDev
    Author

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

  8. pokey commented on Feb 4, 2022

    @pokey
    Member

    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

  9. pokey commented on Feb 4, 2022

    @pokey
    Member

    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

  10. pokey commented on Feb 4, 2022

    @pokey
    Member

    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

  11. adabru commented on Apr 19, 2022

    @adabru

    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.

  12. ajyoon commented on Apr 28, 2022

    @ajyoon

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

  13. reopened this on Apr 29, 2022
  14. 3 remaining items

  15. saidelike commented on May 10, 2023

    @saidelike
    Collaborator

    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
    
  16. pokey commented on May 10, 2023

    @pokey
    Member

    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?

  17. auscompgeek commented on May 10, 2023

    @auscompgeek
    Member

    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.

  18. pokey commented on May 11, 2023

    @pokey
    Member

    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

  19. nathanheffley commented on Aug 17, 2023

    @nathanheffley
    Contributor

    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.

  20. pokey commented on Aug 18, 2023

    @pokey
    Member

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

  21. juliatuttle commented on Jul 21, 2024

    @juliatuttle

    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.

  22. pokey commented on Jul 21, 2024

    @pokey
    Member

    @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?

  23. AndreasArvidsson commented on Jul 21, 2024

    @AndreasArvidsson
    Member

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

  24. pokey commented on Jul 21, 2024

    @pokey
    Member

    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

  25. AndreasArvidsson commented on Jul 22, 2024

    @AndreasArvidsson
    Member

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

  26. pokey commented on Jul 22, 2024

    @pokey
    Member

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

  27. changed the title [-]max() arg is an empty sequence[/-] [+]Failure on startup when user has no vscode `settings.json`[/+] on Dec 5, 2024
  28. AndreasArvidsson commented on Jan 25, 2025

    @AndreasArvidsson
    Member

    This is now handled gracefully Talon side. An empty file or non existing file doesn't really matter anymore. Closing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    talon

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions