Git bash 和 cmd 不加载我的用户帐户 PATH 变量

Git bash 和 cmd 不加载我的用户帐户 PATH 变量

启动 gitbash 或 Windows cmd 会话并运行

echo $PATH

或者

echo %PATH%

echo $PATH它们都打印系统 PATH 变量的内容,但都没有打印特定于我的用户帐户的 PATH 变量的内容。作为参考,以下是git bash 中的输出:

/c/Users/Chiel.tenBrinke/bin:/mingw64/bin:/usr/local/bin:/usr/bin:/bin:/mingw64/bin:/usr/bin:/c/Users/Chiel.tenBrinke/bin:/c/Program Files (x86)/Intel/iCLS Client:/c/Program Files/Intel/iCLS Client:/c/Windows/system32:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0:/c/Program Files/ThinkPad/Bluetooth Software:/c/Program Files/ThinkPad/Bluetooth Software/syswow64:/c/Program Files/Intel/Intel(R) Management Engine Components/DAL:/c/Program Files/Intel/Intel(R) Management Engine Components/IPT:/c/Program Files (x86)/Intel/Intel(R) Management Engine Components/DAL:/c/Program Files (x86)/Intel/Intel(R) Management Engine Components/IPT:/c/Program Files (x86)/Intel/OpenCL SDK/2.0/bin/x86:/c/Program Files (x86)/Intel/OpenCL SDK/2.0/bin/x64:/c/Program Files/Common Files/Lenovo:/c/SWTOOLS/ReadyApps:/c/Program Files (x86)/Common Files/Lenovo:/c/Program Files/Intel/WiFi/bin:/c/Program Files/Common Files/Intel/WirelessCommon:/c/Program Files/Symantec.cloud/PlatformAgent:/c/Program Files (x86)/Windows Kits/8.1/Windows Performance Toolkit:/c/Program Files/Microsoft SQL Server/110/Tools/Binn:/c/Program Files (x86)/Microsoft SQL Server/100/Tools/Binn:/c/Program Files/Microsoft SQL Server/100/Tools/Binn:/c/Program Files/Microsoft SQL Server/100/DTS/Binn:/c/Program Files (x86)/Microsoft SDKs/TypeScript/1.0:/c/Program Files/Microsoft SQL Server/120/Tools/Binn:/c/Program Files/Microsoft/Web Platform Installer:/c/Program Files (x86)/IBM/Personal Communications:/c/Program Files (x86)/IBM/Trace Facility:/c/Program Files/7-Zip:/c/Program Files (x86)/Gource/cmd:/c/Program Files (x86)/LLVM/bin:/c/Program Files/Perforce:/c/Program Files/Perforce/DVCS:/c/Users/Chiel.tenBrinke/.dnx/bin:/c/Program Files/Microsoft DNX/Dnvm:/c/Program Files/nodejs:/c/ProgramData/chocolatey/bin:/c/Program Files/Microsoft SQL Server/130/Tools/Binn:/c/Go/bin:/c/Users/Chiel.tenBrinke/bin:/c/Program Files (x86)/Python 3.5/Scripts:/c/Program Files (x86)/Python 3.5:/c/ProgramData/Oracle/Java/javapath:/c/Program Files/Python 3.5/Scripts:/c/Program Files/Python 3.5:

为了澄清系统 PATH 和用户 PATH 之间的区别,此屏幕截图显示了允许您编辑用户变量和系统变量的面板,这就是我所指的区别:

截屏

根据要求,以下是用户 PATH 的内容:

C:\Ruby22-x64\bin;C:\Users\Chiel.tenBrinke\bin;C:\Program Files (x86)\CMake\bin;C:\Users\Chiel.tenBrinke\AppData\Local\Pandoc\;C:\Users\Chiel.tenBrinke\luacheck\bin;C:\Windows\Microsoft.NET\Framework64\v4.0.30319;C:\Users\Chiel.tenBrinke\AppData\Roaming\npm;C:\Users\Chiel.tenBrinke\.babun;C:\Users\Chiel.tenBrinke\.gem\ruby\2.2.0\bin;C:\Program Files (x86)\ChucK\bin

和系统 PATH:

C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\ThinkPad\Bluetooth Software\;C:\Program Files\ThinkPad\Bluetooth Software\syswow64;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x86;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x64;C:\Program Files\Common Files\Lenovo;C:\SWTOOLS\ReadyApps;C:\Program Files (x86)\Common Files\Lenovo;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files\Symantec.cloud\PlatformAgent\;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\DTS\Binn\;C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Files (x86)\IBM\Personal Communications\;C:\Program Files (x86)\IBM\Trace Facility\;C:\Program Files\7-Zip;C:\Program Files (x86)\Gource\cmd;C:\Program Files (x86)\LLVM\bin;C:\Program Files\Perforce;C:\Program Files\Perforce\DVCS\;C:\Users\Chiel.tenBrinke\.dnx\bin;C:\Program Files\Microsoft DNX\Dnvm\;C:\Program Files\nodejs\;C:\ProgramData\chocolatey\bin;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Go\bin;C:\Users\Chiel.tenBrinke\bin;C:\Program Files (x86)\Python 3.5\Scripts\;C:\Program Files (x86)\Python 3.5\;C:\ProgramData\Oracle\Java\javapath;C:\Program Files\Python 3.5\Scripts\;C:\Program Files\Python 3.5\;C:\Program Files\Git\cmd

如何确保我的用户 PATH 变量在 cmd 和 git bash 中也被考虑在内?

答案1

我如何确保我的用户PATH变量被考虑在内。

您的问题是您的系统路径目前太长(2000 个字符)。修复此问题也应该修复您的bash路径,因为这通常基于 Windows 路径。

你可以:

  • 将系统路径缩短至少于 1920 个字符,或者

  • 将用户路径值添加到系统路径。


echo 是否%PATH%仅扩展到系统变量还是也扩展到用户变量?

发现在 Windows Server 2003 上,一旦系统 PATH 超过 1920 个字符,用户 PATH 环境变量就不再与其合并来设置进程 PATH 环境变量,即使完整的系统 PATH(即使更大)将包含在进程 PATH 变量中。

来源echo %PATH% 是否仅扩展到系统变量还是也扩展到用户变量?回答大卫·赫弗南

相关内容