Skip to content

Migrating to Elpaca

John Sperger edited this page Oct 10, 2024 · 3 revisions

Use-package Integration

Elpaca integrates with use-package via elpaca-use-package-mode. With the mode enabled, use-package's :ensure keyword accepts the following values:

  • t: Install a package with an ID matching the feature name.

    (use-package feature-name :ensure t)
    ;; Roughly expands to:
    (elpaca feature-name)

    The same behavior can be implied by setting use-package-always-ensure non-nil.

  • nil: Ignore Elpaca integration

     (use-package built-in :ensure nil) ;; Don't try to install built-in feature
  • An ID symbol: Install the package which matches ID

     ;; The package provides "feature", but is advertised in package menus as "some-other-name"
     (use-package feature :ensure some-other-name)
  • An order: Install the package based off the order.

    (use-package not-in-elpa :ensure (not-in-elpa :host github :repo "user/not-in-elpa"))
    ;; You can optionally drop the ID in the order if it matches the use-package feature NAME.
    (use-package not-in-elpa :ensure (:host github :repo "user/not-in-elpa"))

Asynchronicity

Because Elpaca does most of its work asynchronously, you may need to rework configuration which relied on straight's synchronicity. For example, in order to use Elpaca's use-package integration at the top-level of your init file, you'll need to call elpaca-wait. This will block until Elpaca processes everything it has queued up to the point of the call.

(elpaca elpaca-use-package
  ;;Enable Elpaca's use-package support
  (elpaca-use-package-mode))
;; Block until package is installed/activated so we can use it at the top-level below.
(elpaca-wait)
;; Now we can use the :ensure use-package keyword.
;; You'll want to call `elpaca-wait` after other packages which are required at the top-level of your init.
;; For example, general.el is a popular keybinding library which adds its own use-package keyword.
(use-package general :ensure t)
;; wait so we can use the :general use-package keyword below
(elpaca-wait)
;; :general use-package keyword can be used below

If you're making use of after-init-hook and/or emacs-startup-hook see the wiki page on startup hooks

Migrating from Straight.el to Elpaca

Package Versioning

Straight.el does not currently check that a package's dependencies meet its minimum version requirements. Elpaca does. See the warnings and errors and troubleshooting pages for solutions to common possible errors.

Recipe keyword differences

The following straight.el recipe keywords do not exist in Elpaca:

  • :flavor

  • :includes

  • :source

  • :type If you were using :type built-in, you may need to push the package's features to elpaca-ignored-dependencies to prevent Elpaca from installing them as a dependency of another package. For example:

    (cl-pushnew 'org elpaca-ignored-dependencies)
    ;; Packages which depend on Org will not install the development version.
  • :upstream

The following straight.el recipe keywords have different semantics in Elpaca:

  • :depth accepts an integer, nil, 'blobless', or 'treeless. A full repository clone is specified by:depth nil`. See https://git-scm.com/docs/partial-clone for the meaning of blobless and treeless.
  • :inherit accepts nil, t, a menu symbol or list of menu symbols, subsuming straight.el's :source keyword.

The following straight.el recipe keywords are replaced in Elpaca:

  • :fork is replaced by :remotes
  • :source is replaced by :inherit