hyprland-community/pyprland

[BUG] Error loading plugin pyprland -> JSONDecodeError: Expecting value

Closed this issue · 12 comments

Pyprland version
2.2.11

Describe the bug
Start up pypr gives following:

> pypr
Error loading plugin pyprland:
Traceback (most recent call last):
  File "/home/x/miniconda/lib/python3.11/site-packages/pyprland/command.py", line 121, in _load_single_plugin
    await plug.init()
  File "/home/x/miniconda/lib/python3.11/site-packages/pyprland/plugins/pyprland.py", line 12, in init
    version = (await self.hyprctlJSON("version"))["tag"]
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/x/miniconda/lib/python3.11/site-packages/pyprland/ipc.py", line 59, in wrapper
    return await func(*args, **kwargs, logger=logger)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/x/miniconda/lib/python3.11/site-packages/pyprland/ipc.py", line 100, in hyprctlJSON
    ret = json.loads(resp)
          ^^^^^^^^^^^^^^^^
  File "/home/x/miniconda/lib/python3.11/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/x/miniconda/lib/python3.11/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/x/miniconda/lib/python3.11/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 8 column 16 (char 136)

I am not sure what additional infos I should provide, please advice, I am happy to give you all needed infos.

Cheer!

Hi, as stated by the error message, you made a mistake in the configuration file at line 8... it's not a bug but a typo or invalid syntax.
You can share your configuration here if it's not clear for you.

Many thanks for your swift reply. Looking at my config, I do not see any misconfigurations, not sure though. Could you please take a look at my pyprland.toml.

[pyprland]
plugins = [
  "scratchpads",
  # "lost_windows",
  # "monitors",
  # "toggle_dpms",
  # "magnify",
  "expose",
  "shift_monitors",
  # "workspaces_follow_focus",
]

# [workspaces_follow_focus]
# max_workspaces = 9

[expose]
include_special = false

# [scratchpads.stb]
# animation = "fromBottom"
# command = "kitty --class kitty-stb sstb"
# class = "kitty-stb"
# lazy = true
# size = "75% 45%"

# [scratchpads.stb-logs]
# animation = "fromTop"
# command = "kitty --class kitty-stb-logs stbLog"
# class = "kitty-stb-logs"
# lazy = true

[scratchpads.term]
animation = "fromBottom"
unfocus = "hide"
command = "alacritty --class alacritty-drop-term"
# class = "alacritty"
# lazy = true
# size = "50% 50%"
# max_size = "50% 50%"

[scratchpads.blue]
animation = "fromBottom"
unfocus = "hide"
command = "alacritty --class alacritty-drop-term -e bluetuith"
# class = "alacritty"
# lazy = true
# size = "40% 90%"
# position = "50% 50%"


[scratchpads.wifi]
animation = "fromBottom"
unfocus = "hide"
command = "alacritty --class alacritty-drop-term -e nmtui"
# class = "alacritty"
# lazy = true
# size = "40% 90%"
# position = "50% 50%"


[scratchpads.volume]
animation = "fromBottom"
command = "pavucontrol"
class = "pavucontrol"
lazy = true
# size = "40% 90%"
unfocus = "hide"

# [monitors]
# unknown = "wlrlui"

# [monitors.placement]
# "Sony".top_of = ["Brand X", "Other Brand"]
# "Acer".left_end_of = "Sony"
# "MSI Gaming stuff".bottom_center_of = "(HDMI-A-1)"

Oooh, I overlooked something, apparently this error comes from the reply hyprland is providing which doesn't have a correct syntax (?!).

What is returned by hyprctl version -j ?

Here you go:


> hyprctl version -j
{
    "branch": "",
    "commit": "",
    "dirty": true,
    "commit_message": "",
    "commit_date": "",
    "tag": "",
    "commits": ,
    "flags": []
}

Ok, now it's much more clear :)
I believe either there is a huge bug in Hyprland "git" (or the version you are using) or it wasn't built properly.

  • no (required) information is provided
  • it's not even managed by Hyprland properly (to miss all the commit/version data) hence it's not returning valid JSON (check "commits": missing a value... which is the line 8 of the response....)

So I suggest that you check your Hyprland package first, if it happens to be a real bug and not a build issue then report it in the Hyprland github.

Before closing this issue, may I ask how you got such "blank" build? Which distro/build system etc ?

Hi!
I am using the hyprland rpm that OpenSuse Tumbleweed provides. I should try to boot up on older snapper version to see if an older "hyprctl version -j" does provide any info. (Maybe I'll just use the hyprland binary provided @ git directly)
Thanks for looking into this issue. :-D

I reverted to an old version of OSuseTW (around 10days old) same behavior as noted.
So decided to run an old version of pyprland that was running fine -> 2.2.8. Here pypr starts up without any issues. Not sure if that is any help for you.

If you need any info, I´d be happy to help

So the problem seats with TW.... it is expected that older pyprland aren't failing: they were not checking the Hyprland version.... hence not hitting this packaging issue.

Hope it makes sense... What I can do is implementing a "fallback" for such bogus case, which will need to be conservative and disable features requiring a recent Hyprland version. Most of the time I don't think this will be noticed (very minor behavior change).

Btw, you can work around it early before I push the change by moving one line as follows:

image

Latest git version should not fail anymore, re-open if that's not the case.
I also added an exception, so not having any tag will assume it's a recent version instead of assuming it's an old one... is your Hyprland >0.39.0 ?

FYI, I just updated nixos (unstable) and i am having this issue now as well.

Only 2.2.12 handles that in a robust way (at least that's the hope ;p).
Nix is lagging a tiny bit behind... do you have an option to use a "git" package or just update the package to pull 2.2.12 instead of 2.2.10 ?