0

I am on a fresh install of emacs 26.3, and I have the following in my init.el:

(require 'package)
(add-to-list 'package-archives
         '("melpa", "https://melpa.org/packages") t)
(package-initialize)

When I go to refresh the package list (M-x package-refresh-contents) I encounter the following error:

  string-match("\\`https?:" ((\, "http://melpa.org/packages/")) nil)
  package--download-one-archive(("melpa" (\, "http://melpa.org/packages/")) "archive-contents" t)
  package--download-and-read-archives(t)
  package-refresh-contents(t)
  package-menu-refresh()
  package-list-packages(nil)
  funcall-interactively(package-list-packages nil)
  call-interactively(package-list-packages record nil)
  command-execute(package-list-packages record)
  execute-extended-command(nil "package-list-packages" "package-lis")
  funcall-interactively(execute-extended-command nil "package-list-packages" "package-lis")
  call-interactively(execute-extended-command nil nil)
  command-execute(execute-extended-command)

What is happening and why doesn't this work? I have seen some chatter on related issues that

(setq gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3")

before (package-initialize) should resolve this issue, but it doesn't

5

The error seems to be saying that ((\, "http://melpa.org/packages/")) doesn't match the regex

"\`https?:"

Let's look at that value, the one being added to package-archives:

'("melpa", "https://melpa.org/packages")

If we put this into IELM, let's see what we get:

ELISP> '("melpa", "https://melpa.org/packages")
("melpa"
 (\, "https://melpa.org/packages"))

Oh! This is not what we expect! The cdr of this list is a proper list (we want a string), and that has a comma as the first character.

What happened here? What is each element of package-archives supposed to be?

package-archives is a variable defined in ‘package.el’.

Each element has the form (ID . LOCATION).

A period instead of a comma makes this a single cons cell, and not a proper list. The proper code is:

(add-to-list 'package-archives
         '("melpa" . "https://melpa.org/packages") t)
  • 1
    Thank you, correct syntax is good to have :/ – learner Nov 11 at 23:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.