From e548c6cdbb95ea81001548ff0b5752ffbc37e760 Mon Sep 17 00:00:00 2001 From: Nathaniel Nicandro Date: Thu, 8 Jun 2023 09:19:17 -0500 Subject: [PATCH] jupyter-available-kernelspecs: Handle parsing kernelspecs better Raise an error when `jupyter kernelspec list --json` doesn't return valid JSON. --- jupyter-kernelspec.el | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/jupyter-kernelspec.el b/jupyter-kernelspec.el index a06420b..b87334a 100644 --- a/jupyter-kernelspec.el +++ b/jupyter-kernelspec.el @@ -76,9 +76,20 @@ REFRESH." (or (and (not refresh) (gethash host jupyter--kernelspecs)) (let ((specs (plist-get - (jupyter-read-plist-from-string - (or (jupyter-command "kernelspec" "list" "--json" "--log-level" "ERROR") - (error "Can't obtain kernelspecs from jupyter shell command"))) + (let ((json (or (jupyter-command "kernelspec" "list" + "--json" "--log-level" "ERROR") + (error "\ +Can't obtain kernelspecs from jupyter shell command")))) + (condition-case nil + (jupyter-read-plist-from-string json) + (error + (error "\ +Jupyter kernelspecs couldn't be parsed from + + jupyter kernelspec list --json + +To investiagate further, run that command in a shell and examine +why it isn't returning valid JSON.")))) :kernelspecs))) (puthash host