I see that a few packages, and package.el use (file-name-directory #$). How does Emacs know what directory #$ is? On OSX, that returns Wrong type argument: stringp, nil.

Excerpt from cl-lib.el when installing a package evil-mc through the package manager, which goes into cl-lib-autoloads.el and then Emacs chokes:

;; First line of defense: try to make sure the built-in cl-lib comes earlier in
;; load-path so we never get loaded:
;;;###autoload (let ((d (file-name-directory #$)))
;;;###autoload   (when (member d load-path)
;;;###autoload     (setq load-path (append (remove d load-path) (list d)))))
  • 1
    Can you show an example of its use?
    – Drew
    Jun 26, 2017 at 3:46
  • @Drew -- Thanks, I updated the question with a specific example. As to package-autoload-ensure-default-file, I added (or (and #$ (file-name-directory #$)) ...) to avoid an error. But, I have no control over fixing the entry in cl-lib.el that the package manager is installing . . . .
    – lawlist
    Jun 26, 2017 at 3:52
  • I also get Lisp error: (wrong-type-argument stringp nil) file-name-directory(nil) on macOS from (file-name-directory #$), but only when using --debug-init. This is with the emacs-mac port. Oct 24, 2019 at 14:14
  • I find that I typically get this error after updating packages, and I can fix it by deleting all elc files (then recompiling them). Nov 14, 2019 at 15:56

1 Answer 1


M-x elisp-index-search RET #$ RET tells us:

   Internally, the dynamic loading of documentation strings is
accomplished by writing compiled files with a special Lisp reader
construct, ‘#@COUNT’.  This construct skips the next COUNT characters.
It also uses the ‘#$’ construct, which stands for the name of this file,
as a string.  Do not use these constructs in Lisp source files; they are
not designed to be clear to humans reading the file.

C-hig (elisp)Docs and Compilation

  • 1
    Never heard of elisp-index-search. Thank you for teaching me how to fish.
    – pedz
    Oct 25, 2022 at 14:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.