117

Problem on WindowsXP (likely will happen on all Win installs), first 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")

Kevin Won
  • 7,156
  • 5
  • 36
  • 54

10 Answers10

94

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.

Stephen Ostermiller
  • 23,933
  • 14
  • 88
  • 109
Kevin Won
  • 7,156
  • 5
  • 36
  • 54
  • 1
    I posted this q/a to hopefully help someone in the future from having to waste time with this nugget. – Kevin Won Feb 25 '10 at 04:20
  • 4
    Actually there's no Mercurial.ini file in my install directory either. Adding a file called `hgrc` in the `.hg` folder of my repository with the above text allowed me to commit changes. – Phil Gan May 03 '10 at 21:49
  • 2
    No Mercurial.ini file in my install directory either (Win 7 64-bit). I created Mercurial.ini on C:\Users\Abbas and copy-pasted Kevin's [ui] snippet and it worked like a charm. Tried Phil's solution and it worked too. – Abbas Dec 24 '10 at 17:39
  • Thanks for the question and answer. It would have taken me ages to figure that out. Ah, the hardships of developing on Windows... – Wes Apr 22 '11 at 14:42
  • I am using Tortoise Hg and that tip help me as well. Thanks ! – James Freitas Mar 12 '16 at 19:12
51

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.

Stephen Ostermiller
  • 23,933
  • 14
  • 88
  • 109
