28
29

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Windowsのパスの長さ制限に引っかかったので短くしてみた

Posted at

WindowsにはPath環境変数の長さに制限があって、長すぎるとUser定義のPathが無視されてしまいます。

Systemだけで下みたいなことになって長さ制限に引っかかりました。

C:\>echo %path% | perl -nle "s/;/;\n/g;print $_"
C:\Program Files (x86)\Haskell\bin;
C:\Program Files (x86)\Haskell Platform\2013.2.0.0\lib\extralibs\bin;
C:\Program Files (x86)\Haskell Platform\2013.2.0.0\bin;
C:\Program Files (x86)\Intel\iCLS Client\;
C:\Program Files\Intel\iCLS Client\;
%SystemRoot%\system32;
%SystemRoot%;
%SystemRoot%\System32\Wbem;
%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;
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\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;
D:\ProgrammingLanguages\scala\\bin;
D:\ProgrammingLanguages\Dwimperl\perl\bin;
D:\ProgrammingLanguages\Dwimperl\perl\site\bin;
D:\ProgrammingLanguages\Dwimperl\c\bin;
C:\Program Files\TortoiseSVN\bin;
C:\Program Files (x86)\Git\cmd;
C:\Program Files\nodejs\;
C:\Program Files\TortoiseGit\bin;
C:\Program Files (x86)\Haskell Platform\2013.2.0.0\mingw\bin;
%GROOVY_HOME%\bin;

※ 上記はSystemのPathが長すぎて、Userで追記したPathが無視されている状態です。

なので、Windows7のmklinkコマンドを使って短くしてみました。
大体長いのはProgram Files (x86)とかProgram Filesなので、

mklink /d P "C:\Program Files"
mklink /d Q "C:\Program Files(x86)"

とすることで、

C:\>echo %path% | perl -nle "s/;/;\n/g;print $_"
C:\Q\Haskell\bin;
C:\Q\Haskell Platform\2013.2.0.0\lib\extralibs\bin;
C:\Q\Haskell Platform\2013.2.0.0\bin;
C:\Q\Intel\iCLS Client\;
C:\P\Intel\iCLS Client\;
C:\Windows\system32;
C:\Windows;
C:\Windows\System32\Wbem;
C:\Windows\System32\WindowsPowerShell\v1.0\;
C:\Q\Intel\OpenCL SDK\2.0\bin\x86;
C:\Q\Intel\OpenCL SDK\2.0\bin\x64;
C:\P\Intel\Intel(R) Management Engine Components\DAL;
C:\P\Intel\Intel(R) Management Engine Components\IPT;
C:\Q\Intel\Intel(R) Management Engine Components\DAL;
C:\Q\Intel\Intel(R) Management Engine Components\IPT;
D:\ProgrammingLanguages\scala\\bin;
D:\ProgrammingLanguages\Dwimperl\perl\bin;
D:\ProgrammingLanguages\Dwimperl\perl\site\bin;
D:\ProgrammingLanguages\Dwimperl\c\bin;
C:\P\TortoiseSVN\bin;
C:\Q\Git\cmd;
C:\P\nodejs\;
C:\P\TortoiseGit\bin;
C:\Q\Haskell Platform\2013.2.0.0\mingw\bin;
C:\Q\Groovy\Groovy-2.1.3\bin;
C:\Q\Haskell\bin;
C:\Q\Haskell Platform\2013.2.0.0\lib\extralibs\bin;
C:\Q\Haskell Platform\2013.2.0.0\bin;
C:\Q\Intel\iCLS Client\;
C:\P\Intel\iCLS Client\;
C:\Windows\system32;
C:\Windows;
C:\Windows\System32\Wbem;
C:\Windows\System32\WindowsPowerShell\v1.0\;
C:\Q\Intel\OpenCL SDK\2.0\bin\x86;
C:\Q\Intel\OpenCL SDK\2.0\bin\x64;
C:\P\Intel\Intel(R) Management Engine Components\DAL;
C:\P\Intel\Intel(R) Management Engine Components\IPT;
C:\Q\Intel\Intel(R) Management Engine Components\DAL;
C:\Q\Intel\Intel(R) Management Engine Components\IPT;
D:\ProgrammingLanguages\scala\\bin;
D:\ProgrammingLanguages\Dwimperl\perl\bin;
D:\ProgrammingLanguages\Dwimperl\perl\site\bin;
D:\ProgrammingLanguages\Dwimperl\c\bin;
C:\P\TortoiseSVN\bin;
C:\Q\Git\cmd;
C:\P\nodejs\;
C:\P\TortoiseGit\bin;
C:\Q\Haskell Platform\2013.2.0.0\mingw\bin;
C:\Q\Groovy\Groovy-2.1.3\bin;
C:\Users\h.ayabe\AppData\Roaming\cabal\bin;
C:\Ruby200-x64\bin;
C:\P\Java\jdk1.7.0_17\bin;
C:\Program Files\7-Zip;
D:\DevTools\Maven\apache-maven-3.0.5\bin;
C:\Program Files (x86)\Git\bin\;
D:\ProgrammingLanguages\Python33;
C:\;
C:\Users\h.ayabe\AppData\Roaming\npm;
C:\P\PostgreSQL\9.2\bin;
C:\P\7-Zip;

ちゃんと動くようになりました。

28
29
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
28
29

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?