views:

3354

answers:

10

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")

+11  A: 

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 = [email protected]

This fixed the problem for me.

Kevin Won
I posted this q/a to hopefully help someone in the future from having to waste time with this nugget.
Kevin Won
Sweet very good one mate, saved me loads of time.
simplyme
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
+2  A: 

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?

Martin Geisler
(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
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 `<install-dir>\Mercurial.ini`), so I'm unsure why the settings in that file did not take effect.
Martin Geisler
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
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
@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
@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
@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
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
A: 

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

Pierre Ducher
A: 

I am getting same error. I am on Fedora 11. Not finding Mercurial.ini file. Any ideas how can I resolve this error?

Snehal
A: 

no matter windows or linux, hg looks the "/.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 verbose = true

save and "hg commit -m 'test'"

Usuario
+1  A: 

But in my /.hg/,I can't find the hgrc file. I add a file named ghrc and add the [ui] username=test verbose = true . then run the hg commit command . I always report the error message :abort: no username supplied (see "hg help config"). any help?

x16man
+1  A: 

I installed hg on win xp. C:\Program Files\Mercurial\Mercurial.ini was not created, as were all of the hgrc files listed in 'hg help config'. I created a hgrc file in the repository under .hg and entered [ui] username = My Name verbose = true (case sensitive) and it worked. Any idea why the installation did not create those files in the 1st place?

Marwan
A: 

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.

mathias wellner
+1  A: 

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 = [email protected]

Zamboni
A: 

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.

Dean Schulze