0

Why can't Emacs find counsel and swiper, even though they (as well as ivy) seem installed, and moreover Ivy mode is enabled, and seems to be working?

This is what I get when I try the following:

(package-installed-p 'ivy)
t

(package-installed-p 'counsel)
t

(package-installed-p 'swiper)
t

And I can also see the version information for Ivy:

(pkg-info-version-info 'ivy)
"0.11.0 (package: 20190412.840)"

But when I try to get version information for counsel, I get an error:

(pkg-info-version-info 'counsel)

Debugger entered--Lisp error: (error "Can’t find library counsel")
  signal(error ("Can’t find library counsel"))
  error("Can't find library %s" "counsel")
  find-library-name("counsel")
  pkg-info-library-source(counsel)
  pkg-info-library-version(counsel)
  pkg-info-version-info(counsel)
  eval((pkg-info-version-info 'counsel) nil)
  elisp--eval-last-sexp(t)
  eval-last-sexp(t)
  eval-print-last-sexp(nil)
  funcall-interactively(eval-print-last-sexp nil)
  call-interactively(eval-print-last-sexp nil nil)
  command-execute(eval-print-last-sexp)

Interestingly enough, if I visit the the packages list, counsel is listed as installed and I can get the following details:

counsel is an installed package.

     Status: Installed in ‘counsel-20190414.1926/’ (unsigned).
    Version: 20190414.1926
     Commit: 0e62f0d1f61b825ca5eb4b55e47ecb37b3e2834e
    Summary: Various completion functions using Ivy
   Requires: emacs-24.3, swiper-0.11.0
Required by: counsel-tramp-20190125.751
   Homepage: https://github.com/abo-abo/swiper
   Keywords: convenience matching tools 
Other versions: 20190414.1926 (melpa).

My Emacs version is:

"GNU Emacs 27.0.50 (build 1, x86_64-w64-mingw32)
 of 2018-06-19"

and I'm encountering this issue on MS Windows 10 (version 1607).

  • 1
    I can confirm that with same counsel version and GNU Emacs 26.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.22.30) on archlinux I do get counsel version, if that's any reassurance... – manandearth Apr 15 at 14:41
  • 1
    Is it actually a case of Emacs not finding it? As far as I'm aware the function/command you're using there (pkg-info-version-info) is from pkg-info.el, which (as of 26.2 at least) isn't part of GNU Emacs. – davep Apr 15 at 15:05
  • @davep you are correct, pkg-info isn't part of Emacs, I've installed it as a package. As can be seen in my answer below, package-initialize solved my problem. But, it's still a mystery to me why ivy was working whereas counsel and swiper didn't. If it's a matter of me having to explicitly initialize, then why was ivy working without that. Hence my confusion. – Emre Sevinç Apr 16 at 6:21
  • @EmreSevinç it is curious. It might be an idea to raise the issue with the package author. – davep Apr 16 at 6:53
1

Adding the following to my .emacs seems to solve the problem:

(package-initialize)

But I'm a little bit confused, because 41.1 Packaging Basics says that

Whenever Emacs starts up, it automatically calls the function package-initialize to load installed packages.

Moreover, I had the same version of Emacs on a Linux machine, and I'm using the same Emacs configuration there without any problems, that is, without (package-initialize).

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.