6

I am new to emacs. I'm trying to use cask to manage emacs packages.

This is my ~/.emacs.d/init.el:

(require 'cask "~/etsi/cask/cask.el")
(cask-initialize "~/etsi")

(require 'evil)
(evil-mode 1)

~/etsi/Cask file:

(source "melpa" "http://melpa.milkbox.net/packages/")
(source "gnu" "http://elpa.gnu.org/packages/")

(depends-on "evil")

However, it does not seem to work. For example, whenever I open a file, there seems to be no evil mode. (Yes I add cask binary to $PATH and ran cask install.)

Looking at other people's publicly available dotfiles, I see they use Cask too and do the same or similar things, so I'm not sure what I did wrong.

I also tried the following for ~/.emacs.d/init.el:

(require 'package)
(require 'cask "~/etsi/cask/cask.el")
(package-initialize)
(cask-initialize "~/etsi")

(require 'evil)
(evil-mode 1)

which also does not work.


Why?

Because I am new to emacs, perhaps I'm doing it wrong, and explaining what exactly I'm trying to achieve might bring forward a more straightforward solution.

Instead of manually M-x package-install RET <package-name> RET for each and every package, I want to simply put a list of them somewhere (in a text file), and have something automatically install them all (and take care of initalization). This is because I want to replicate my emacs setup across multiple machines, and obviously doing M-x package-install RET <package-name> RET for each package on each machine is not desirable.

I thought cask was the correct tool for this, since you can have a Cask file to list your packages. And just use the cask install command to install them. When I ran cask install, it did download and "install" (to .cask directory) evil and its dependencies. But emacs does not seem to load it?

I also tried (add-to-list 'load-path (cask-load-path ((cask-initialize "~/etsi")))) instead of (cask-initialize "~/etsi"), but that did not work either.

Is el-get the right tool for the job instead? Reading the introductory documentation, it wasn't clear that it was, hence why I chose clask, because their documentation specifically said "If you are using Cask for your Emacs configuration [...]".

Edit: Maybe I'm checking for evil mode wrong? Is there a reliable way to check for the existence of a package, i.e. whether or not it has been loaded? I'm checking for evil by just pressing j, or searching for evil mode help with C-h evil.

  • 1
    Why do you think you need cask? The default package manager is shorter and simpler. I use only the cask shell script for testing. – abo-abo Jun 24 '15 at 14:18
  • 1
    Because of what I said under the why section? Can I do it with the default package manager? If so, how? – vyp Jun 24 '15 at 14:25
  • 2
    I believe that most people have their Cask file within their .emacs.d folder vs. an external folder. Did you give it a shot? If that doesn't work, I believe that it's worth creating a Github issue for your problem? I've never used cask-initialize with arguments. – rimero Jun 24 '15 at 18:07
  • 1
    Do you see an error message when starting Emacs? – lunaryorn Jun 24 '15 at 19:15
  • 2
    Okay figured it out, ~/.emacs and ~/.emacs.d/init.el (or I guess any other startup file) are mutually exclusive. I had one line .emacs file. I thought there was a load order or something. i.e. init.el loads before .emacs. For anyone reading in the future, solved by removing ~/.emacs file (or transferring the contents of that too init.el and then deleting). – vyp Jun 25 '15 at 8:07
3

Here's how I do it: packages.el.

Cite some code, it's nothing too complex:

;; install required
(dolist (package ora-packages)
  (unless (package-installed-p package)
    (package-install package)))
;; upgrade installed
(save-window-excursion
  (package-list-packages t)
  (package-menu-mark-upgrades)
  (condition-case nil
      (package-menu-execute t)
    (error
     (package-menu-execute))))

And how to use it:

emacs -batch -l packages.el

That's it, after this single shell command all packages from the ora-packages variable will be installed/upgraded.

I have this tied into my Emacs startup, if I want to start Emacs with an upgrade, I type make up. To start without an upgrade, I type make run.

  • I've seen something like this here and here, but can this be used to install specific versions/hashes? Does ELPA even support installing specific revisions? – vyp Jun 24 '15 at 15:04
  • 1
    Specific revisions aren't supported. I don't miss them too much. If you look at my config, I'm using git submodules for that sort of stuff. – abo-abo Jun 24 '15 at 15:24
  • I see, I will have to "fallback" anyway to using package.el, but would you know why cask does not seem to work here still? (Say I want to use it for package development or something later.) – vyp Jun 24 '15 at 15:35
  • 1
    For package development, I only use the cask python script. I never actually install cask into Emacs. – abo-abo Jun 24 '15 at 15:59
  • Okay cool. :) I will wait to see if anyone else answers, or if I can figure out it myself, or figure out something else. Otherwise I'll accept your answer. – vyp Jun 24 '15 at 16:01

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.