From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Zachary Kanfer Newsgroups: gmane.emacs.bugs Subject: bug#31397: 27.0.50; Emacs doesn't call package-initialize if there's no elpa directory Date: Thu, 10 May 2018 01:17:12 -0400 Message-ID: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000fd4f6c056bd322bd" X-Trace: blaine.gmane.org 1525929366 7653 195.159.176.226 (10 May 2018 05:16:06 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 10 May 2018 05:16:06 +0000 (UTC) To: 31397@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu May 10 07:16:02 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fGdvu-0001tQ-BH for geb-bug-gnu-emacs@m.gmane.org; Thu, 10 May 2018 07:16:02 +0200 Original-Received: from localhost ([::1]:60271 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fGdy1-00013g-9c for geb-bug-gnu-emacs@m.gmane.org; Thu, 10 May 2018 01:18:13 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:34654) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fGdxt-00013Z-4A for bug-gnu-emacs@gnu.org; Thu, 10 May 2018 01:18:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fGdxq-0002Is-U1 for bug-gnu-emacs@gnu.org; Thu, 10 May 2018 01:18:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:47930) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fGdxq-0002Im-Q1 for bug-gnu-emacs@gnu.org; Thu, 10 May 2018 01:18:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1fGdxq-000635-KJ for bug-gnu-emacs@gnu.org; Thu, 10 May 2018 01:18:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Zachary Kanfer Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 10 May 2018 05:18:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 31397 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.152592947023230 (code B ref -1); Thu, 10 May 2018 05:18:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 10 May 2018 05:17:50 +0000 Original-Received: from localhost ([127.0.0.1]:55827 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fGdxd-00062c-CQ for submit@debbugs.gnu.org; Thu, 10 May 2018 01:17:49 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:43637) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fGdxb-00062O-Eq for submit@debbugs.gnu.org; Thu, 10 May 2018 01:17:48 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fGdxT-0002FL-Mf for submit@debbugs.gnu.org; Thu, 10 May 2018 01:17:42 -0400 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:48149) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fGdxT-0002FF-Ik for submit@debbugs.gnu.org; Thu, 10 May 2018 01:17:39 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:34607) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fGdxR-00013O-0Z for bug-gnu-emacs@gnu.org; Thu, 10 May 2018 01:17:39 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fGdxO-0002EZ-Kg for bug-gnu-emacs@gnu.org; Thu, 10 May 2018 01:17:36 -0400 Original-Received: from mail-io0-x233.google.com ([2607:f8b0:4001:c06::233]:37239) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fGdxO-0002EJ-Co for bug-gnu-emacs@gnu.org; Thu, 10 May 2018 01:17:34 -0400 Original-Received: by mail-io0-x233.google.com with SMTP id e20-v6so1640968iof.4 for ; Wed, 09 May 2018 22:17:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=JkixAR1q96nCWKFhaIbleaRYoRGx0pffC6do3WXNmFQ=; b=UuPVagVDIH/LAGIgSAvqWXgreQPxFDUoOytc0lQv1JtOGjHLYCu+Ut4fzD3m6azqWN SbPZnydSWbiXWowLXTxT0Ytkm+Z+LJ3EjGDkg5kndjv8xBh4BYwQszSKyCcQNEV7IlyN 3XtSj9rSv4PnXxyR6vN8YwxtbNYQY2sHYj3nGDAaDtjIs4vyVn30awcxcb5lVUTlDs1Z NP88oPWOcUZydhFDzCQL7SwIOQfiHKd+GuNOV3+3URJZuRl44ysyscAuOsjqHKYkmy35 UMrMqcVWziJVXnhnCyPfCJtJ23UOuGIefd9Z1LD8DAMZIBAx8bbfBTgbum1AsDmfcbwr HIBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=JkixAR1q96nCWKFhaIbleaRYoRGx0pffC6do3WXNmFQ=; b=ZhuxX/hnaAWviwWWB06PgmBdjtufdk25i6AzADulQm55xIYnoNM6pGrvSxVRpy/OBM wopKVC/7Xr76oeMGqWKC+eCjSXW6cfVZ4/hXHkvnizQ4ijP4IDjx/0avN8SqAETYt9Zg NCnSWKcsbb461T1Mp2rJ33STUbr6iHisTxlTnAc0u76dSvzwMi8k6hET/siHvpVCQjim OeBjDkK6U5WjYb0gNS9cDi/YmKhBG/nIyU9/weJuL6s8tQAxT5PgBF5xyLQLd3ntH/MP cqozB3Xm/eYtBToEsk9V7dVm9mXe7nrz/zX5nGXp1RrBsie/SHFgR5KsBLp3SWmyHee4 IkEA== X-Gm-Message-State: ALQs6tDSkwRV3vDXi9OZan7xkc1D69t35eFgIKB/EqPvE1rMB9B7T/BP c236E5U9zFcWFRuCpIZ9QvI3mBbRTla7w3UwADFVvFcU X-Google-Smtp-Source: AB8JxZpp9VjL+5jc9xkMYVASfVvFSFfCBPJI38yGJ+YbwY+CZlUObQ7qaODJZZBdQOu8KFVJAp2M5e/BJUgw7srtDrs= X-Received: by 2002:a6b:9652:: with SMTP id y79-v6mr45328661iod.171.1525929452849; Wed, 09 May 2018 22:17:32 -0700 (PDT) Original-Received: by 2002:a4f:244:0:0:0:0:0 with HTTP; Wed, 9 May 2018 22:17:12 -0700 (PDT) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:146101 Archived-At: --000000000000fd4f6c056bd322bd Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable ------------------ High-level summary: ------------------ If Emacs is started with no ~/.emacs.d/elpa directory, #'package-initialize is not called, and I can't programatically work with packages. ---------- Motivation ---------- I like my init file to completely set up Emacs: I want to be able to start with an empty ~/.emacs.d/ move my init file into it, and start up Emacs. To do that, I've had (previously to Emacs 27), this as the preamble to my init file: (require 'package) (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/")) (package-initialize) (unless (package-installed-p 'use-package) (package-refresh-contents) (package-install 'use-package)) This sets up package.el with the ability to use melpa, then installs use-package, for use in the rest of my init file. This has worked fine. But I recently upgraded my Emacs to a newer version built from source, using commit 766b057e41df7316808ec7658836fda75facda75. As part of that, I've read up on the early init file. My understanding is that users should no longer call #'package-initialize in their init files. This is supported by, if I do have a call to #'package-initialize, starting Emacs gives me a warning "Warning (package): Unnecessary call to =E2=80=98package-initialize=E2=80=99 in init file". So I figured I would re= move it. But I quickly ran into a problem, or at least an area for better documentation. ------------------------- Reproduction instructions ------------------------- A minimal init file that shows my problem is here: (require 'package) (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/")) (message "use-package is installed: %s" (package-installed-p 'use-package)) Here's how I delete the elpa directory, and then start up Emacs: $ rm -r ~/.emacs.d/elpa $ src/emacs Upon doing so, here's the error I get: Warning (initialization): An error occurred while loading =E2=80=98/home/zck/.emacs.d/init.el=E2=80=99: error: package.el is not yet initialized! To ensure normal operation, you should investigate and remove the cause of the error in your initialization file. Start Emacs with the =E2=80=98--debug-init=E2=80=99 option to view a complete error back= trace. --------------------------- Investigation & speculation --------------------------- I started looking around for documentation, and found this interesting comment in simple.el's function #'command-line: ;; If any package directory exists, initialize the package system. This seems to be the cause. I'm not sure why the package system shouldn't be initialized if there is no package directory; I want to be able to do package operations even if I'm starting with no package directory. You have to start somewhere. Thanks! ------------------ System information ------------------ In GNU Emacs 27.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.18.9) of 2018-05-07 built on zck-laptop Repository revision: 766b057e41df7316808ec7658836fda75facda75 Windowing system distributor 'The X.Org Foundation', version 11.0.11804000 System Description: Ubuntu 16.04.4 LTS Recent messages: Checking for load-path shadows...done Auto-saving... Overwrite mode enabled in current buffer is undefined Undo! [3 times] user-error: No further undo information C-c k is undefined Quit C-x C-g is undefined Mark set Configured features: XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GSETTINGS NOTIFY ACL LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB TOOLKIT_SCROLL_BARS GTK3 X11 THREADS LCMS2 Important settings: value of $LANG: en_US.UTF-8 value of $XMODIFIERS: @im=3Dibus locale-coding-system: utf-8-unix Major mode: Fundamental Minor modes in effect: tooltip-mode: t global-eldoc-mode: t electric-indent-mode: t mouse-wheel-mode: t tool-bar-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t buffer-read-only: t line-number-mode: t transient-mark-mode: t Load-path shadows: None found. Features: (shadow sort mail-extr emacsbug message rmc puny dired dired-loaddefs format-spec rfc822 mml mml-sec epa derived epg gnus-util rmail rmail-loaddefs mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils cl-extra pp cl-print package-x thingatpt help-fns radix-tree help-mode time-date elec-pair warnings package easymenu epg-config url-handlers url-parse auth-source cl-seq eieio eieio-core cl-macs eieio-loaddefs password-cache json map url-vars seq byte-opt gv bytecomp byte-compile cconv cl-loaddefs cl-lib mule-util tooltip eldoc electric uniquify ediff-hook vc-hooks lisp-float-type mwheel term/x-win x-win term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe tabulated-list replace newcomment text-mode elisp-mode lisp-mode prog-mode register page menu-bar rfn-eshadow isearch timer select scroll-bar 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 composite charscript charprop 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 dbusbind inotify lcms2 dynamic-setting system-font-setting font-render-setting move-toolbar gtk x-toolkit x multi-tty make-network-process emacs) Memory information: ((conses 16 114821 11707) (symbols 48 21397 0) (miscs 40 99 151) (strings 32 34316 1830) (string-bytes 1 888700) (vectors 16 17166) (vector-slots 8 524482 10750) (floats 8 54 84) (intervals 56 292 144) (buffers 992 15) (heap 1024 44657 1840)) --000000000000fd4f6c056bd322bd Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
------------------
High-level summary:
-------------= -----

