0

A couple of weeks ago I did a re-install of my Ubuntu and now I'm running into issues with my init file. See screenshot below.

I'm quite puzzled, probably something trivial, but I'm missing it ...

I've also tried http instead of https for the melpa address, same error.

Edit: Below the picture the complete init file, it seems to go wrong at the line

Edit 2: I start emacs GUIfrom the command line emacs & when there is a virtual env active with python 3.10.12 (not sure this is relevant, though). On startup the error message 'Package elpy-' not available' does not appear. It does not appear to be loading the init file, which is at ~/.emacs.d/init.el. Only when I do M-x load-file ~/.emacs.d/init.el ` the error message appears.

Edit 3: There was a ~/.emacs file that was used on the startup. I've removed that one and now I get a debug message when starting the emacs GUI like emacs --debug-init:

Debugger entered--Lisp error: (error "Package ‘elpy-’ is unavailable")
  signal(error ("Package ‘elpy-’ is unavailable"))
  error("Package `%s-%s' is unavailable" elpy "")
  package-compute-transaction(nil ((elpy)))
  package-install(elpy)
  (if (package-installed-p package) nil (package-install package))
  (lambda (package) (if (package-installed-p package) nil (package-install package)))(elpy)
  mapc((lambda (package) (if (package-installed-p package) nil (package-install package))) (elpy ein flycheck py-autopep8 blacken magit material-theme solarized-theme))
  eval-buffer(#<buffer  *load*> nil "/home/ytsen/.emacs.d/init.el" nil t)  ; Reading at buffer position 1313
  load-with-code-conversion("/home/ytsen/.emacs.d/init.el" "/home/ytsen/.emacs.d/init.el" t t)
  load("/home/ytsen/.emacs.d/init" noerror nomessage)
  startup--load-user-init-file(#f(compiled-function () #<bytecode 0x1716a6d573b1>) #f(compiled-function () #<bytecode 0x1716a6d5731d>) t)
  command-line()
  normal-top-level()

screenshot of "About Emacs", init file and error message

;; .emacs.d/init.el

;; ===================================
;; MELPA Package Support
;; ===================================
;; Enables packaging support
(require 'package)

;; Adds the Melpa archive to the list of available repositories
(add-to-list 'package-archives `("melpa" . "https://melpa.org/packages/"))


;; Initializes the package infrastructure
(package-initialize)

;; If there are no archived package contents, refresh them
(when (not package-archive-contents)
  (package-refresh-contents))

;; Installs packages
;;
;; myPackages contains a list of package names
(defvar myPackages
  '(
    elpy                            ;; Emacs Lisp Python Environment
    ein                             ;; Emacs iPython Notebook
    flycheck                        ;; On the fly syntax checking
    py-autopep8                     ;; Run autopep8 on save
    blacken                         ;; Black formatting on save
    magit                           ;; Git integration
    material-theme                  ;; Theme
    solarized-theme                 ;; Solarized theme
    )
  )

;; Scans the list in myPackages
;; If the package listed is not already installed, install it
(mapc #'(lambda (package)
          (unless (package-installed-p package)
            (package-install package)))
      myPackages)

;; ====================================
;; Basic Customization
;; ====================================

(setq inhibit-startup-message t)  ;; Hide the startup message
(load-theme 'solarized-light t)   ;; Load theme
(global-linum-mode t)             ;; Enable line numbers globally

;; ====================================
;; DEVELOPMENT SETUP
;; ====================================
;; Enable elpy
(elpy-enable)

;; Use IPython for REPL
;; (setq python-shell-interpreter "jupyter"
;;       python-shell-interpreter-args "console --simple-prompt"
;;       python-shell-prompt-detect-failure-warning nil)
;; (add-to-list 'python-shell-completion-native-disabled-interpreters
;;              "jupyter")
 
;; Enable Flycheck
(when (require 'flycheck nil t)
  (setq elpy-modules (delq 'elpy-module-flymake elpy-modules))
  (add-hook 'elpy-mode-hook 'flycheck-mode))

;; Enable Autopep8
;; (require 'py-autopep8)
;; (add-hook 'elpy-mode-hook 'py-autopep8-enable-on-save)

;; User-Defined init.el ends here
(custom-set-variables
 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(custom-safe-themes
   (quote
    ("c433c87bd4b64b8ba9890e8ed64597ea0f8eb0396f4c9a9e01bd20a04d15d358" "00445e6f15d31e9afaa23ed0d765850e9cd5e929be5e8e63b114a3346236c44c" default)))
 '(package-selected-packages
   (quote
    (realgud-ipdb realgud material-theme magit blacken py-autopep8 flycheck ein  yasnippet-snippets elpy))))
(custom-set-faces
 ;; custom-set-faces was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 )


(setq scroll-step            1
      scroll-conservatively  10000)

(setq-default indent-tabs-mode nil)
9
  • 2
    The screenshot is not enough to diagnose the problem. Why don't you post your init file (or the portion of it relevant to the problem)?
    – NickD
    Commented Apr 24 at 18:58
  • But it fails on the first line of the defvar myPackages ... at least, so I though. I'll post the rest too, hang on a sec. Thanks for looking in any case :) Commented Apr 24 at 19:49
  • Start with emacs --debug-init and add the backtrace (if any) to your question.
    – NickD
    Commented Apr 25 at 3:22
  • FWIW, I created a new user on my system and did emacs -nw --debug-init in a terminal for that user (with your init.el above as the user's initialization file). I ran it with emacs-30 (unreleased upstream code) and it barfed on global-linum-mode, but when I commented that out, it initialized properly. I also ran it with emacs-28.3 and it barfed with void function defvar-1 when loading elpy-refactor in the elpy-enable call: it seems that defvar-1 does not exist in 28.3 (but this remains to be verified). I don't have 27.1 available unfortunately, so I can't say what happens there.
    – NickD
    Commented Apr 25 at 3:29
  • Based on the above quick (and certainly not definitive) tests, my guess is that the version of elpy you are installing is incompatible with Emacs 27.1. Please try to verify by doing the --debug-init test and reporting the backtrace (if any).
    – NickD
    Commented Apr 25 at 3:32

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.