greghendershott / racket-mode

Emacs major and minor modes for Racket: edit, REPL, check-syntax, debug, profile, packages, and more.
https://www.racket-mode.com/
GNU General Public License v3.0
682 stars 93 forks source link

repl doesn't start #468

Closed arademaker closed 4 years ago

arademaker commented 4 years ago

C-c C-z doesn't start the repl. The command M-x racket-repl doesn't start the repl... No error message..

``` ((alist-get 'racket-mode package-alist) #s(package-desc racket-mode (20200509 1405) "Racket editing, REPL, and more" ((emacs (25 1)) (faceup (0 0 2)) (pos-tip (20191127 1028))) nil nil "/Users/ar/.emacs.d/elpa/racket-mode-20200509.1405" ((:url . "https://www.racket-mode.com/") (:maintainer "Greg Hendershott") (:authors ("Greg Hendershott"))) nil)) ((emacs-version "26.3") (system-type darwin) (major-mode lisp-interaction-mode) (racket--el-source-dir UNDEFINED) (racket--rkt-source-dir UNDEFINED) (racket-program "/usr/local/bin/racket") (racket-command-timeout 10) (racket-xp-after-change-refresh-delay 1) (racket-xp-highlight-unused-regexp "^[^_]") (racket-repl-buffer-name-function nil) (racket-memory-limit 2048) (racket-error-context medium) (racket-history-filter-regexp "\\`\\s *\\S ?\\S ?\\s *\\'") (racket-images-inline t) (racket-images-keep-last 100) (racket-images-system-viewer "open") (racket-images-system-viewer "open") (racket-use-repl-submit-predicate nil) (racket-pretty-print t) (racket-indent-curly-as-sequence t) (racket-indent-sequence-depth 0) (racket-pretty-lambda nil) (racket-smart-open-bracket-enable nil) (racket-module-forms "\\s(\\(?:module[*+]?\\|library\\)") (racket-logger-config ((cm-accomplice . warning) (GC . info) (module-prefetch . warning) (optimizer . info) (racket/contract . error) (sequence-specialization . info) (* . fatal))) (racket-show-functions (racket-show-echo-area racket-show-pos-tip))) (enabled-minor-modes (TeX-PDF-mode) (async-bytecomp-package-mode) (auto-composition-mode) (auto-compression-mode) (auto-encryption-mode) (auto-fill-mode) (auto-save-mode) (blink-cursor-mode) (column-number-mode) (diff-auto-refine-mode) (eldoc-mode) (electric-indent-mode) (file-name-shadow-mode) (font-lock-mode) (global-eldoc-mode) (global-font-lock-mode) (global-git-commit-mode) (global-magit-file-mode) (golden-ratio-mode) (line-number-mode) (magit-auto-revert-mode) (menu-bar-mode) (mouse-wheel-mode) (override-global-mode) (paredit-mode) (persistent-scratch-autosave-mode) (shell-dirtrack-mode) (show-paren-mode) (tooltip-mode) (transient-mark-mode) (winner-mode)) (disabled-minor-modes (LaTeX-math-mode) (TeX-Omega-mode) (TeX-interactive-mode) (TeX-source-correlate-mode) (abbrev-mode) (archive-subfile-mode) (auto-fill-function) (auto-revert-mode) (auto-revert-tail-mode) (auto-save-visited-mode) (buffer-read-only) (cl-old-struct-compat-mode) (command-log-mode) (company-mode) (company-search-mode) (compilation-in-progress) (compilation-minor-mode) (compilation-shell-minor-mode) (completion-in-region-mode) (defining-kbd-macro) (diff-minor-mode) (dired-hide-details-mode) (electric-layout-mode) (electric-pair-mode) (electric-quote-mode) (ess-debug-minor-mode) (ess-listing-minor-mode) (ess-r-package-mode) (ess-roxy-mode) (ess-transcript-minor-mode) (flycheck-mode) (flymake-mode) (flyspell-mode) (git-commit-mode) (global-auto-revert-mode) (global-command-log-mode) (global-company-mode) (global-flycheck-mode) (global-prettify-symbols-mode) (global-visual-line-mode) (horizontal-scroll-bar-mode) (hs-minor-mode) (ido-everywhere) (isearch-mode) (ispell-minor-mode) (jit-lock-debug-mode) (julia-math-mode) (magit-blame-mode) (magit-blame-read-only-mode) (magit-blob-mode) (magit-file-mode) (magit-wip-after-apply-mode) (magit-wip-after-save-local-mode) (magit-wip-after-save-mode) (magit-wip-before-change-mode) (magit-wip-initial-backup-mode) (magit-wip-mode) (mail-abbrevs-mode) (mml-mode) (next-error-follow-minor-mode) (org-cdlatex-mode) (org-src-mode) (orgstruct-mode) (outline-minor-mode) (overwrite-mode) (paragraph-indent-minor-mode) (persistent-scratch-mode) (prettify-symbols-mode) (server-mode) (sh-electric-here-document-mode) (shell-command-with-editor-mode) (show-smartparens-global-mode) (show-smartparens-mode) (size-indication-mode) (slime-edit-value-mode) (slime-editing-mode) (slime-macroexpansion-minor-mode) (slime-mode) (slime-popup-buffer-mode) (smartparens-global-mode) (smartparens-global-strict-mode) (smartparens-mode) (smartparens-strict-mode) (smerge-mode) (spaceline-helm-mode) (spaceline-info-mode) (table-fixed-width-mode) (table-mode-indicator) (temp-buffer-resize-mode) (tool-bar-mode) (tracking-mode) (transient-resume-mode) (unify-8859-on-decoding-mode) (unify-8859-on-encoding-mode) (url-handler-mode) (use-hard-newlines) (view-mode) (visible-mode) (visual-line-mode) (which-function-mode) (window-divider-mode) (with-editor-mode) (xref-etags-mode) (yas-global-mode) (yas-minor-mode) (zoom-mode)) ```
greghendershott commented 4 years ago

