Subject: Re: bug#6805: 24.0.50; package--dir assumes that Emacs is installed

From: Ævar Arnfjörð Bjarmason <[email-masked]>
Date: Sun, 8 Aug 2010 20:55:15 +0000

On Sun, Aug 8, 2010 at 20:33, Chong Yidong <[email-masked]> wrote:
> Ævar Arnfjörð Bjarmason <[email-masked]> writes:
>
>> When I compile Emacs from Git and run it without doing "make install" I
>> run into this in package.el:
>>
>>     (unless pkg-dir
>>       (error "Internal error: could not find directory for %s-%s"
>>            name version-str))
>
> I can't reproduce this.  I run Emacs in place without `make install',
> and have not encountered any such error.  Could you provide a precise
> description of the error, such as the error message shown in echo area?

On a fresh Emacs checkout from git://repo.or.cz/emacs.git on both
Debian GNU/Linux testing and Debian GNU/kFreeBSD unstable doing:

    mkdir ~/g
    git clone git://repo.or.cz/emacs.git &&
    cd emacs &&
    make -j 10 bootstrap &&
    make

followed by:

    src/emacs

will display, in the echo area:

    "Internal error: could not find directory for package-1.0"

And in *Messages*:

    package-activate-1: Internal error: could not find directory for package-1.0

>> It's failing that assertion because package--dir assumes that Emacs is
>> already installed:
>>
>>     package-directory-list is a variable defined in `package.el'.
>>     Its value is
>>     ("/usr/local/share/emacs/24.0.50/site-lisp/elpa"
>> "/usr/local/share/emacs/site-lisp/elpa")
>
> It should not matter if these directories do not exist, but your bug
> report does not provide enough information to tell for sure.

I've just glanced at the code, but it seems that it does
matter. package-activate-1 has this:

    (defun package-activate-1 (package pkg-vec)
      (let* ((name (symbol-name package))
             (version-str (package-version-join (package-desc-vers pkg-vec)))
             (pkg-dir (package--dir name version-str)))
        (unless pkg-dir
          (error "Internal error: could not find directory for %s-%s"
                 name version-str)

Which calls:

    (defun package--dir (name version-string)
      (let* ((subdir (concat name "-" version-string))
             (dir-list (cons package-user-dir package-directory-list)

package--dir is searching through (cons package-user-dir
package-directory-list), whose value on my system is:

    ("~/.emacs.d/elpa" "/usr/local/share/emacs/24.0.50/site-lisp/elpa"
"/usr/local/share/emacs/site-lisp/elpa")

None of those directories exist on my system. Perhaps you can
reproduce this issue if you delete your ~/.emacs.d/elpa directory?

Or maybe something is wrong on my system. I haven't looked deeply into
this bug, and I'd be happy to supply further info needed to solve it.