HGRCPATH 保存在 /etc/sudoers 中,但被 hg 忽略?

HGRCPATH 保存在 /etc/sudoers 中,但被 hg 忽略?

我正在尝试按照指示进行操作这里在“sudo 和多个用户”下。我相信我设法足够正确地修改(通过在默认部分的开头/etc/sudoers添加,但后来因为 sudo 给我解析错误而剪切),因为我得到了这个:Defaults :me env_keep += "HGRCPATH":me

[me /]$ su
Password:
[root /]$ echo $HGRCPATH
/home/me/.hgrc

然而,当我尝试实际使用时hg,我遇到了麻烦:

[me /]$ sudo hg commit -m "Initial check-in."
abort: no username supplied (see "hg help config")

的确:

[me /]$ sudo hg debugconfig --debug | grep read
read config from: /usr/etc/mercurial/hgrc
read config from: /etc/mercurial/hgrc
read config from: /etc/mercurial/hgrc.d/mergetools.rc
read config from: /root/.hgrc

为什么hg似乎忽略 $HGRCPATH 并查找/root/.hgrc而不是/home/me/.hgrc

更新

以下是未注释的行/etc/sudoers

$ sudo cat /etc/sudoers | grep '^[^#]'
Defaults env_keep += "HGRCPATH"
Defaults    requiretty
Defaults   !visiblepw
Defaults    always_set_home
Defaults    env_reset
Defaults    env_keep =  "COLORS DISPLAY HOSTNAME HISTSIZE INPUTRC KDEDIR LS_COLORS"
Defaults    env_keep += "MAIL PS1 PS2 QTDIR USERNAME LANG LC_ADDRESS LC_CTYPE"
Defaults    env_keep += "LC_COLLATE LC_IDENTIFICATION LC_MEASUREMENT LC_MESSAGES"
Defaults    env_keep += "LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER LC_TELEPHONE"
Defaults    env_keep += "LC_TIME LC_ALL LANGUAGE LINGUAS _XKB_CHARSET XAUTHORITY"
Defaults    secure_path = /sbin:/bin:/usr/sbin:/usr/bin
root    ALL=(ALL)       ALL
me     ALL=(ALL)       ALL

答案1

Defaults env_keep += "HGRCPATH"
Defaults    env_keep =  "COLORS DISPLAY HOSTNAME HISTSIZE INPUTRC KDEDIR LS_COLORS"

第二行重置env_keep。坚持+=或移动=任何线之前的线+=

相关内容