development

Windows 10에서 환경 변수가 너무 큼

big-blog 2020. 7. 26. 11:35
반응형

Windows 10에서 환경 변수가 너무 큼


나는 이것이 이상하다는 것을 알고 있으며 유용한 솔루션을 얻지 않고 온라인으로 솔루션을 검색하는 데 거의 3 일을 보냈습니다. 그래서 여기에 오기로 결정했습니다.

최근에 Windows 8.1에서 Windows 10으로 업그레이드했습니다.

이제 새로운 Apache Maven 설치를위한 환경 변수를 설정하고 싶었습니다.

사용자 변수를 만들 때마다 문제가 없습니다. 그러나 사용자 변수에서 aready가 작성한 변수에 "path"가되도록 bin 디렉토리를 추가해야하는 시스템 변수도 작성해야합니다.

이제이 작업을 수행 할 때마다 "이 환경 변수가 너무 큽니다. 결과적으로 경로를 만들 수 없습니다.

이 오류의 이미지를 첨부했습니다.

누구 든지이 문제를 해결하도록 도와 줄 수 있다면 감사하겠습니다.

도움을 주셔서 감사합니다.여기에 이미지 설명을 입력하십시오


PATH 변수에 너무 많은 값이 오버로드되면 더 이상 값을 추가 할 수없는 지점에 도달합니다. 다음을 시도하면 문제가 해결됩니다.

해결책 1 :

  1. 'NEWPATH'라는 새 시스템 변수를 만듭니다.
  2. bin 디렉토리 위치를 'NEWPATH'에 지정하십시오.
  3. 이제 ' ; % NEWPATH % '를 PATH 변수에 추가

그래도 문제가 해결되지 않으면 기존의 PATH 변수 일부를 'NEWPATH'에 복사 한 다음 'NEWPATH'를 추가하십시오.

해결책 2 :

경로를 그룹화하고 단축 할 수있는 경우 PATH 변수 값을 확인하십시오. 예를 들어

C : \ Program Files \ Microsoft SQL Server \ 102 \ Tools \ Binn \; C : \ 프로그램 파일 \ Microsoft SQL Server \ 102 \ DTS \ Bin \;

에 결합 될 수있다

C : \ Program Files \ Microsoft SQL Server;

In this way you can build more space into your fixed length PATH variable and finally adjust your bin directory location into PATH.

Hope this helps you!


There are few ways to clean up your path variable. The easiest is to use Rapid Environment Editor. This free utility will,

  1. Remove the duplicate paths (right click > Cleanup Paths)
  2. Remove non-existent folders (shown in red which you need to manually delete)
  3. Replace long paths with short paths (right click > long to short path).

I do above steps in order and use 3rd step only for longest paths until Path variable size is in control again.

If you want to go more advanced, here's little C# tool that you can modify to whatever other logic you want to implement.


Another solution or more a workaround to bypass the Environment PATH variable length limit is to manage your path (add, remove or update) using a PowerShell script;

1) Capture the current PATH variable by clicking "Edit Text" (see above screenshot) and copy it to your clipboard and save it in a text file as a backup too to avoid bad surprises. This is not mandatory but will allow you to recover should something go wrong.

2) Now that it is backed up, add the following to a new PowerShell (.ps1) file (amending the first line below with the folder path(s) you want to add (the part after the + sign):

$newPath = $env:Path + '; C:\Users\....\FirstFolderToAddToPath; C:\Users\....\SecondFolderToAddToPath;'

[Environment]::SetEnvironmentVariable("Path", $newPath, "Machine")

$env:Path = $newPath

This is how I managed to get my (long) PATH variable back after playing with the Windows 10 UI, being caught by the length limitation and loosing most of my path. I hope it helps.


In addition to the answer of Swapnil, note that you can modify the maximum length of a single path in the Path variable - which is otherwise historically limited to 260 characters. In Windows 10, you achieve this by setting the LongPathsEnabled registry key to 1, which can be found here:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem

To access the registry editor: Windows Key+R, type Regedit.

Source: https://superuser.com/a/1119980

Also take a look at this SuperUser answer: https://superuser.com/a/1119980/327009


Late answer but I was looking for something similar and ended up here. I changed all the paths to variables for program files and programdata (this one saves like 1 character though not as important).

For something like nodejs, i changed the normal path of

C:\Program Files\nodejs\

to

%ProgramFiles%\nodejs\

This can be done with "C:\Program Files (x86)\" as well using "%ProgramFiles(x86)%\"

It saved me a few characters but enough that it stopped complaining I feel.


I found you can do via PowerShell.

[System.Environment]::SetEnvironmentVariable("PATH", "C:\Program Files (x86......etc.....", "Machine")

So I grabbed existing system PATH, pasted into notepad, added my new thing, then pasted into the "C:\Program Files" bit of the above. Path updated. Done.


Workaround:

Please restart the system. After restarting the system, PATH is no longer empty, but may get truncated to 2047 (4095) characters If the system restart does not help please:

Launch c:\windows\system32\regedit.exe Go to the registry hive "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" Clean up unnecessary directories from the “Path” key Restart the system

Note: In some exceptional cases if the system is not able to start please:

Login in the safe mode Open the command prompt shell and type: reg add "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v Path /t REG_EXPAND_SZ /d ^%SystemRoot^%\system32;^%SystemRoot^% /f

For more details: https://software.intel.com/en-us/articles/limitation-to-the-length-of-the-system-path-variable


In addition to other methods (e.g. Powershell), I found a nice GUI, "Rapid Environment Editor" that can handle larger text values.

https://www.rapidee.com/en/download


Try modify by regedit, in my case it works when length more than 3000.

Press Win + R and enter regedit to open regedit. Go to Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment, and modify value of Path to your path. And restart computer, it should works.


Workarround. Use Edit Text and edit your PATH in a text Editor

참고 URL : https://stackoverflow.com/questions/34491244/environment-variable-is-too-large-on-windows-10

반응형