I am a heavy user of https://github.com/yuya373/emacs-slack, and I noticed a weird behavior of auth-source-search: If I call this function multiple times, querying the second info always returns nil.

This is my slack configuration:

(let ((auth1 (car (auth-source-search :host "team1.slack.com")))
      (auth2 (car (auth-source-search :host "team2.slack.com"))))
   :name "Team 1"
   :user "some_email1@example1.com"
   :token (funcall (plist-get auth1 :secret)))
   :name "Team 2"
   :user "some_email2@example2.com"
   :token (funcall (plist-get auth2 :secret)))

And the second call to auth-source-search fails, making auth2 nil. So, Emacs cannot evaluate the expression (funcall (plist-get auth2 :secret)) since (plist-get auth2 :secret) is nil.

I am certain that auth-source-search is somehow broken, and have found a prior question to this: `auth-source-search` returns nil for valid queries . A comment to this question suggested to add :port keyword argument to auth-source-search, but in this case I cannot because the Slack auth info does not contain any port fields.

How can I solve this issue?

Edit: My .authinfo looks roughly like this:

host team1.slack.com user some_email1@example1.com password ...
machine imap.gmail.com login ... port ... password ...
machine smtp.gmail.com login ... port ... password ...
host team2.slack.com user some_email2@example2.com password ...

That is, the entry of team1.slack.com comes before that of team2.slack.com.

My Emacs is of version 27.1, configured with Spacemacs at the develop branch's latest commit.

  • 1
    You'll have to show us the contents of your .authinfo in order to determine if this is a bug or not (and tell us which version of Emacs you're using) – rpluim Jan 20 at 8:53
  • Oops, nice point. Will edit soon. – Namudon'tdie Jan 20 at 8:59

Yay, solved it: use machine instead of host for both authinfo.gpg and the keyword argument.

  • Can you tell us which bit of the auth-source manual led you to using host in your authinfo.gpg so we can fix it? – rpluim Jan 27 at 14:06
  • @rpluim The confusion was on my part. Because the keyword argument was :host, I incorrectly thought that the matching line of the authinfo should also be led by host, not machine. – Namudon'tdie Jan 28 at 7: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.