I have a .emacs file in which I use package-install to automatically install needed packages from a repository at initialization. Up to now, I was using the http://melpa.milkbox.net/packages/ repository, which I got from an online tutorial. At some point, I tried to install the auctex package and got an error message which told me the package was not available under that repository. I checked and it is true. I found out the the auctex package is available under the GNU repository: http://elpa.gnu.org/packages/ instead.
What I tried to do is the following: add a second package repository (GNU ELPA in this case) to my .emacs file from which package-install can feed if it needs to install packages not available under the first repository (MELPA).
I am not an expert (in fact, I am a pure beginner) in Elisp and I browsed various threads to find a solution. Here is my actual code:
(package-initialize)
(require 'package)
(add-to-list 'package-archives
'(("melpa" . "http://melpa.milkbox.net/packages/")
("gnu" . "http://elpa.gnu.org/packages/")) t)
(package-refresh-contents)
(dolist (package '(use-package))
(unless (package-installed-p package)
(package-install package)))
(use-package paredit :ensure t)
(dolist (package '(auctex ; <-- Not available under MELPA!
auto-complete
auto-complete-c-headers
magit
sr-speedbar
yasnippet
))
(unless (package-installed-p package)
(package-install package))
(require package))
With this code in my .emacs file, when I boot emacs up, my configurations are ignored. I get this error message: error: Required feature 'auctex' was not provided.
How can I modify my code to see the auctex package from GNU ELPA?
For your information, I use Ubuntu 16.04 with GNU Emacs 24.5.1.
EDIT: Just to add a few words on what Stefan proposed: there were several problems with my code and splitting my add-to-list 'package-archives ...) in two calls did not seem, to work (although it is the right thing to do, of course). This was due to my (require package) line was trying to do: (require auctex) at some point. See this post to see why that is a problem.
I read on the fact that (require 'package-name) is not needed after package installation. This post explains why. removing this line made sure that auctex was loaded correctly, because it was automatically loaded.
From then on, everything worked fine, no more errors or warnings. I then tried to remove my lines:
(add-to-list 'package-archives
'("gnu" . "http://elpa.gnu.org/packages/"))
and auctex package was still loaded correctly.
(dolist (package '(use-package))...)? That iterates over the list whose sole element is the symboluse-package- one iteration only, binding variablepackageto symboluse-package. - Drew