reddit / emacs

"make-directory: Wrong type argument: stringp, nil" when trying to load use-package

publicvoit · 2022-10-26 14:30
Hi, I want to make my EmacsConf22 demo self-contained. However, so far I'm failing in setting up the use-package. I've included the start of my setup until the error occurs. I even stole from a different setup, ending up with the very same error (see "FIXXME"). Edit: the Elisp code is supposed to be part of a custom start file when started with \`emacs -q\` ;; parts of the Emacs setup is copied from: https://gitlab.com/skybert/my-little-friends/-/blob/master/emacs/.emacs (defun my-message(string) "Print out a message with mild formatting" (interactive) (message (concat "————→ " string " …")) ) ;; (my-message "") (my-message "START of demo config setup") (my-message "turn off backup files") (setq-default backup-inhibited t) (my-message "set start of week to Monday (not Sunday) as I prefer and it should be according to ISO: https://en.wikipedia.org/wiki/ISO_week_date") (setq-default calendar-week-start-day 1) (my-message "set encoding") (setq locale-coding-system 'utf-8) (set-terminal-coding-system 'utf-8) (set-keyboard-coding-system 'utf-8) (prefer-coding-system 'utf-8) (my-message "creating ephemeral configuration directories including ELPA storage") (make-directory "configuration/elpa" "also create parents") (my-message "setq user-emacs-directory to current directory") (setq user-emacs-directory "configuration") (my-message "setq package-user-dir as sub-directory") (setq package-user-dir "configuration/elpa") ;; local demo elpa tree ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (my-message "Emacs package management") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (my-message "Initialise the emacs packages in case any of them overrides built-in Emacs packages") (package-initialize) (setq gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3") (setq package-archives '(("melpa" . "http://melpa.org/packages/") ("gnu" . "http://elpa.gnu.org/packages/") ) gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3" ) (my-message "Ensure use-package is installed and loaded") (condition-case nil (require 'use-package) (file-error (my-message "require 'package") (require 'package) (my-message "package-initialize") (package-initialize) (my-message "package-refresh-contents") (package-refresh-contents) (my-message "package-install 'use-package") (edebug-all-defs) ;; FIXXME: doesn't catch the issue (package-install 'use-package) ;; FIXXME: I get "make-directory: Wrong type argument: stringp, nil" (my-message "require 'use-package") (require 'use-package))) (my-message "setq use-package-always-ensure: Set to true to have use-package install all packages mentioned if they're not already installed.") (setq use-package-always-ensure t) ;; ... more definitions and functions for the demo setup ... Yes, this is not a minimal example. However, I wanted to make sure to include my whole setup until the issue arises in order to mention any side-effect and also to get feedback from you, if you've got improvement ideas. :-) The end of the output is: [...] ————→ package-install ’use-package … Edebugging all definitions is on. Setting ‘package-selected-packages’ temporarily since "emacs -q" would overwrite customizations [2 times] Contacting host: melpa.org:80 Generating autoloads for bind-key.el...done Wrote /home/vk/src/2022-12 EmacsConf22 - org-super-links demo/configuration/elpa/bind-key-20220910.2157/bind-key-autoloads.el [2 times] Checking /home/vk/src/2022-12 EmacsConf22 - org-super-links demo/configuration/elpa/bind-key-20220910.2157... [3 times] Compiling /home/vk/src/2022-12 EmacsConf22 - org-super-links demo/configuration/elpa/bind-key-20220910.2157/bind-key.el...done Wrote /home/vk/src/2022-12 EmacsConf22 - org-super-links demo/configuration/elpa/bind-key-20220910.2157/bind-key.elc Checking /home/vk/src/2022-12 EmacsConf22 - org-super-links demo/configuration/elpa/bind-key-20220910.2157... Done (Total of 1 file compiled, 2 skipped) Contacting host: melpa.org:80 Parsing tar file...done Extracting use-package-20221012.1743/ make-directory: Wrong type argument: stringp, ni There seems to be an issue with creating a directory. I don't know what to change to fix this. Do you have an idea?
deaddyfreddy · 2022-10-26 17:09
does `toggle-debug-on-error` help?
publicvoit · 2022-10-26 17:32
Edit: outdated (see other comment by me at that level) Somewhat: Debugger entered--Lisp error: (wrong-type-argument stringp nil) directory-file-name(nil) make-directory("use-package-20221012.1743/" t) tar-untar-buffer() package-untar-buffer("use-package-20221012.1743") package-unpack(#s(package-desc :name use-package :version (20221012 1743) :summary "A configuration macro for simplifying your .emacs" :reqs ((emacs (24 3)) (bind-key (2 4))) :kind tar :archive "melpa" :dir nil :extras ((:commit . "28531e9b94c72ed777803e10e391ea287496ffc2") (:authors ("John Wiegley" . "johnw@newartisans.com")) (:maintainer "John Wiegley" . "johnw@newartisans.com") (:keywords "dotemacs" "startup" "speed" "config" "package") (:url . "https://github.com/jwiegley/use-package")) :signed nil)) #f(compiled-function (&optional good-sigs) #<bytecode 0x15b3889>)(nil) [...] To me, it looks like a bug in the package but I doubt it. I couldn't find anything for this error so far.
publicvoit · 2022-10-27 08:10
I now switched to a more recent Emacs version (27.1) and got a different error message: ``` Debugger entered--Lisp error: (file-error "Creating directory" "Permission denied" "/usr/bin/configuration") signal(file-error ("Creating directory" "Permission denied" "/usr/bin/configuration")) files--ensure-directory("/usr/bin/configuration") make-directory("/usr/bin/configuration/elpa/use-package-20221027.4..." t) tar-untar-buffer() package-untar-buffer("use-package-20221027.422") [...] ``` This is much better: it tries to create a directory within `/usr/bin` which is puzzling me. Does anybody have an idea how I have to switch whatever is possible to the local directory? I don't want to modify anything outside of it. So far, ./configuration is created and populated by elpa: bind-key, gnupg, archives.
deaddyfreddy · 2022-10-27 10:15
Probably, instead of setting Emacs directories manually, you may want to override HOME variable (like, to `/tmp/emacsconf` or smth)? I usually do this when I want to experiment with things.
publicvoit · 2022-10-27 12:24
First: is this really the only option here? Re-directing $HOME seems to be a bold move for this purpose. I just want to express Emacs that it should use the local directory for everything it writes via ELPA. I thought that `user-emacs-directory` is here for that purpose. Second: How can re-directing $HOME be done in an OS-independent way? I don't want to put `HOME=$pwd emacs -q ...` in the README.org when I lose all users of Windows with this step.
deaddyfreddy · 2022-10-27 13:31
> First: is this really the only option here? it's not, but looked the easiest one for me The version 29 (not released yet) supports `--init-directory` parameter, which is the same as `user-emacs-directory`. > I just want to express Emacs that it should use the local directory for everything it writes via ELPA. in this case, probably `package-user-dir` will help
publicvoit · 2022-10-27 14:37
`package-user-dir` is set in my code above. So unfortunately, it didn't help in this case or I did an error applying it.
deaddyfreddy · 2022-10-27 14:42
> (setq package-user-dir "configuration/elpa") you've set it using a relative path, but docs say that package-user-dir is a variable defined in ‘package.el’. Its value is "~/.emacs.d/elpa" This variable may be risky if used as a file-local variable. You can customize this variable. This variable was introduced, or its default value was changed, in version 24.1 of Emacs. Probably introduced at or before Emacs version 25.1. Documentation: Directory containing the user’s Emacs Lisp packages. The directory name should be **absolute.** Apart from this directory, Emacs also looks for system-wide packages in ‘package-directory-list’.
publicvoit · 2022-10-27 17:52
**Yes, it's working now!** A classic RTFM on my side. `(setq package-user-dir (concat default-directory "configuration/elpa"))` saved the day. Thank you very much for your help!