title: lisp as a shebang script vs lisp running in SLIME
body: <p>I just started with common-lisp, having come from C++ and Python. I'm trying to run a simple SDL program that does nothing other than show an image on-screen. I can get it working from within SLIME. The problem is, it won't work when run from the shell as a script.</p>
  
  <p>My program looks like this:</p>
  
  <pre><code>#!/usr/bin/sbcl --script
  
  (asdf:operate 'asdf:load-op :lispbuilder-sdl)
  
  (defun main ()
    (sdl:with-init ()
      (sdl:window 320 240)
      (sdl:draw-surface (sdl:load-image "image.png"))
      (sdl:update-display)
      (sdl:with-events ()
        (:quit-event () t)
        (:video-expose-event () (sdl:update-display)))))
  
  (main)
  </code></pre>
  
  <p>When I run this as a script, I get the following error:</p>
  
  <pre><code>mkg@chisel:~/projects/common-lisp/sandbox$ ./hello-world.lisp 
  unhandled ASDF:MISSING-COMPONENT in thread #&lt;SB-THREAD:THREAD "initial thread" RUNNING {AA5E849}&gt;:
    component "lispbuilder-sdl" not found
  
  0: (SB-DEBUG::MAP-BACKTRACE #&lt;CLOSURE (LAMBDA #) {AAF1EF5}&gt;)[:EXTERNAL]
  </code></pre>
  
  <p>(... long backtrace omitted)</p>
  
  <p>Oddly, this program works fine if I do the following. I open the program in Emacs, start SLIME in another window, and in the SLIME window, I enter the first line of the program:</p>
  
  <pre><code>(asdf:operate 'asdf:load-op :lispbuilder-sdl)
  </code></pre>
  
  <p>Then, in the editor window, I hit C-c C-k (compile/load file). This pops up a window showing image.png, as expected.</p>
  
  <p>Why does this not work when run as a shebang script? How can I fix it?</p>