DEV Community

Jonas Samuelsson
Jonas Samuelsson

Posted on

Map drive letter to local folder

We have a group policy or something at work that tries to add some network drives at startup. This doesn't always work, espacially when working remotely.

This causes an error when using the azure cli, resulting in this type of error.

❯ az account show
Traceback (most recent call last):
  File "C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure\cli\__main__.py", line 33, in <module>
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure\cli\core\__init__.py", line 599, in get_default_cli
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure\cli\core\azlogging.py", line 30, in <module>
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure\cli\core\commands\__init__.py", line 28, in <module>
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure\cli\core\extension\__init__.py", line 18, in <module>
  File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-install-_kvuguic\knack\knack\config.py", line 38, in __init__
  File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-install-_kvuguic\knack\knack\util.py", line 111, in ensure_dir
  File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-install-_kvuguic\knack\knack\util.py", line 108, in ensure_dir
  File "C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\lib\os.py", line 210, in makedirs
    makedirs(head, mode, exist_ok)
  File "C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\lib\os.py", line 220, in makedirs
    mkdir(name, mode)
FileNotFoundError: [WinError 3] The system cannot find the path specified: 'P:\\\\'
Enter fullscreen mode Exit fullscreen mode

Mapping the failing drive letter to a local folder solves the problem, like this

subst p: c:\temp
Enter fullscreen mode Exit fullscreen mode

To remove the mapping, do

subst p: /D
Enter fullscreen mode Exit fullscreen mode

Top comments (0)