jwiegley / use-package

A use-package declaration for simplifying your .emacs
https://jwiegley.github.io/use-package
GNU General Public License v3.0
4.4k stars 260 forks source link

Using 'use-package' causes error showing an appended hypen on package name #154

Closed zenshinji closed 9 years ago

zenshinji commented 9 years ago

Q: Why is use-package appending a hyphen on package names?

I get 'error: Package `aggressive-indent-' is unavailable' & the same thing for every package I try to set up except for 'dired-x'. 'linum-off' I was able to get working by installing it via elpa. Everything else I've tried fails in the same way as 'aggressive-indent'. I am running GNU Emacs 25.0.50.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.10.8).

Thoughts?

More Detail:

When trying to use 'use-package' I run into the following error:

Warning (initialization): An error occurred while loading `/home/pjorgensen/.emacs.d/init.el':

error: Package `aggressive-indent-' is unavailable

To ensure normal operation, you should investigate and remove the cause of the error in your initialization file. Start Emacs with the `--debug-init' option to view a complete error backtrace.

Here's my init.el:

;; -- mode: emacs-lisp; coding: utf-8 -- ;; ;; Title: init.el --- Where the magic begins ;; Author: ;; Email: ;; Version: 1.0 ;; Time-stamp: <> ;; Purpose: Set up base emacs environment

;; ;; -=[ About ]=- ;;

;; This file starts the server, loads Org-mode, loads ergoemacs, and then ;; loads the rest of our Emacs initialization from Emacs lisp embedded in ;; literate tangled Org-mode files. I try to do as little in here as ;; possible and define as much as possible in separate functional files ;; in ~/.emacs.d/ on each machine.

;; ;; -=[ Debugging Initialization ]=- ;;

;; activate debugging but disable others

(setq debug-on-error t debug-on-signal nil debug-on-quit nil server-socket-dir (format "~/tmp/emacs%d" (user-uid)) )

;; ;; -=[ Coding Initialization ]=- ;;

;; Set the coding to UTF-8 here to make sure everything after has it set. ;; Do this in as many ways as possible here to make sure it's reflected ;; properly everywhere.

(setq current-language-environment "UTF-8" default-process-coding-system '(utf-8 . utf-8) default-buffer-file-coding-system 'utf-8 coding-system-for-read 'utf-8 coding-system-for-write 'utf-8 locale-coding-system 'utf-8 x-select-request-type '(UTF8_STRING COMPOUND_TEXT TEXT STRING) ) (modify-coding-system-alist 'process "*" 'utf-8) (prefer-coding-system 'utf-8) (set-buffer-file-coding-system 'utf-8) (set-clipboard-coding-system 'utf-8) (set-default-coding-systems 'utf-8) (set-file-name-coding-system 'utf-8) (set-keyboard-coding-system 'utf-8) (set-language-environment 'utf-8) (set-selection-coding-system 'utf-8) (set-terminal-coding-system 'utf-8) (setq-default pathname-coding-system 'utf-8)

;; ;; -=[ File Initialization ]=- ;;

;; from https://github.com/technomancy/emacs-starter-kit/blob/master/init.el

(setq dotfiles-dir (file-name-directory (or (buffer-file-name) load-file-name)) )

;; from http://emacsblog.org/2008/12/06/quick-tip-detaching-the-custom-file/ ;; from https://github.com/technomancy/emacs-starter-kit/blob/master/init.el ;; Separate custom file for each host, placed in .emacs.d

(setq custom-file (concat dotfiles-dir system-name ".el")) (load custom-file 'noerror)

;; ;; -=[ Interface initialization ]=- ;;

;; Turn off the tool bar since it's ugly and redundant

(tool-bar-mode 0)

;; Prevent the cursor from blinking

(blink-cursor-mode -1)

;; Turn on column numbering

(column-number-mode)

;; Don't use messages that you don't read

(setq initial-scratch-message "" inhibit-startup-message t ;; ;; Don't let Emacs hurt your ears ;; visible-bell t ;; ;; You need to set `inhibit-startup-echo-area-message' from the ;; customization interface: ;; M-x customize-variable RET inhibit-startup-echo-area-message RET ;; then enter your username ;; inhibit-startup-echo-area-message user-login-name )

;; from http://www.emacswiki.org/emacs/emacs-init.el ;;; COMMENT THIS OUT IF YOU DO NOT WANT "SPECIAL" BUFFERS TO BE IN ;;; SEPARATE FRAMES ("Special" buffers are those, such as grep, ;;; whose names are within '*'s.) If `special-display-regexps' is ;;; non-nil, then special buffers are in dedicated frames (cannot ;;; dissociate the buffer and its frame).

