Mercurial error: abort no username supplied
Problem on WindowsXP (likely will happen on all Win installs), firs开发者_运维知识库t time using Mercurial. I found the answer in an inobvious place so I'm asking/answering the question myself so others don't have to search like I did.
First time using Mercurial on machine.
Add new repoz:
c:\bla\>hg add
no problem.
Next, commit:
c:\bla\hg commit
error:
abort: no username supplied (see "hg help config")
Solution:
On my Windows install, the Mercurial.ini
did not get propagated. It also needs a user email added to it.
Take the default Mercurial.ini
file found at in the Mercurial executable install directory (C:\Program Files\Mercurial\Mercurial.ini
on my machine)
and copy it to your user home dir (C:\Documents and Settings\myName
on winXP).
On a Windows 7 install there is no default .ini, you will need to create a new one in C:\Users\myName
.
Then edit that .ini file. Find this area. The username needs an email set. It will be blank--add your email name here.
[ui]
; editor used to enter commit logs, etc. Most text editors will work.
editor = notepad
username = userEmail@domain.example
This fixed the problem for me.
I'm sorry, but why do you call this a problem? Mercurial asks you to see hg help config
, and this help text explicitly tells you how to add a username -- I know since I wrote that help text :-)
How should we improve the error message to make this more clear?
However, we've managed to screw this up by making hg help config
include help for all config settings. So the nice little example of how to set the username:
[ui]
username = Your Name <your@email.example>
is now lost in the noise (add this to ~/.hgrc
, creating the file if necessary). I've opened an issue for this.
On Windows XP I do not see an ini file.
After creating the repository using the command hg init
,
I added a file with the name hgrc
to the folder .hg
With the following content:
[ui]
editor = notepad
username = zamboni@icemachine.example
no matter Windows or Linux, hg looks the <repo>/.hg/hgrc
file for valid configuration. As in "hg help config" says, you only have to add at the end of that file the following lines:
[ui]
username = YOUR NAME <EMAIL@HOST.EXAMPLE>
verbose = true
save and hg commit -m 'test'
If you are using TortoiseHg, you can add [UI] settings easily
Right clicking in any folder Explorer to access the TortoiseHg menu.
From the flyout TortoiseHg menu choose Global Settings
From the interface click the Edit File
Add the
[UI]
settings to the end[ui] username = YourName <YourEmail@SomeAddress.com> verbose = true
Save and you are done
Here is what worked like a charm for me on Windows XP:
- Go to the folder
C:\Program Files\Mercurial\hgrc.d
assuming you have installed Mercurial toC:\Program Files\Mercurial\
. - You should see a
Mercurial.RC
file in there. - Copy the file to
C:\Documents and Settings\ [USERNAME]\
- Rename
Mercurial.RC
toMercurial.ini
. - Edit the [ui] section like so:
[ui] ; editor used to enter commit logs, etc. Most text editors will work. editor = notepad verbose = True username = userEmail@domain.example
I had the same problem. What helped me was to put [ui]
and username = firstname lastname
on separate lines of the ~/.hgrc
file. Putting these two things on one line did not work and led to the error.
This problem still exists. The mercurial.ini
file is ignored no matter where you put it.
No mercurial.ini
file is created during installation. I created one in the Mercurial install directory, but it had no effect. I copied it to %USERPROFILE%
and then to %HOME%
, but neither one works.
Putting .hgrc
in the HOME directory works.
The documentation ("hg help config") needs to be fixed.
Configure you .hgrc like this:
[ui]
username = your name <youremail@host.example>
verbose = True
NOTE! Do not leave out the [ui]
part
This is a problem because in the help file the path to the specified config file does not exist, we have to copy the Mercurial.ini
from program files directory to USER directory, maybe this is a problem coming from the installer on windows.
@Kevin Won: you forgot to add the line:
verbose = True
精彩评论