Martin Geisler
  • 72,968
  • 25
  • 171
  • 229
  • (1) the installer doesn't copy the .ini to the user directory, (2) the error text makes perfect sense in a *nix context but not for windows. I think the problem is tha the error msg doesn't make sense in a windows context (at least on xp). Having now installed this on Ubuntu, I can say that the msg is fine for that platform, but stand by my contention that it s not helpful for Windows (xp at least). Thanks for your work on Mercurial and I hope this comment helps make the issue I had clearer. – Kevin Won Mar 09 '10 at 06:00
  • 1
    Thanks for the explanation -- it's so nice to see when people followup on questions with the solution they found :-) However, the help text for `hg help config` does include instructions for Windows, i.e., it lists the possible locations of your `Mercurial.ini` file. One of the locations is `C:\Program Files\Mercurial\Mercurial.ini` (listed as `\Mercurial.ini`), so I'm unsure why the settings in that file did not take effect. – Martin Geisler Mar 10 '10 at 21:48
  • 13
    The big problem for me (and what brought me to this question) was the fact none of this is mentioned on the quick start page: http://mercurial.selenic.com/quickstart/#. That page implies that a basic install followed by following the instructions will work, and it doesn't, without reading the help text. At this point you are nervous because you already assume something has gone wrong – Nick Fortescue Mar 15 '10 at 11:52
  • 1
    Ah, I see what you mean. This change is new in Mercurial 1.4 and we forgot to update the quickstart guide. Sorry about that! – Martin Geisler Mar 15 '10 at 13:47
  • 7
    @Martin Geisler: The `hg help config` text doesn't say what we need to do to solve the problem and it's not particularly clear where the paths are pointing in the "On Windows" section. Where does `%USERPROFILE%` or `%HOME%` point? I guess it doesn't help that following installation `mercurial.ini` doesn't exist anywhere on my system. – Phil Gan May 03 '10 at 14:41
  • @Phil: as you've probably guessed, I'm no Windows user :-) But I think I would open a Command Prompt and execute `echo %USERPROFILE%` to see what the value is of the environment variable (I think `echo` works the same as in Linux, but I'm not 100% sure). But fear not -- we talked about changing this just yesterday on our IRC channel: I expect the next version of Mercurial to prompt you for your username and store it for you in the right `Mercurial.ini` file. – Martin Geisler May 03 '10 at 18:17
  • @Martin Geisler: Actually that's not too important - I can have a good guess at what `%USERPROFILE%` might signify but none of the files listed in the `hg help config` output exist after running the installer. Previous experience would suggest that missing files mean something somewhere has gone seriously wrong. As it turns out I only needed to make an ini file myself. (And get TortoiseHG and VisualHG) – Phil Gan May 03 '10 at 21:46
  • I agree that it's confusing that we don't put in a template configuration file -- we are asked about this on IRC quite a lot by both Linux, Windows, and Mac users. – Martin Geisler May 04 '10 at 08:57
  • 8
    Don't mean to be insulting, so please take this as an attempt to be constructive. There may be an answer in the 1260 lines of text that gets printed out to standard out when I do "hg help config" but I really think that 1260 lines of text is excessive and that a short distinct answer, even if it sends me to the docs would be much much better. – Tony Giaccone Apr 02 '12 at 20:53
  • 4
    @TonyGiaccone: Back in 2010 `hg help config` would only print a screenful of text and I had made sure that setting the username was the main example in that text. Since then we've managed to screw that up by including the help text for all config options in that output :-( I've opened an issue for this: http://mercurial.selenic.com/bts/issue3348 – Martin Geisler Apr 02 '12 at 21:32
  • +1 for your comment regarding the 'noise' I came here rather than trying to hunt through the huge help config output – Sam May 18 '13 at 22:38
  • I believe the correct link to the issue is this: http://bz.selenic.com/show_bug.cgi?id=3349 – Patrick Jun 19 '13 at 14:09
  • Where is that config file on Ubuntu? – int_ua Oct 24 '13 at 01:29
  • 1
    @int_ua: You add the username to `~/.hgrc` on Ubuntu. The config files are described in the beginning of [hg help config](http://www.selenic.com/mercurial/hgrc.5.html#files). – Martin Geisler Oct 24 '13 at 06:31
  • Yes, it worked, thanks. The problem was that the help wasn't piped through less so I've seen only the ending and the filename was above the lines limit. – int_ua Oct 24 '13 at 07:07
13

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
Stephen Ostermiller
  • 23,933
  • 14
  • 88
  • 109
Zamboni
  • 7,897
  • 5
  • 43
  • 52
9

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'

Stephen Ostermiller
  • 23,933
  • 14
  • 88
  • 109
Usuario
  • 91
  • 1
4

If you are using TortoiseHg, you can add [UI] settings easily

  1. Right clicking in any folder Explorer to access the TortoiseHg menu.

  2. From the flyout TortoiseHg menu choose Global Settings

  3. From the interface click the Edit File

  4. Add the [UI] settings to the end

    [ui]
    username = YourName <YourEmail@SomeAddress.com>
    verbose = true
    
  5. Save and you are done

Stephen Ostermiller
  • 23,933
  • 14
  • 88
  • 109
3

Here is what worked like a charm for me on Windows XP:

  1. Go to the folder C:\Program Files\Mercurial\hgrc.d assuming you have installed Mercurial to C:\Program Files\Mercurial\.
  2. You should see a Mercurial.RC file in there.
  3. Copy the file to C:\Documents and Settings\ [USERNAME]\
  4. Rename Mercurial.RC to Mercurial.ini.
  5. 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
    
Stephen Ostermiller
  • 23,933
  • 14
  • 88
  • 109
Ralph Wiggum
  • 699
  • 1
  • 6
  • 10
  • Also works for Windows Server 2008 and the 64 bit Mercurial msi except of course step 3 should be c:\users\[username] – Andrew Cowenhoven Oct 09 '11 at 16:59
  • Having installed "TortoiseHg 2.2 with Mercurial 2.0 - x86 Windows", the Mercurial.RC file can be found under C:\Program Files\TortoiseHg\hgrc.d – urig Nov 30 '11 at 07:36
1

Configure you .hgrc like this:

[ui]
username = your name <youremail@host.example>
verbose = True

NOTE! Do not leave out the [ui] part

Stephen Ostermiller
  • 23,933
  • 14
  • 88
  • 109
Wedava
  • 1,211
  • 2
  • 16
  • 30
1

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.

Jérôme Verstrynge
  • 57,710
  • 92
  • 283
  • 453
1

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.

Jérôme Verstrynge
  • 57,710
  • 92
  • 283
  • 453
Dean Schulze
  • 9,633
  • 24
  • 100
  • 165
0

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
Jérôme Verstrynge
  • 57,710
  • 92
  • 283
  • 453