The package straight.el requires the following bootstrapping code in your emacs config:
(defvar bootstrap-version)
(let ((bootstrap-file
(expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
(bootstrap-version 5))
(unless (file-exists-p bootstrap-file)
(with-current-buffer
(url-retrieve-synchronously
"https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
'silent 'inhibit-cookies)
(goto-char (point-max))
(eval-print-last-sexp)))
(load bootstrap-file nil 'nomessage))
The use of defvar to initialize bootstrap-version was a little confusing to me, given that it's only used in a let statement that could have also just as easily initialized and defined it. However, it is invoked later in the install.el file that is retrieved into the buffer later. I'm not confident I fully understand the use of defvar, but is it the case that initializing bootstrap-version using a defvar statement makes it available to install.el? Would it not be accessible otherwise? If that's not the case, why is this variable initialized in this way instead of in the let expression?