Unknown 'hg' Version

This isn’t exactly question about mercurial repositories, but let me ask this because I’m not sure this is a general question or mercurial specific one.

After installing phabricator, “Unknown ‘hg’ Version” has been shown in “setup issues” menu (/config/issue/ page).
I installed phabricator into my PC for evaluation, and guess this is caused by LANG environment variable.

$ echo $LANG
ja_JP.UTF-8
$ hg version
Mercurial - 分散構成管理ツール(バージョン 4.2)
(詳細は https://mercurial-scm.org を参照)

Copyright (C) 2005-2017 Matt Mackall and others
本製品はフリーソフトウェアです。
頒布条件に関しては同梱されるライセンス条項をお読みください。
市場適合性や特定用途への可否を含め、 本製品は無保証です。

Is my guess right? If so, can I solve this issue?

I can understand why running phabricator in non-EN environment doesn’t be stable.

From reading https://secure.phabricator.com/T7339, it sounds like you can just generate a locale for EN_US locally and version detection should work.

  1. check which locales are supported:
    locale -a
  2. add the locale:
    sudo locale-gen en_US
    sudo locale-gen en_US.UTF-8
  3. run this update comand
    sudo update-locale

THAT IS GREAT!!!
I’ll try it later! :grinning:

nn…
unfortunately, it doesn’t seems to work for my environment. I’m not sure whether I did something wrong. Is something wrong with this locale settings?

$ locale -a
C
C.UTF-8
POSIX
en_AG
en_AG.utf8
en_AU.utf8
en_BW.utf8
en_CA.utf8
en_DK.utf8
en_GB.utf8
en_HK.utf8
en_IE.utf8
en_IN
en_IN.utf8
en_NG
en_NG.utf8
en_NZ.utf8
en_PH.utf8
en_SG.utf8
en_US
en_US.iso88591
en_US.utf8
en_ZA.utf8
en_ZM
en_ZM.utf8
en_ZW.utf8
ja_JP.utf8

So far, I avoid this Unknown 'hg' Version issue rewriting libphutil/src/filesystem/binary/PhutilMercurialBinaryAnalyzer.php as bellow:

public static function parseMercurialBinaryVersion($stdout) {
  // NOTE: At least on OSX, recent versions of Mercurial report this
  // string in this format:
  //
  //   Mercurial Distributed SCM (version 3.1.1+20140916)

  $matches = null;
  //$pattern = '/^Mercurial Distributed SCM \(version ([\d.]+)/m';  <= this is original.
  $pattern = '/([\d.]+)/m';
  if (preg_match($pattern, $stdout, $matches)) {
    return $matches[1];
  }

  return null;
}

This regular expression may cause troubles. I agree it is sure that it is very difficult to modify regular expression for multilingual properly.

Possibly fixed by https://secure.phabricator.com/D18610.

1 Like

I made sure and it was actually fixed. Thanks!