Hmm. These catch my eye:

(racket--el-source-dir UNDEFINED)
(racket--rkt-source-dir UNDEFINED)

Normally these values are strings that are pathnames -- dirs under load-file-name:

(defconst racket--el-source-dir
  (file-name-directory (or load-file-name (racket--buffer-file-name)))
  "Path to dir of our Emacs Lisp source files.
When installed as a package, this can be found from the variable
`load-file-name'. When developing interactively, get it from the
.el buffer file name.")

(defconst racket--rkt-source-dir
  (expand-file-name "./racket/" racket--el-source-dir)
  "Path to dir of our Racket source files. ")

So for example if you installed Racket Mode from MELPA, racket--el-source-dir would be a string like (say) "/Users/ar/.emacs.d/elpa/racket-mode-20200509.1405". I don't understand how it would instead be the symbol 'UNDEFINED.

How did you install Racket Mode?

arademaker commented 4 years ago

MELPA, I believe! I have in my init.el:

(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
(add-to-list 'package-archives '("org"   . "http://orgmode.org/elpa/") t)
(add-to-list 'package-archives '("gnu"   . "https://elpa.gnu.org/packages/") t)
(package-initialize)
greghendershott commented 4 years ago

Yes, that looks like MELPA.

Could you please:

  1. C-h v and enter racket--run.rkt (note the double hyphens --): What is the value?

  2. C-h v and enter racket-adjust-run-rkt: What is the value?

  3. Also, is this your first time using Racket Mode? OR, did you update the package recently -- and if so did it used to work but stopped, now?

arademaker commented 4 years ago
racket--run\.rkt is a variable defined in ‘racket-cmd.el’.
Its value is
"/Users/ar/.emacs.d/elpa/racket-mode-20200509.1405/racket/main.rkt"

Documentation:
Pathname of run.rkt.
racket-adjust-run-rkt is a variable defined in ‘racket-cmd.el’.
Its value is ‘identity’

Documentation:
A function used to transform the variable ‘racket--run.rkt’.

You probably don’t need to change this unless you are developing
Racket Mode, AND run Emacs on Windows Subsystem for Linux, AND
want to run your programs using Windows Racket.exe, AND have the
Racket Mode source code under "/mnt". Whew. In that case you
can set this variable to the function ‘racket-wsl-to-windows’ so
that Racket Mode can find its own run.rkt file.

No. I have used before and I was able to run the repl. But I don't use it very ofen, so probably I have updated the packages more than one time before notice the error.

greghendershott commented 4 years ago

Does /Users/ar/.emacs.d/elpa/racket-mode-20200509.1405/racket/main.rkt exist?

(The value of racket--run.rkt is based on racket--rkt-source-dir. So if the latter is 'UNDEFINED I'm confused how the former could be /Users/ar/.emacs.d/elpa/racket-mode-20200509.1405/racket/main.rkt. But however it got that value, it seems like a reasonable value. So I'd just like to confirm that, to narrow down the possibility tree.)

greghendershott commented 4 years ago

Also, it might be worth trying this. I realize it's a PITA, and often it's not needed. But since things seems to be in such a mysterious (to me) state, it's probably warranted?

arademaker commented 4 years ago

Yes.

% file /Users/ar/.emacs.d/elpa/racket-mode-20200509.1405/racket/main.rkt
/Users/ar/.emacs.d/elpa/racket-mode-20200509.1405/racket/main.rkt: ASCII text
arademaker commented 4 years ago

Done, I removed the package, restarted Emacs, installed the package again. Same behaviour.... C-c C-z does not start the repl.

greghendershott commented 4 years ago

Interesting.

What if you M-x racket-start-back-end? Do you see any error message? How about in the *Messages* buffer (just in case the message didn't appear in the echo area for some reason).


Something else to try:

  1. M-x racket-logger. A *Racket Logger* buffer should appear.

  2. Type l.

  3. Enter racket-mode for the topic.

  4. Enter debug for the level.

  5. Now try again to M-x racket-repl. Please copy that tail end of the *Racket Logger* buffer, and paste it here.

Thank you!

arademaker commented 4 years ago

Hi @greghendershott , thank you very much for your attention. After step 1, I got the screen attached below

image

Note that l didn't give me the option racket-mode in the list. What should I do from here?

greghendershott commented 4 years ago

It should allow you to type something new, not already on the list. Can you type racket-mode and ENTER?

greghendershott commented 4 years ago

If it doesn't allow you to type something new, then that's a separate issue I'll investigate! :smile: It definitely does for me. Anyway, in that case, perhaps you could M-x customize-mode, and among the Racket options choose Other, choose Logger Configuration, and INS a new racket-mode item with the value debug.

greghendershott commented 4 years ago

I guess you could also just M-x eval-expression and enter (add-to-list 'racket-logger-config '(racket-mode . debug)) for a one-time thing.

arademaker commented 4 years ago

OK, I have added racket-mode with value debug using the customize-mode. I have also checked the value of racket-logger-config:

((cm-accomplice . warning) (GC . info) (module-prefetch . warning) (optimizer . info) (racket/contract . error) (sequence-specialization . info) (* . fatal) (racket-mode . debug))

But in the *Racket Logger* I didn't see any change once I call M-x racket-repl. The content is:

racket-logger-config:
((cm-accomplice . warning)
 (GC . info)
 (module-prefetch . warning)
 (optimizer . info)
 (racket/contract . error)
 (sequence-specialization . info)
 (* . fatal)
 (racket-mode . debug))
racket-logger-config:
((cm-accomplice . warning)
 (GC . info)
 (module-prefetch . warning)
 (optimizer . info)
 (racket/contract . error)
 (sequence-specialization . info)
 (* . fatal)
 (racket-mode . debug))
greghendershott commented 4 years ago

OK, well that in itself is interesting information. What we seem to know now:

racket-logger-config:
((racket-mode-syntax-cache . debug)
 (TR-optimizer . info)
 (racket-mode . debug)
 (cm-accomplice . warning)
 (GC . info)
 (module-prefetch . warning)
 (optimizer . warning)
 (racket/contract . error)
 (sequence-specialization . info)
 (* . fatal))
[   info] racket-mode: TCP port 39241 chosen for REPL sessions
[   info] racket-mode: '(1427 "*" (repl-tcp-port-number))
[  debug] racket-mode: (call-with-session-context '() #<procedure:command> '((repl-tcp-port-number))): no specific session
[   info] racket-mode: start "repl-session-0"
[  debug] racket-mode: (set-session! "repl-session-0" #f #f) => sessions: (hash "repl-session-0" (session #<thread:repl-thunk> #<channel> #f #<namespace> #f))
[  debug] racket-mode: (set-session! "repl-session-0" #f #f) => sessions: (hash "repl-session-0" (session #<thread:repl-thunk> #<channel> #f #<namespace> #f))
[   info] racket-mode: '(1428 "repl-session-0" (syms))
[  debug] racket-mode: (call-with-session-context "repl-session-0" #<procedure:command> '((syms))) => (session #<thread:repl-thunk> #<channel> #f #<namespace> #f)
[   info] racket-mode: '(1429 "repl-session-0" (break terminate))

Next: While you have the racket-mode logger topic set to debug, please try M-x racket-start-back-end again, and tell me the logger output? Thank you!

greghendershott commented 4 years ago

(Note: M-x racket-start-back-end is really "restart". If back end already running, it will be stopped and started again. So you should see some logger output. If you still don't, that will be the interesting fact for me to consider.)

(Note: Normally things you do in Racket Mode will start the back end automatically. That's why I haven't documented the racket-start-back-end and racket-stop-back-end commands. In a happy world you wouldn't need to use them.)

greghendershott commented 4 years ago

One other idea: It is rare but possible there might be stderr output that the logger would not (or could not) show. To check for this, switch to the buffer " *racket-process-stderr*". The leading space in the buffer name is important. This tells Emacs to hide the buffer from normal pick-a-buffer lists. You'll need to type that buffer name, including the leading space. If you have trouble switching to this buffer, let me know. Anyway, there might be some useful output, there.

If you see any content in that buffer other than Process racket-process stderr finished, please let me know? (After trying commands like M-x racket-start-back-end and M-x racket-repl.) Thanks!

arademaker commented 4 years ago

I see nothing in the logger when I execute M-x racket-start-back-end

image

In the *racket-process-stderr* I see

standard-module-name-resolver: collection not found
  for module path: gui-debugger/marks
  collection: "gui-debugger"
  in collection directories:
   /Users/ar/Library/Racket/7.6/collects
   /usr/local/Cellar/minimal-racket/7.6/share/racket/collects
  context...:
   show-collection-err
   standard-module-name-resolver
   module-path-index-resolve
   perform-require!
   for-loop
   finish
   [repeats 2 more times]
   pass-1-and-2-loop
   module-begin-k
   expand-module
   expand-capturing-lifts
   temp98_0
   temp71_0
   compile
   temp65_0
   standard-module-name-resolver
   ...

Process racket-process stderr finished
standard-module-name-resolver: collection not found
  for module path: gui-debugger/marks
  collection: "gui-debugger"
  in collection directories:
   /Users/ar/Library/Racket/7.6/collects
   /usr/local/Cellar/minimal-racket/7.6/share/racket/collects
  context...:
   show-collection-err
   standard-module-name-resolver
   module-path-index-resolve
   perform-require!
   for-loop
   finish
   [repeats 2 more times]
   pass-1-and-2-loop
   module-begin-k
   expand-module
   expand-capturing-lifts
   temp98_0
   temp71_0
   compile
   temp65_0
   standard-module-name-resolver
   ...

Process racket-process stderr finished
standard-module-name-resolver: collection not found
  for module path: gui-debugger/marks
  collection: "gui-debugger"
  in collection directories:
   /Users/ar/Library/Racket/7.6/collects
   /usr/local/Cellar/minimal-racket/7.6/share/racket/collects
  context...:
   show-collection-err
   standard-module-name-resolver
   module-path-index-resolve
   perform-require!
   for-loop
   finish
   [repeats 2 more times]
   pass-1-and-2-loop
   module-begin-k
   expand-module
   expand-capturing-lifts
   temp98_0
   temp71_0
   compile
   temp65_0
   standard-module-name-resolver
   ...

Process racket-process stderr finished
standard-module-name-resolver: collection not found
  for module path: gui-debugger/marks
  collection: "gui-debugger"
  in collection directories:
   /Users/ar/Library/Racket/7.6/collects
   /usr/local/Cellar/minimal-racket/7.6/share/racket/collects
  context...:
   show-collection-err
   standard-module-name-resolver
   module-path-index-resolve
   perform-require!
   for-loop
   finish
   [repeats 2 more times]
   pass-1-and-2-loop
   module-begin-k
   expand-module
   expand-capturing-lifts
   temp98_0
   temp71_0
   compile
   temp65_0
   standard-module-name-resolver
   ...

Process racket-process stderr finished
arademaker commented 4 years ago

It is strange because, from the prompt, I can start Racket normally:

ar@leme ~ % which racket
/usr/local/bin/racket
ar@leme ~ % racket
Welcome to Racket v7.6.
>

Calling the same rkt file I don't have any error too:

ar@leme main % racket ex-1.15.rkt
ar@leme main %
arademaker commented 4 years ago

In the buffer *racket-process* I see


Process racket-process exited abnormally with code 1

Process racket-process exited abnormally with code 1

Process racket-process exited abnormally with code 1

Process racket-process exited abnormally with code 1
greghendershott commented 4 years ago
  1. While I was waiting for you to reply, I realized that I should "surface" any stderr output to make this kind of investigation easier for folks like you (and me). :smile: So I have a commit (not yet merged), to display the stderr buffer automatically when it receives output.

  2. The error is that the back end Racket Mode program is trying to use the collection, gui-debugger/marks. Probably this information about using Minimal Racket applies -- does doing a raco pkg install drracket resolve it for you?

arademaker commented 4 years ago

Wow!! Finally I got the REPL. It looks like the raco pkg install drracket was the missing step!

image

Now I will try to understand how to uninstall the DrRacket from my Applications folder that I installed from https://download.racket-lang.org/racket-v7.6.html. The ideia is to keep only the instalation from the brew. Actually, I was expecting that the raco command above would also give me the DrRacket IDE, but that is not the case, right ? I didn't find in my path the DrRacket command. But ok, I can now live in Emacs with racket-mode! ;-)

greghendershott commented 4 years ago

Yay! :tada:

  1. I'm sorry that Racket Mode startup fails this way, so silently. As I mentioned above, I'm already working on making it fail more noisily.

  2. I'm not sure if installing the drracket package installs the DrRacket application. But I'm also not sure how much more space the app would really add, compared to all the libraries? In that vein...

  3. The drracket package has dependencies that Racket Mode doesn't need. I suggest installing it as a simple, one-line, reliable thing to do.

    I'll investigate the minimal actual dependencies. Then I'll update the docs.

    Also, I'll look into checking the deps installed on startup, and a message repeating how to install. Maybe I'll even offer to run raco pkg install, to do it.

I'll create those to-do items as separate issues, in case you want to close this one (unless you have more questions/problems).

p.s. Thank you for being so patient and including such great information and screen caps!

greghendershott commented 4 years ago

I'm going to close this because:

If you disagree, please feel free to re-open, and/or add more comments here.

gwangjinkim commented 2 years ago

I still had this problem on my ubuntu. raco pkg install drracket - I missed that totally. Thank you a lot!