If Emacs is started with no ~/.emacs.d/elpa directory,
#= 9;package-initialize is not called, and I can't programatically workwith packages.

----------
Motivation
----------

I like= my init file to completely set up Emacs: I want to be able to
start wit= h an empty ~/.emacs.d/ move my init file into it, and start up
Emacs. To= do that, I've had (previously to Emacs 27), this as the
preamble to= my init file:

=C2=A0=C2=A0=C2=A0 (require 'package)
=C2=A0= =C2=A0=C2=A0 (add-to-list 'package-archives
=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 &#= 39;("melpa" . "https= ://melpa.org/packages/"))
=C2=A0=C2=A0=C2=A0 (package-initializ= e)
=C2=A0=C2=A0=C2=A0
=C2=A0=C2=A0=C2=A0 (unless (package-installed-= p 'use-package)
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (package-refresh-cont= ents)
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (package-install 'use-package))=

This sets up package.el with the ability to use melpa, then install= s
use-package, for use in the rest of my init file. This has worked fine= .

But I recently upgraded my Emacs to a newer version built from sou= rce,
using commit 766b057e41df7316808ec7658836fda75facda75. As part of t= hat,
I've read up on the early init file. My understanding is that u= sers
should no longer call #'package-initialize in their init files.= This is
supported by, if I do have a call to #'package-initialize, = starting
Emacs gives me a warning "Warning (package): Unnecessary c= all to
=E2=80=98package-initialize=E2=80=99 in init file". So I fig= ured I would remove it. But
I quickly ran into a problem, or at least an= area for better
documentation.

-------------------------
Repr= oduction instructions
-------------------------

A minimal init fi= le that shows my problem is here:

=C2=A0=C2=A0=C2=A0 (require 'p= ackage)
=C2=A0=C2=A0=C2=A0 (add-to-list 'package-archives
=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0 '("melpa" . "https://melpa.org/packages/"))
=C2=A0=C2=A0=C2=A0 =
=C2=A0=C2=A0=C2=A0 (message "use-package is installed: %s" (p= ackage-installed-p 'use-package))

Here's how I delete the el= pa directory, and then start up Emacs:

=C2=A0=C2=A0=C2=A0 $ rm -r ~/= .emacs.d/elpa
=C2=A0=C2=A0=C2=A0 $ src/emacs

Upon doing so, here&= #39;s the error I get:

=C2=A0=C2=A0=C2=A0 Warning (initialization): = An error occurred while loading =E2=80=98/home/zck/.emacs.d/init.el=E2=80= =99:
=C2=A0=C2=A0=C2=A0
=C2=A0=C2=A0=C2=A0 error: package.el is not = yet initialized!
=C2=A0=C2=A0=C2=A0
=C2=A0=C2=A0=C2=A0 To ensure nor= mal operation, you should investigate and remove the
=C2=A0=C2=A0=C2=A0 = cause of the error in your initialization file.=C2=A0 Start Emacs with
= =C2=A0=C2=A0=C2=A0 the =E2=80=98--debug-init=E2=80=99 option to view a comp= lete error backtrace.

---------------------------
Investigation &= amp; speculation
---------------------------

I started looking ar= ound for documentation, and found this interesting
comment in simple.el&= #39;s function #'command-line:

=C2=A0=C2=A0=C2=A0 ;; If any pack= age directory exists, initialize the package system.

This seems to b= e the cause. I'm not sure why the package system
shouldn't be in= itialized if there is no package directory; I want to be
able to do pack= age operations even if I'm starting with no package
directory. You h= ave to start somewhere.

Thanks!

------------------
System = information
------------------

In GNU Emacs 27.0.50 (build 1, x86= _64-pc-linux-gnu, GTK+ Version 3.18.9)
=C2=A0of 2018-05-07 built on zck-= laptop
Repository revision: 766b057e41df7316808ec7658836fda75facda75
= Windowing system distributor 'The X.Org Foundation', version 11.0.1= 1804000
System Description: Ubuntu 16.04.4 LTS

Recent messages:Checking for load-path shadows...done
Auto-saving...
Overwrite mode= enabled in current buffer
<pause> is undefined
Undo! [3 times]=
user-error: No further undo information
C-c k is undefined
QuitC-x C-g is undefined
Mark set

Configured features:
XPM JPEG = TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GSETTINGS NOTIFY
ACL LIBSEL= INUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB
TOOLKIT_SCROLL_BAR= S GTK3 X11 THREADS LCMS2

Important settings:
=C2=A0 value of $LAN= G: en_US.UTF-8
=C2=A0 value of $XMODIFIERS: @im=3Dibus
=C2=A0 locale-= coding-system: utf-8-unix

Major mode: Fundamental

Minor modes= in effect:
=C2=A0 tooltip-mode: t
=C2=A0 global-eldoc-mode: t
=C2= =A0 electric-indent-mode: t
=C2=A0 mouse-wheel-mode: t
=C2=A0 tool-ba= r-mode: t
=C2=A0 menu-bar-mode: t
=C2=A0 file-name-shadow-mode: t
= =C2=A0 global-font-lock-mode: t
=C2=A0 auto-composition-mode: t
=C2= =A0 auto-encryption-mode: t
=C2=A0 auto-compression-mode: t
=C2=A0 bu= ffer-read-only: t
=C2=A0 line-number-mode: t
=C2=A0 transient-mark-mo= de: t

Load-path shadows:
None found.

Features:
(shadow = sort mail-extr emacsbug message rmc puny dired dired-loaddefs
format-spe= c rfc822 mml mml-sec epa derived epg gnus-util rmail
rmail-loaddefs mm-d= ecode mm-bodies mm-encode mail-parse rfc2231
mailabbrev gmm-utils mailhe= ader sendmail rfc2047 rfc2045 ietf-drums
mm-util mail-prsvr mail-utils c= l-extra pp cl-print package-x thingatpt
help-fns radix-tree help-mode ti= me-date elec-pair warnings package
easymenu epg-config url-handlers url-= parse auth-source cl-seq eieio
eieio-core cl-macs eieio-loaddefs passwor= d-cache json map url-vars seq
byte-opt gv bytecomp byte-compile cconv cl= -loaddefs cl-lib mule-util
tooltip eldoc electric uniquify ediff-hook vc= -hooks lisp-float-type
mwheel term/x-win x-win term/common-win x-dnd too= l-bar dnd fontset image
regexp-opt fringe tabulated-list replace newcomm= ent text-mode elisp-mode
lisp-mode prog-mode register page menu-bar rfn-= eshadow isearch timer
select scroll-bar 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 eucj= p-ms cp51932
hebrew greek romanian slovak czech european ethiopic indian= cyrillic
chinese composite charscript charprop case-table epa-hook jka-= cmpr-hook
help simple abbrev obarray minibuffer cl-preloaded nadvice loa= ddefs
button faces cus-face macroexp files text-properties overlay sha1 = md5
base64 format env code-pages mule custom widget hashtable-print-read= able
backquote dbusbind inotify lcms2 dynamic-setting system-font-settin= g
font-render-setting move-toolbar gtk x-toolkit x multi-tty
make-net= work-process emacs)

Memory information:
((conses 16 114821 11707)=
=C2=A0(symbols 48 21397 0)
=C2=A0(miscs 40 99 151)
=C2=A0(strings= 32 34316 1830)
=C2=A0(string-bytes 1 888700)
=C2=A0(vectors 16 17166= )
=C2=A0(vector-slots 8 524482 10750)
=C2=A0(floats 8 54 84)
=C2= =A0(intervals 56 292 144)
=C2=A0(buffers 992 15)
=C2=A0(heap 1024 446= 57 1840))

--000000000000fd4f6c056bd322bd--