'Error: "Windows can't find 'C:/PROGRA~1/'. Check the spelling and try again."

I am getting an error in R in Windows 10 about finding a directory while trying to install a package from GitHub*. Trying to troubleshoot this error led me to a few observations.

For example, both Windows Explorer and my browser can find C:/PROGRA~1, but only my browser can find C:/PROGRA~1/R, where R is installed. The specific Windows Explorer error is:

Windows can't find 'C:/PROGRA~1/R'. Check the spelling and try again.

Yet, Windows Explorer can find C:/Program Files/R no problem. And the error above is the same with C:/PROGRA~1/Adobe, C:/PROGRA~1/Google, or any other. Even more interesting, Windows Explorer can't even find the raw program files path as long as we add a simple slash at the end! So C:/PROGRA~1/ will output a similar error.

So can anyone explain to me why Windows Explorer is not able to find C:/PROGRA~1/R or C:/PROGRA~1/? Is this normal/expected? If I solve this, I can probably resolve my R error too. Thanks.

*Here is the full original error in R:

Error: Failed to install 'package' from GitHub:
  create process 'C:/PROGRA~1/R/R-40~1.3/bin/x64/Rcmd.exe' (system error 267, The directory name is invalid.
) @win/processx.c:1040 (processx_exec)

Edit: My investigation revealed that it might be related to the direction of slashes... So for instance, C:/PROGRA~1\R (or even C:/PROGRA~1\) works in Windows Explorer, but only as long as the second slash is a backslash... Can this be of any help in resolving this issue? Doesn't seem like R wants to put that second slash as backslash...



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source