reddit / emacs

Straight.el not building in 'self-contained' installation script

chatziiola · 2022-12-29 16:38
Hello all! To keep this short, I use emacs to build and maintain my blog in github pages. To do that, I have a file `build-site.el`, which gets called by a simple bash script like this: emacs -Q --script build-site.el It used to work properly, yet greedy as I am I decided to implement a couple of new *features*, and to achieve that functionality I decided to install `straight.el`: (setq straight-vc-git-default-clone-depth 1) (setq straight-recipes-gnu-elpa-use-mirror t) ;; Default installation function, as found in straight.el repo (defvar bootstrap-version) (let ((bootstrap-file (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory)) (bootstrap-version 6)) (unless (file-exists-p bootstrap-file) (with-current-buffer (url-retrieve-synchronously "https://raw.githubusercontent.com/radian-software/straight.el/develop/install.el" 'silent 'inhibit-cookies) (goto-char (point-max)) (eval-print-last-sexp) ;; This was added for debugging purposes, unnecessarily (message "Install.el has been properly evaluated"))) ;; In any case load the bootstrap file ;; This is where the error is caused: ;; I changed the line a little bit hoping for a clearer debug message (load bootstrap-file)) ;nil)) Simply using the functions I have in my *main conf*, however, was not enough since the process exited with code 255 (error). This I could not reproduce locally (since the functions themselves worked for me) and the error occured only in the github actions machine as seen [here](https://github.com/chatziiola/chatziiola.github.io/actions/runs/3800324766/jobs/6463691228). I suspected that this has something to do with the limited environment in which emacs must run in the target VM. To gain a better understanding I modified the 'package installer' (the preceding lisp snippet) section by adding the following lines at the beginning: ;; Changing these directories is what let me (hopefully) reproduce the error from github pages locally (setq user-emacs-directory (expand-file-name "./.emacs.d")) (setq package-user-dir user-emacs-directory) (setq straight-base-dir user-emacs-directory) And this gave me the error you see here: Debugger entered--Lisp error: (error "straight-ert-print-hack.el:0:0: error: file-missin...") signal(error ("straight-ert-print-hack.el:0:0: error: file-missin...")) error("%s:0:0: error: %s: %s" "straight-ert-print-hack.el" file-missing ("Opening input file" "No such file or directory" "/Users/maclampis/Github/chatziiola.github.io/.emac...")) autoload-generate-file-autoloads("straight-ert-print-hack.el" nil "/Users/maclampis/Github/chatziiola.github.io/.emac...") make-directory-autoloads("/Users/maclampis/Github/chatziiola.github.io/.emac..." "/Users/maclampis/Github/chatziiola.github.io/.emac...") straight--build-autoloads((:type git :host github :repo "radian-software/straight.el" :files ("straight*.el") :branch "master" :package "straight" :local-repo "straight.el")) run-hook-with-args(straight--build-autoloads (:type git :host github :repo "radian-software/straight.el" :files ("straight*.el") :branch "master" :package "straight" :local-repo "straight.el")) straight--build-package((:type git :host github :repo "radian-software/straight.el" :files ("straight*.el") :branch "master" :package "straight" :local-repo "straight.el") nil) #f(compiled-function () #<bytecode -0x532d0d99a925356>)() straight--transaction-exec(use-package-\"c809124e9c5270ea1c72e2c3507331d1\"-nil-nil :now #f(compiled-function () #<bytecode -0x532d0d99a925356>)) straight-use-package((straight :type git :host github :repo "radian-software/straight.el" :files ("straight*.el") :branch "master")) eval-buffer(#<buffer *load*-853969> nil "/Users/maclampis/Github/chatziiola.github.io/.emac..." nil t) ; Reading at buffer position 5397 load-with-code-conversion("/Users/maclampis/Github/chatziiola.github.io/.emac..." "/Users/maclampis/Github/chatziiola.github.io/.emac..." nil nil) load("/Users/maclampis/Github/chatziiola.github.io/.emac...") (let ((bootstrap-file (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory)) (bootstrap-version 6)) (if (file-exists-p bootstrap-file) nil (save-current-buffer (set-buffer (url-retrieve-synchronously "https://raw.githubusercontent.com/radian-software/..." 'silent 'inhibit-cookies)) (goto-char (point-max)) (eval-print-last-sexp) (message "Install.el has been properly evaluated"))) (load bootstrap-file)) eval-buffer(#<buffer *load*> nil "/Users/maclampis/Github/chatziiola.github.io/build..." nil t) ; Reading at buffer position 3520 load-with-code-conversion("/Users/maclampis/Github/chatziiola.github.io/build..." "/Users/maclampis/Github/chatziiola.github.io/build..." nil t) load("/Users/maclampis/Github/chatziiola.github.io/build..." nil t t) command-line-1(("-scriptload" "build-site.el")) command-line() normal-top-level() which I then traced back to this section of straight's `bootstrap.el`: (straight-use-package `(straight :type git :host github :repo ,(format "%s/straight.el" straight-repository-user) :files ("straight*.el") :branch ,straight-repository-branch)) It obviously is the *build* of straight.el, yet I hoped that someone here understands a little bit more than that, allowing me to overcome this problem. I searched for the solution online and could not find another user with the same question. I would gladly appreciate any tips on where to look ...
nv-elisp · 2022-12-29 18:16
Code fences don't render properly on all versions of Reddit. Please indent all code by 4 spaces instead.
nv-elisp · 2022-12-29 18:18
As far as the error goes it looks like a file is missing while straight's autoloads are being generated. If you expand the ellipses in that backtrace you can see what file is missing. It's also unclear where you set default-directory. Please include the full script or a link to it.
chatziiola · 2022-12-29 18:44
Thanks for taking some time to look at my post. I did not state it clearly enough but what I did was to set the variables at the beginning of my first snippet. The complete code would be: ```elisp (setq user-emacs-directory (expand-file-name "./.emacs.d")) (setq package-user-dir user-emacs-directory) (setq straight-base-dir user-emacs-directory) (setq straight-vc-git-default-clone-depth 1) (setq straight-recipes-gnu-elpa-use-mirror t) (defvar bootstrap-version) (let ((bootstrap-file (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory)) (bootstrap-version 6)) (unless (file-exists-p bootstrap-file) (with-current-buffer (url-retrieve-synchronously "https://raw.githubusercontent.com/radian-software/straight.el/develop/install.el" 'silent 'inhibit-cookies) (goto-char (point-max)) (eval-print-last-sexp) (message "Install.el has been properly evaluated"))) ;; In any case load the bootstrap file (load bootstrap-file)) ;nil)) ``` Furthermore, I had understood that the problem was that of a missing file, the thing is that this file gets automatically downloaded by `bootstrap.el`, when it builds `straight.el`. As such, I do not believe I have any control over it. I just do not understand why it is not there.
chatziiola · 2022-12-29 18:46
I'm sorry but I do not understand the problem you describe. And should every level of indentation be 4 spaces wide or simply add 4 spaces at the beginning of every code line?
nv-elisp · 2022-12-29 18:51
Add 4 to each line.
nv-elisp · 2022-12-29 18:54
What is the computed path of user-emacs-directory just before straight's bootstrap snippet? Does that path exist? e.g. (message "%s" user-emacs-directory)
chatziiola · 2022-12-29 18:59
Yes, the path exists (and in the case the folder does not exist it gets created by the script). This is not the issue here, my guess would be that `straight.el` uses a different path somewhere and the file gets stuck there instead of the proper directory. I checked that repeatedly. Edit: I also indented every line in my comment's block of code by 4 spaces. Does this solve your problem?
nv-elisp · 2022-12-29 19:17
> I also indented every line in my comment's block of code by 4 spaces. Does this solve your problem? No. The initial post is malformed. You need to remove the backticks and language name. Then each line of code gets 4 spaces added to it. Separate the code block from surrounding text with a blank line. To give you an example of how it looks on old.reddit: https://ibb.co/xz85MzC
chatziiola · 2022-12-29 19:23
Hopefully at least this is now fixed for viewing.
nv-elisp · 2022-12-29 19:38
Thanks. That's much clearer. Try adding `(setq backtrace-line-length nil)` prior to bootstrapping straight. That should get you a backtrace sans the abbreviated printing. It will show the full path of the missing file.
lastnamebird · 2022-12-29 23:29
It’s not a solution to the Straight issue, but maybe you can make use of `package-vc-install` instead? Especially if it is simply a build script. Of course this requires a later build of emacs.
chatziiola · 2022-12-30 19:48
I could do that I suppose, yet, having limited experiences with the different emacs packaging systems (I have found one that behaves the way I want it , leaving me no reason to go down that rabbit hole), I am trying to limit both the difficulty I will face and the time I will need when I want to modify this file in the future. However, your comment let me see that I dont actually need a package manager - I only needed limited functions from a file which I have now *integrated* into my directory
lastnamebird · 2022-12-30 21:12
To be clear, `package-vc-install` is a built-in function and a part of the standard Emacs package management offering in Emacs 29. I'm glad you found a solution to your problem though, you should share your site whenever you get it completed!