cbaggers / cepl

Code Evaluate Play Loop
BSD 2-Clause "Simplified" License
860 stars 52 forks source link

SDL Error in Emacs under WSL2 #347

Closed ghost closed 4 years ago

ghost commented 4 years ago

Hitting (cepl:repl) in slime yields (after a bit of hanging...):

SDL Error (-1): No available video device
   [Condition of type SDL2::SDL-RC-ERROR]

Restarts:
 0: [RETRY] Retry SLIME REPL evaluation request.
 1: [*ABORT] Return to SLIME's top level.
 2: [ABORT] abort thread (#<THREAD "repl-thread" RUNNING {1002579BC3}>)

Backtrace:
  0: (CEPL.SDL2::INIT-SDL2-LOW-LEVEL :EVERYTHING)
  1: ((:METHOD CEPL.SDL2::SDL-INIT NIL)) [fast-method]
  2: (CEPL.HOST:INITIALIZE)
  3: (CEPL:INITIALIZE-CEPL :GL-VERSION NIL :HOST-INIT-FLAGS NIL)
  4: (CEPL:REPL 320 240 NIL)
  5: (SB-INT:SIMPLE-EVAL-IN-LEXENV (CEPL:REPL) #<NULL-LEXENV>)
  6: (EVAL (CEPL:REPL))

However in plain SBCL repl (from the command line) everything works as expected -- the cepl repl is working and the small empty initial window appears!

metayan commented 4 years ago

I'm not at all familiar with WSL2, but these might be two things to try:

1. Run the SDL2 examples

to check if CEPL really is the culprit here, with

(ql:quickload :sdl2/examples)
(sdl2-examples:basic-test)

2. Limit SLIME to one thread

by making a .swank.lisp file in your $HOME directory containing:

(setf *communication-style* nil)

before starting SLIME.

metayan commented 4 years ago

By the way, could you post the value of *features* when running SBCL under WSL2? Noticed https://github.com/cbaggers/cepl.sdl2/blob/6da5a030db5e3579c5a1c5350b1ffb8fc9950e9a/cepl.sdl2.lisp#L177-L180

ghost commented 4 years ago

1. So yeah, cepl is not the problem :) it has to do with sdl2 and slime emacs somehow -- because again, in sbcl repl from command line everything works just fine. So I'm closing the issue 🙈

2. Yes, I had tried that before with no success 😢

3. 👇

(:QUICKLISP :SB-BSD-SOCKETS-ADDRINFO :ASDF3.3 :ASDF3.2 :ASDF3.1 :ASDF3 :ASDF2
 :ASDF :OS-UNIX :NON-BASE-CHARS-EXIST-P :ASDF-UNICODE :X86-64 :64-BIT :ANSI-CL
 :COMMON-LISP :ELF :GENCGC :IEEE-FLOATING-POINT :LINUX :LITTLE-ENDIAN
 :PACKAGE-LOCAL-NICKNAMES :SB-CORE-COMPRESSION :SB-LDB :SB-PACKAGE-LOCKS
 :SB-THREAD :SB-UNICODE :SBCL :UNIX)

Btw I've just tried calling sbcl from eshell and then loading the sdl2 examples: the same error appears (with bits of information added). It definitely has to be something with emacs-the-process being already displayed in the X server and -- I don't know, I will try stuff.

So I am closing because this is not related to cepl's workings, but I will post as soon as I get to somewhere. Thanks for your time!

ghost commented 4 years ago

Update: I was using Spacemacs, the problem is non-existent in 'vanilla' Emacs. I've noticed that the problem solves by resetting the .spacemacs.env file/it might be that when (unrelated) errors arise during a spacemacs startup configuration this file is left in some inconsistent state, leading to problems as soon as spacemacs needs to look up the environment variables. This is only a mild guess though. I am not comfortable enough with spacemacs to say why it happens; what I know is that the issue is reproducible by causing configuration errors (mistyped layer names for example). To get it working again quit emacs, remove the file and start emacs again (with the proper configuration files).

metayan commented 4 years ago

Alright. Good to know. Portacle might be worth a try. (That's what I'm mostly using - on macOS, Linux, and when I'm occasionally expected to do something on Windows.)