Why does ERC connect to ZNC without password, even if it's in .authinfo?
I faced a problem where I had a self-hosted ZNC instance and I was trying to connect to it using Emacs ERC. My password for ZNC was placed in the .authinfo file that Emacs auth-source should read, but ERC never read that password and displayed the Logging in without password message in the echo area. Here’s how I was trying to connect:
(erc-tls :server "myzncinstance.com" :user "myusername/LiberaChat")
Note the ZNC specific username format, where myusername is the name of the user within ZNC, and LiberaChat is the name of the network defined within ZNC for that particular user.
And my .authinfo:
machine myzncinstance.com login myusername/LiberaChat password mypasswordhere
The solution
As you’ve seen above, I called (erc-tls) with :user. It turns out that ERC tries to find a matching .authinfo entry using the :nick prop, not :user. You can see that for yourself in the ERC source code here.
To fix my initial problem, all you have to do is call (erc-tls) like this:
(erc-tls :server "myzncinstance.com" :user "mysuername" :nick "myusername/LiberaChat")
The .authinfo file is kept unchanged from my initial example.
The property :nick is added solely so that ERC can find the correct .authinfo entry. The :user property is changed to contain just the ZNC user name, without the ZNC network name. This is because ZNC refuses to authenthicate if :user is not provided.