Wanting to set up a pleasant shell environment in Emacs, I invested in getting
Eshell happy. Everything went well but the fact that directory name
completion doesn’t work. The error message appeared:
Invalid variable reference
Lately I’ve been learning more about how to develop (or re-learning depending upon
how you look at it) so I set up the debugger to run when the error occurred:
(toggle-debug-on-error)
to receive:
Debugger entered--Lisp error: (error "Invalid variable reference") signal(error ("Invalid variable reference")) error("Invalid variable reference") eshell-parse-variable-ref() eshell-parse-variable() eshell-interpolate-variable() run-hook-with-args-until-success(eshell-interpolate-variable) byte-code("m\204-\303\304!\206\305\306f!\306u\210 \204\202)\n\204$ C\307 C\244\210)\202\306\207" [result eshell-current-argument eshell-arg-listified run-hook-with-args-until-success eshell-parse-argument-hook char-to-string nil t] 2) eshell-parse-argument() byte-code("m?\205$`\303 `U\203\304\305d{\"\210 \203 \n C\244\210*\202\207" [here arg args eshell-parse-argument error "Failed to parse argument '%s'"] 4) eshell-parse-arguments(29 #<marker at 43 in *eshell*>) byte-code("\303\304 \"\207" [begin end args nil eshell-parse-arguments] 4) eshell-complete-parse-arguments() pcomplete-parse-arguments(nil) #[0 "\306!\2053 \nU\203 \207\307\f !\206 \310 T\311 \nV\203.\312\313!\210\314\315\310\"\210 \210\262\207" [pcomplete-expand-before-complete pcomplete-index pcomplete-last pcomplete-command-completion-function pcomplete-command-name-function pcomplete-default-completion-function pcomplete-parse-arguments pcomplete-find-completion-function nil pcomplete-arg message "No completions" throw pcompleted pcomplete-stub] 5 "\n\n(fn)"]() funcall(#[0 "\306!\2053 \nU\203 \207\307\f !\206 \310 T\311 \nV\203.\312\313!\210\314\315\310\"\210 \210\262\207" [pcomplete-expand-before-complete pcomplete-index pcomplete-last pcomplete-command-completion-function pcomplete-command-name-function pcomplete-default-completion-function pcomplete-parse-arguments pcomplete-find-completion-function nil pcomplete-arg message "No completions" throw pcompleted pcomplete-stub] 5 "\n\n(fn)"]) pcomplete-completions() #[0 "\306\211\306\211\306\211\f\f \307 \310\"\211\2056\211@\311=?\2056\211A\2056\312A@\313>$.\207" [pcomplete-stub pcomplete-seen pcomplete-norm-func pcomplete-args pcomplete-last pcomplete-index nil pcomplete-completions pcomplete-do-complete listed pcomplete-insert-entry (sole shortest) pcomplete-autolist pcomplete-suffix-list pcomplete-last-completion-raw] 8 "\n\n(fn)"]() funcall(#[0 "\306\211\306\211\306\211\f\f \307 \310\"\211\2056\211@\311=?\2056\211A\2056\312A@\313>$.\207" [pcomplete-stub pcomplete-seen pcomplete-norm-func pcomplete-args pcomplete-last pcomplete-index nil pcomplete-completions pcomplete-do-complete listed pcomplete-insert-entry (sole shortest) pcomplete-autolist pcomplete-suffix-list pcomplete-last-completion-raw] 8 "\n\n(fn)"]) pcomplete(1) call-interactively(pcomplete) byte-code("\203\301\302!\207\302 \207" [interactively call-interactively pcomplete] 2) eshell-pcomplete(1) call-interactively(eshell-pcomplete nil nil)
This stacktrace is simpler because I unloaded yasnippet. This will be a good
project for me to learn more about this environment because right now I’m
not sure how to address an issue like this beyond the standard, universal issue addressing techniques.
I recently experienced exactly same problem. I finally figured out that it was because the `eshell-prompt-regexp’ didn’t match the prompt returned from the `eshell-prompt-function’. Hope this will also solve your problem.
YORK ZHAO:
Thank you. Long ago I fixed using the prompt regex and forgot to update this post with the solution.