1
;; Install package.el for package management
(require 'package)
(setq package-enable-at-startup nil)


(add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/") t)
(add-to-list 'package-archives '("gnu" . "https://elpa.gnu.org/packages/") t)

(package-initialize)

;;(when (not package-archive-contents)
;;   (package-refresh-contents))

;; Bootstrap use-package
(unless (package-installed-p 'use-package)
  (package-refresh-contents)
  (package-install 'use-package))

;; (package-install 'use-package)
(featurep 'use-package)

Hi I'm new to emacs and I'm learning how to configure the init file. I have this code above so far that I'm not sure is working. Of particular interest is the bootstrapping of use-package. It might be ok and I just don't know how to use featurep or misunderstand it's use.

So I want to verify that the packages are being installed so I read somewhere on the internet that you can use (featurep 'some-package) to verify that the package is installed. So when I run the last line of this code, it is supposed to verify that the use-package bootstrapping worked. I thought I should be expecting t as the output but I'm getting nil as the output from running (featurep use-package)

Any advice?

  • Welcome. Can you provide a link to where you found this code? – Andrew Swann Dec 17 '17 at 13:08
  • I got that code from about 4 different sources. it's my experimentation trying to learn this stuff. @AndrewSwann – Bucephalus Dec 17 '17 at 13:46
2

It is the correct behavior that (featurep 'use-package) returns nil, since even though the package is installed it is not loaded in the environment.

features variable in emacs is a list of all components provided by emacs packages. These are declared by the provide function and are checked with the require function. With M-x describe-variable (C-h v) you can see the list.

Either way you don't need to check with featurep for a feature, here a simple (require 'use-package) checks if use-package is loaded and if not loads it and puts the symbol to the features list.

  • Oh yeah ok, so what is the difference between "installed" and "loaded"? – Bucephalus Dec 17 '17 at 7:12
  • installed means the file of the libraries are there, loaded means they are interpreted by the emacs lisp environment and therefore added and ready to use. – D. Dimakakos Dec 17 '17 at 7:17
  • I see so package-install only installs a package and so it may not show up in featurep variable. it's only after a package is loaded that it will show up in featurep. That's what Im understanding from what you're saying @D.Dimakakos. also, I found that when i use use-package to install other packages that they actually show up in the featurep variable. This tells me that use-package installs and loads. is this correct? – Bucephalus Dec 17 '17 at 7:17
  • 1
    that's the use of use-package! it loads packages, if you want to also check and install you use the :ensure keyword – D. Dimakakos Dec 17 '17 at 7:18
  • That's awesome. Thankyou @D. Dimakakos – Bucephalus Dec 17 '17 at 7:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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