Subject: bug#23237: Strange behavior of `package` in automated install in init script

From: Alex Coventry <[email-masked]>
Date: Thu, 7 Apr 2016 02:00:53 -0400

This is a report of two bugs in a fresh install of emacs on the
ubuntu:14.04 docker image and the following elisp in install-package.el

  (require 'package)
  (add-to-list
   'package-archives
   '("melpa" . "http://melpa.org/packages/")
   t)
  (package-initialize)
  (package-refresh-contents)
  (message (format "package contents: %s" package-archive-contents))
  (package-install "evil")

The first bug is that both of the shell commands result in "not enough
arguments for format string".  Something is strange about the value of
package-archive-contents at that time.

  root@cecce30d6adf:/emacs# emacs -l install-package.el
  root@cecce30d6adf:/emacs# emacs -batch --eval '(setq user-init-file
"~/.emacs")' -l install-package.el

However, the (format) command works just fine when invoked interactively
after the install-package.el command has failed.

The second (original) bug is that both shell commands result in the
complaint `Package `evil-' is unavailable` if you comment out the (message)
sexp.

I would like to be able to use `package-install` in an automated way like
this in order to build docker containers for emacs.

The following docker file built the container I was testing in, and will be
available at alxempirical/emacs-git-master as soon as it's pushed.  (It's
on the order of a gig, though.)

Best regards,
Alex

FROM ubuntu:14.04
RUN apt-get update && apt-get upgrade -y
RUN apt-get build-dep -y emacs
RUN apt-get install -y git ncurses-dev autoconf automake
RUN git clone git://git.savannah.gnu.org/emacs.git
WORKDIR emacs
RUN ./autogen.sh
RUN ./autogen.sh git
RUN apt-get install -y texinfo
RUN ./configure
RUN make install
COPY install-package.el /

In GNU Emacs 25.1.50.1 (x86_64-unknown-linux-gnu)
 of 2016-04-07 built on f0726407848b
Repository revision: 1f6b0bc1512de08fd542df0234476788038c8c82
System Description: Ubuntu 14.04.4 LTS

Configured features:
SOUND NOTIFY

Important settings:
  locale-coding-system: nil

Major mode: Lisp Interaction

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  electric-indent-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.
Importing package-keyring.gpg...done
Contacting host: elpa.gnu.org:80 [2 times]
Contacting host: melpa.org:80
Package refresh done [2 times]
Saving file /root/.emacs...
Wrote /root/.emacs [2 times]
package-compute-transaction: Package ‘evil-’ is unavailable
Quit
Type C-x 1 to delete the help window.

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug sendmail regexp-opt eieio-opt speedbar
sb-image ezimage image dframe find-func thingatpt help-fns cus-edit
cus-start cus-load wid-edit mm-archive message dired dired-loaddefs
format-spec rfc822 mml mml-sec epa derived gnus-util rmail tool-bar
rmail-loaddefs mailabbrev gmm-utils mailheader mm-decode mm-bodies
mm-encode mail-utils network-stream starttls url-http tls gnutls
mail-parse rfc2231 rfc2047 rfc2045 mm-util ietf-drums mail-prsvr url-gw
nsm puny seq url-cache url-auth url url-proxy url-privacy url-expand
url-methods url-history url-cookie url-domsuf url-util mailcap epg
term/xterm xterm time-date finder-inf package epg-config url-handlers
url-parse auth-source cl-seq eieio byte-opt bytecomp byte-compile
cl-extra help-mode easymenu cconv eieio-core cl-macs gv eieio-loaddefs
cl-loaddefs pcase cl-lib password-cache url-vars disp-table mule-util
tooltip eldoc electric uniquify ediff-hook vc-hooks lisp-float-type
tabulated-list newcomment elisp-mode lisp-mode prog-mode register page
menu-bar rfn-eshadow timer select mouse jit-lock font-lock syntax
facemenu font-core term/tty-colors frame cl-generic cham georgian
utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean
japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european
ethiopic indian cyrillic chinese charscript case-table epa-hook
jka-cmpr-hook help simple abbrev obarray minibuffer cl-preloaded nadvice
loaddefs button faces cus-face macroexp files text-properties overlay
sha1 md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote inotify multi-tty
make-network-process emacs)

Memory information:
((conses 16 180731 17858)
 (symbols 48 26964 2)
 (miscs 40 34 147)
 (strings 32 43773 19901)
 (string-bytes 1 1131962)
 (vectors 16 24838)
 (vector-slots 8 1238099 198624)
 (floats 8 237 346)
 (intervals 56 213 126)
 (buffers 976 12)
 (heap 1024 21727 2658))