(when (if (fboundp 'display-graphic-p) (display-graphic-p) window-system) (defconst special-display-regexps '("[ ]?[][^]+[*]")) )

;; ;; -=[ Server Initialization ]=- ;;

;; start the server unless its already started

(require 'server) (unless (server-running-p) (server-start) )

;; For Windows, the recommended way to associate files is to associate ;; them with emacsclientw.exe. In order for this to work when Emacs ;; is not yet started, you will also need to set the environment ;; variable ALTERNATE_EDITOR to runemacs.exe.

;; In order to run emacs-server on a windows host the ownership of the ;; directory ~/.emacs.d/server to your login name and the problem is gone ;; https://stackoverflow.com/questions/885793/emacs-error-when-calling-server-start

;; Set the %HOME% variable to %USERPROFILE% in the Windows System Properties - ;; Environment Variables - User. Create %HOME%\bin, %HOME%\var, %HOME%\tmp.

;; Add %HOME%\bin to the user's path in the same place. Set %TMP% to %HOME%\tmp.

;; ;; -=[ Package System Initialization ]=- ;;

;; initialize packages installed with the package system

;; (defun gnutls-available-p () ;; "Function redefined in order to not use built-in GnuTLS support" ;; nil) ;; (if (fboundp 'gnutls-available-p) ;; (fmakunbound 'gnutls-available-p)) ;; (setq tls-program '("gnutls-cli --strict-tofu -p %p %h") ;; imap-ssl-program '("gnutls-cli --strict-tofu -p %p %s") ;; smtpmail-stream-type 'starttls ;; starttls-extra-arguments '("--strict-tofu") ;; ) (require 'package) (package-initialize)

(add-to-list 'package-archives '("marmalade" . "https://marmalade-repo.org/packages/")) (add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/")) (add-to-list 'package-archives '("org" . "http://orgmode.org/elpa/") t)

;; Common Lisp

(require 'cl) (require 'cl-lib)

;; add ~/.emacs.d/elisp and all subdirectories to the load path for ;; downloaded packages

(add-to-list 'load-path (concat dotfiles-dir "elisp/")) (let ((default-directory (concat dotfiles-dir "elisp/")) (normal-top-level-add-to-load-path '(".")) (normal-top-level-add-subdirs-to-load-path) ) )

;; Bootstrap `use-package' (unless (package-installed-p 'use-package) (package-refresh-contents) (package-install 'use-package))

(require 'use-package)

;; ;; -=[ Org Mode Babel Tangle ]=- ;;

;; Load up Org Mode and the now included Org Babel for elisp embedded ;; in Org Mode files. I finish the org-mode configuration in init-org.org

(require 'org-install)

(setq dotfiles-dir (file-name-directory (or (buffer-file-name) load-file-name)))

(let* ((org-dir (expand-file-name "lisp" (expand-file-name "org" (expand-file-name "src" dotfiles-dir)))) (org-contrib-dir (expand-file-name "lisp" (expand-file-name "contrib" (expand-file-name ".." org-dir)))) (load-path (append (list org-dir org-contrib-dir) (or load-path nil))))

;; load up Org-mode and Org-babel

(require 'ob-tangle) )

;; load up all literate org-mode files in this directory

(mapc #'org-babel-load-file (directory-files dotfiles-dir t ".org$"))

;; ;; -=[ ErgoEmacs-mode Initialization ]=- ;;

;; ;; turn on ergoemacs early

;; (setq ;; ergoemacs-theme nil ; Uses Standard Ergoemacs keyboard theme ;; ergoemacs-keyboard-layout "us" ; Assumes QWERTY keyboard layout ;; ) ;; (ergoemacs-mode 1)

;;; init.el ends here

And my init_load_packages.el (generated from init_load_packages.org):

;; -- coding: utf-8 -- ;; Title: init_load_packages.el ;; ;; Author: ;; Version: 0.1 ;; Date: 2014-11-13 ;; Purpose: define packages for emacs

;; dired

;; [[file:~/.emacs.d/init_load_packages.org::*dired][dired:1]]

(use-package dired-x)

;; dired:1 ends here

;; linum off

;; Makes it possible to have some modes not have linum-mode on when global-linum-mode is on. As of GNU Emacs 24.3.1, linum-mode will freeze emacs for about 10 minutes when opening a jpg file of 10 megabytes size.

;; [[file:~/.emacs.d/init_load_packages.org::*linum%20off][linum\ off:1]]

(use-package linum-off :ensure t :defer t )

;; linum\ off:1 ends here

(use-package aggressive-indent :ensure t :init (global-aggressive-indent-mode 1) (add-to-list 'aggressive-indent-excluded-modes 'html-mode) )

Here's the output from emacs --debug-init:

Debugger entered--Lisp error: (error "Package aggressive-indent-' is unavailable") signal(error ("Packageaggressive-indent-' is unavailable")) error("Package `%s-%s' is unavailable" aggressive-indent "") package-compute-transaction(nil ((aggressive-indent))) package-install(aggressive-indent) use-package-ensure-elpa(aggressive-indent)

[(name &rest args) "\306!\210\307\310\311\211$\307\312\"\307\313\"\307\314\"\307\315\"\307\316\311#@\307\317\311\211$A\307\320\"B\307\321\"C\307\322\311\211$D\307\323\311\211$E\307\324\311\211$F\307\325\311\211$G\307\326\311\211$\211H;\203o

thomasf commented 9 years ago

That it's just an error formatting issue in package.el. The %s-%s part of your traceback says that, the last %s would be the version number if the package existed....

Try refreshing the package archives first and maybe verify that it is in the list afterwards:. M-x list-packages

Silex commented 9 years ago

I also get this occasionally. Never really investiguated it, I'll try to do so next time it happens. It usually happens after a "rm -r ~/.emacs.d" when my config tries to reinstall all packages.

thomasf commented 9 years ago

@Silex This is maybe related to your problem https://github.com/jwiegley/use-package/issues/134#issuecomment-66432039

As I wrote in my previous comment this is the error that occurs when a package isnt in the fetched archive lists.

Executing this:

(package-install "dodo")

Results in:

package-compute-transaction: Package `dodo-' is unavailable

It has nothing todo with use package.

Silex commented 9 years ago

@thomasf: that could make sense https://github.com/Silex/emacs-config/blob/master/packages.el#L128-137

Probably that sometimes it takes more than 5 seconds to refresh the packages, and thus the index is not ready when trying to package-install after with-timeout! That's very likely what happens.

zenshinji commented 9 years ago

Refreshing the package archive (M-x package-refresh-contents) and trying again worked. Thanks!