syl20bnr / spacemacs

A community-driven Emacs distribution - The best editor is neither Emacs nor Vim, it's Emacs *and* Vim!
http://spacemacs.org
GNU General Public License v3.0
23.69k stars 4.89k forks source link

Reporting issue with `SPC h I` generates error: variable is void: system-info #8028

Closed nixmaniack closed 7 years ago

nixmaniack commented 7 years ago

Description :octocat:

Reporting issue with SPC h I generates error. Although SPC h d s works fine.

Reproduction guide :beetle:

Observed behaviour: :eyes: :broken_heart: Got error: Symbol’s value as variable is void: system-info

Expected behaviour: :heart: :smile: Open buffer to report issue with template pre-filled.

System Info :computer:

Backtrace :paw_prints:

Debugger entered--Lisp error: (void-variable system-info)
  symbol-value(system-info)
  (replace-match (symbol-value replacement) [keep-case] [literal])
  (save-excursion (goto-char (point-min)) (search-forward placeholder) (replace-match (symbol-value replacement) [keep-case] [literal]))
  (while (consp --cl-var--) (setq --cl-var-- (car --cl-var--) placeholder (pop --cl-var--) replacement (car --cl-var--)) (save-excursion (goto-char (point-min)) (search-forward placeholder) (replace-match (symbol-value replacement) [keep-case] [literal])) (setq --cl-var-- (cdr --cl-var--)))
  (let* ((--cl-var-- (quote (("%SYSTEM_INFO%" system-info) ("%BACKTRACE%" backtrace) ("(%LAST_KEYS%)\n" last-keys)))) (placeholder nil) (replacement nil) (--cl-var--)) (while (consp --cl-var--) (setq --cl-var-- (car --cl-var--) placeholder (pop --cl-var--) replacement (car --cl-var--)) (save-excursion (goto-char (point-min)) (search-forward placeholder) (replace-match (symbol-value replacement) [keep-case] [literal])) (setq --cl-var-- (cdr --cl-var--))) nil)
  (catch (quote --cl-block-nil--) (let* ((--cl-var-- (quote (("%SYSTEM_INFO%" system-info) ("%BACKTRACE%" backtrace) ("(%LAST_KEYS%)\n" last-keys)))) (placeholder nil) (replacement nil) (--cl-var--)) (while (consp --cl-var--) (setq --cl-var-- (car --cl-var--) placeholder (pop --cl-var--) replacement (car --cl-var--)) (save-excursion (goto-char (point-min)) (search-forward placeholder) (replace-match (symbol-value replacement) [keep-case] [literal])) (setq --cl-var-- (cdr --cl-var--))) nil))
  (cl--block-wrapper (catch (quote --cl-block-nil--) (let* ((--cl-var-- (quote (("%SYSTEM_INFO%" system-info) ("%BACKTRACE%" backtrace) ("(%LAST_KEYS%)\n" last-keys)))) (placeholder nil) (replacement nil) (--cl-var--)) (while (consp --cl-var--) (setq --cl-var-- (car --cl-var--) placeholder (pop --cl-var--) replacement (car --cl-var--)) (save-excursion (goto-char (point-min)) (search-forward placeholder) (replace-match (symbol-value replacement) [keep-case] [literal])) (setq --cl-var-- (cdr --cl-var--))) nil)))
  (cl-block nil (let* ((--cl-var-- (quote (("%SYSTEM_INFO%" system-info) ("%BACKTRACE%" backtrace) ("(%LAST_KEYS%)\n" last-keys)))) (placeholder nil) (replacement nil) (--cl-var--)) (while (consp --cl-var--) (setq --cl-var-- (car --cl-var--) placeholder (pop --cl-var--) replacement (car --cl-var--)) (save-excursion (goto-char (point-min)) (search-forward placeholder) (replace-match (symbol-value replacement) [keep-case] [literal])) (setq --cl-var-- (cdr --cl-var--))) nil))
  (loop for (placeholder replacement) in (quote (("%SYSTEM_INFO%" system-info) ("%BACKTRACE%" backtrace) ("(%LAST_KEYS%)\n" last-keys))) do (save-excursion (goto-char (point-min)) (search-forward placeholder) (replace-match (symbol-value replacement) [keep-case] [literal])))
  (let ((buf (generate-new-buffer "REPORT_SPACEMACS_ISSUE")) (system-info (spacemacs//describe-system-info-string)) (backtrace (if (get-buffer "*Backtrace*") (with-current-buffer "*Backtrace*" (buffer-substring-no-properties (point-min) (min (point-max) 1000))) "<<BACKTRACE IF RELEVANT>>")) (last-keys (if (and arg (y-or-n-p (concat "Do you really want to " "include your last pressed keys? It " "may include some sensitive data."))) (concat (spacemacs//describe-last-keys-string) "\n") ""))) (switch-to-buffer buf) (insert-file-contents-literally (concat configuration-layer-template-directory "REPORTING.template")) (loop for (placeholder replacement) in (quote (("%SYSTEM_INFO%" system-info) ("%BACKTRACE%" backtrace) ("(%LAST_KEYS%)\n" last-keys))) do (save-excursion (goto-char (point-min)) (search-forward placeholder) (replace-match (symbol-value replacement) [keep-case] [literal]))) (spacemacs/report-issue-mode))
  spacemacs/report-issue(nil)
  funcall-interactively(spacemacs/report-issue nil)
  call-interactively(spacemacs/report-issue nil nil)
  command-execute(spacemacs/report-issue)
deb0ch commented 7 years ago

It comes from this commit: 467a5cc0ff0677698158f2e8079ad37f72e8d059, which is weird because all that commit does is moving code around without apparently leaving a related dependency behind... :confused:

deb0ch commented 7 years ago

I found it: lexical binding is activated in core-debug and not in the previous file, which causes replace-match to fail because system-info is not defined in the loop special form anymore with lexical binding activated.

Or something along those lines, my understanding of lexical binding is still kinda blurry and I'm not sure how to go about this bug :thinking:

@syl20bnr any insights ?

nixmaniack commented 7 years ago

@deb0ch When I edebugged I did think about lexical binding but I remember Spacemacs not using it[1]. Nice catch.

[1]. Based on this comment https://github.com/syl20bnr/spacemacs/pull/4491#r49259958

deb0ch commented 7 years ago

Nevermind, it is not about the loop special form, it is actually about the symbol-value function:

symbol-value is a built-in function in `C source code'.

(symbol-value SYMBOL)

Return SYMBOL's value. Error if that is void. Note that if `lexical-binding' is in effect, this returns the global value outside of any lexical scope.

[back]

d12frosted commented 7 years ago

@deb0ch be a good person and send a PR 😸

deb0ch commented 7 years ago

I would, I just don't know a) Spacemacs policy about lexical-binding, so if I should or not deactivate it in this file, and b) if keeping lexical binding what equivalent to symbol-value would work in our situation.

syl20bnr commented 7 years ago

Thank you for the investigation, I was able to fix it in commit https://github.com/syl20bnr/spacemacs/commit/105a0a1

deb0ch commented 7 years ago

Oh, it was that simple :open_mouth:

Anyways, I now see that we want to keep lexical bindings where it is (am I right ?).

syl20bnr commented 7 years ago

Anyways, I now see that we want to keep lexical bindings where it is (am I right ?).

Yes, actually I'm not even sure to know one reason where we would like to not use it.