conda / menuinst

Cross platform menu item installation
https://conda.github.io/menuinst/
BSD 3-Clause "New" or "Revised" License
38 stars 44 forks source link

Error in the "base / non-base environment" json example #245

Closed jypeter closed 2 months ago

jypeter commented 3 months ago

Checklist

What happened?

The json example in the Specifying different shortcut names for base and non-base environments section is missing a , at the end of the "name" dictionary, and generates an error

Current example is

      "name": {
        "target_environment_is_base": "Launch Turtle",
        "target_environment_is_not_base": "Launch Turtle ({{ ENV_NAME }})"
      }
      "command": ["python", "-m", "turtle"],

and should instead be

      "name": {
        "target_environment_is_base": "Launch Turtle",
        "target_environment_is_not_base": "Launch Turtle ({{ ENV_NAME }})"
      },
      "command": ["python", "-m", "turtle"],

This is what I get with the current example, and after fixing it

(base) PS C:\Users\jypeter\menuinst_test> python -c "from menuinst.api import install; import pprintTraceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Utils\miniconda3_2024-03\Lib\site-packages\menuinst\utils.py", line 426, in wrapper_elevate
    return func(
           ^^^^^
  File "C:\Utils\miniconda3_2024-03\Lib\site-packages\menuinst\api.py", line 54, in install
    menu, menu_items = _load(metadata_or_path, target_prefix, base_prefix, _mode)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Utils\miniconda3_2024-03\Lib\site-packages\menuinst\api.py", line 36, in _load
    metadata = json.load(f)
               ^^^^^^^^^^^^
  File "C:\Utils\miniconda3_2024-03\Lib\json\__init__.py", line 293, in load
    return loads(fp.read(),
           ^^^^^^^^^^^^^^^^
  File "C:\Utils\miniconda3_2024-03\Lib\json\__init__.py", line 346, in loads
    return _default_decoder.decode(s)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Utils\miniconda3_2024-03\Lib\json\decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Utils\miniconda3_2024-03\Lib\json\decoder.py", line 353, in raw_decode
    obj, end = self.scan_once(s, idx)
               ^^^^^^^^^^^^^^^^^^^^^^
json.decoder.JSONDecodeError: Expecting ',' delimiter: line 11 column 7 (char 340)

(base) PS C:\Users\jypeter\menuinst_test> python -c "from menuinst.api import install; import pprint; pth_list = install('./turtle_nonbase.json'); pprint.pprint(pth_list)"
[WindowsPath('C:/Users/jypeter/AppData/Roaming/Microsoft/Windows/Start Menu/Programs/Python N.A'),
 WindowsPath('C:/Users/jypeter/AppData/Roaming/Microsoft/Windows/Start Menu/Programs/Python N.A/Launch Turtle.lnk'),
 WindowsPath('C:/Users/jypeter/Desktop/Launch Turtle.lnk'),
 WindowsPath('C:/Users/jypeter/AppData/Roaming/Microsoft/Internet Explorer/Quick Launch/Launch Turtle.lnk'),
 WindowsPath('C:/Utils/miniconda3_2024-03/Menu/Launch Turtle.bat')]

Additional Context

No response