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\", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\lib\", line 85, in _run_code
    exec(code, run_globals)
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure\cli\", line 33, in <module>
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure\cli\core\", line 599, in get_default_cli
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure\cli\core\", line 30, in <module>
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure\cli\core\commands\", line 28, in <module>
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure\cli\core\extension\", line 18, in <module>
  File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-install-_kvuguic\knack\knack\", line 38, in __init__
  File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-install-_kvuguic\knack\knack\", line 111, in ensure_dir
  File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-install-_kvuguic\knack\knack\", line 108, in ensure_dir
  File "C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\lib\", line 210, in makedirs
    makedirs(head, mode, exist_ok)
  File "C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\lib\", line 220, in makedirs
    mkdir(name, mode)
FileNotFoundError: [WinError 3] The system cannot find the path specified: 'P:\\\\'

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

subst p: c:\temp

To remove the mapping, do

subst p: /D

Top comments (0)

🌚 Browsing with dark mode makes you a better developer.

It's a scientific fact.