heavyblack1
heavyblack1

Reputation: 82

Emacs definition is void: use-package

I have a problem. If I copy any official code to enable package such elpy into my configuration I get:

Symbol's function definition is void: use-package

(use-package elpy
  :ensure t
  :init
  (elpy-enable))

Upvotes: 1

Views: 2009

Answers (1)

Blitzer
Blitzer

Reputation: 164

Please put this before using use-package:

(require 'package)                   ; Bring in to the environment all package management functions

;; A list of package repositories
(setq package-archives '(("melpa" . "https://melpa.org/packages/")
                         ("org"   . "https://orgmode.org/elpa/")
                         ("elpa"  . "https://elpa.gnu.org/packages/")))

(package-initialize)                 ; Initializes the package system and prepares it to be used

(unless package-archive-contents     ; Unless a package archive already exists,
  (package-refresh-contents))        ; Refresh package contents so that Emacs knows which packages to load


;; Initialize use-package on non-linux platforms
(unless (package-installed-p 'use-package)        ; Unless "use-package" is installed, install "use-package"
  (package-install 'use-package))

(require 'use-package)                            ; Once it's installed, we load it using require

;; Make sure packages are downloaded and installed before they are run
;; also frees you from having to put :ensure t after installing EVERY PACKAGE.
(setq use-package-always-ensure t)

Upvotes: 7

Related Questions