Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Network problem on Windows #4117

Closed
koxo opened this issue Nov 21, 2021 · 9 comments
Closed

Network problem on Windows #4117

koxo opened this issue Nov 21, 2021 · 9 comments
Assignees
Milestone

Comments

@koxo
Copy link

koxo commented Nov 21, 2021

Hi,
I want to report a problem on projects using a network drive on Windows.
When i create my project, i tell to use a folder in a network drive : example : "X:\MyProject".
In "c_cpp_properties.json" i have :

//
// !!! WARNING !!! AUTO-GENERATED FILE!
// PLEASE DO NOT MODIFY IT AND USE "platformio.ini":
// https://docs.platformio.org/page/projectconf/section_env_build.html#build-flags
//
{
    "configurations": [
        {
            "name": "PlatformIO",
            "includePath": [
                "/srv-nas/home/MyProject/MyProject/include",
                "/srv-nas/home/MyProject/MyProject/src",
                "C:/VSCode/platformio/packages/framework-arduino-avr/cores/arduino",
                ....................................................................................
                ""
            ],
            "browse": {
                "limitSymbolsToIncludedHeaders": true,
                "path": [
                    "/srv-nas/home/MyProject/MyProject/include",
                    "/srv-nas/home/MyProject/MyProject/src",
                    "C:/VSCode/platformio/packages/framework-arduino-avr/cores/arduino",
                    ....................................................... 
                    ""
                ]
            },
.............................................................

So i get squiggles in the editor.

If add a library, i get : "/srv-nas/home/MyProject/MyProject/.pio/libdeps/uno/LiquidCrystal/src" instead of "//srv-nas/home/MyProject/MyProject/.pio/libdeps/uno/LiquidCrystal/src" (with two "/") or "X:/MyProject/MyProject/.pio/libdeps/uno/LiquidCrystal/src".

If i modify the lines : "/srv-nas/home/MyProject/MyProject/include" into "//srv-nas/home/MyProject/MyProject/include" (with two "/") or "X:/MyProject/MyProject/include" it's good.

If i tell a drive path, the project should keep a drive path, if i enter a unc path it should use a unc path.

Thank you for your help

Best Regards

@ivankravets
Copy link
Member

Duplicate of #3926

Please re-test with pio upgrade --dev. Does it work now?

@koxo
Copy link
Author

koxo commented Nov 21, 2021

Hi Ivan,
It's good now !
Thank you for all
Best regards
KoXo

@koxo
Copy link
Author

koxo commented Jan 29, 2022

Hi Ivan
I have updated my version to 5.25a6 and the problem of network path is back !
Do you have forget something ?
Best regards
KoXo

@ivankravets ivankravets reopened this Jan 29, 2022
@ivankravets ivankravets added this to the 5.2.5 milestone Jan 29, 2022
@ivankravets ivankravets self-assigned this Jan 29, 2022
@ivankravets
Copy link
Member

I've just re-tested and everything works. Please check that you don't have multiple PIO Cores in the system https://docs.platformio.org/en/latest/faq.html#multiple-platformio-cores-in-a-system

@ivankravets ivankravets removed this from the 5.2.5 milestone Feb 3, 2022
@koxo
Copy link
Author

koxo commented Feb 3, 2022

Hi Ivan,
I have make some tests this morning, in fact it's good with a network drive.
The remaining problem is for a network location
if i am a user in a classical domain with the folder "Documents" redirected to an UNC path like "\server\usershare\documents",
in c_cpp_propserties.json i get "/server/usershare/documents/platformio/MyTest" instead of "//server/usershare/documents/platformio/MyTest". So i get squiggles and if i use libraries in my path, the autocompletion does not works correctly.
https://imgur.com/GSJgiH0
Thank you for your help.
KOXO

@ivankravets ivankravets reopened this Feb 3, 2022
@celsocos
Copy link

celsocos commented Apr 20, 2023

Hello. I also found problems with a network drive, and Ivan suggested to place information here so we can improve this point.

SCENARIO 1
A virtual PC (local machine) with VS Code and Platform IO, Arduino project.
I have a network share "\\ccsrv\Projetos" and inside the network share a folder "Projects"

So the drive letter P: is mapped to shared folder "\\ccsrv\Projetos" and in the c_cpp_properties.json we have the correct path using the P: drive letter, like “P:/Projects/Server Modbus/include” and similar.

No more problems with incomplete UNC path inside c_cpp_properties.json , that is good.

However, the CMD.EXE is started with the UNC path

‘\\CCSRV\Projetos\Projects\Server Modbus’
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported. Defaulting to Windows directory.

In my system, the provided registry hack did not work, and in fact the registry edit only supress the warnings. I expected the “current directory” to be ‘P:\Projects\Server Modbus’ with the cmd.exe, no UNC path.

But for some reason, the system still uses the UNC path in the complilation.
SUGGESTIONS:

  1. Maybe use the drive letter and not UNC path with CMD.EXE may fix?
  2. Even better: Maybe use the power shell instead of cmd.exe? Power shell does supports UNC path.

SCENARIO 2:
A virtual PC (local machine) with VS Code and Platform IO, Arduino project.
Just the network share "\\ccsrv\Projetos\Projects" without mapped drive.

Now we have a network UNC path incomplete in the c_cpp_properties.json and a general compiler crash, similar issue reported by Koxo. The double \ in the UNC path disapear like magic...

SUGGESTION:
The UNC path is very tricky within code, because it can be undestood as escape sequences. I had problems very similar I can see here, I wrote for sure double \ but just a sinlge \ was redered and a crazy bug was found. The first \ disapear like magic, it was quite hard to fix. I suspect the \ disapear like magic from UNC path because escape sequences, and I had no compliler errors, just a wrong string because the escape sequence.

NOTE: Also quite hard to write \\ here too, you can see double \ but I had to type three times...

Please let me know if I can help with something else.

@koxo
Copy link
Author

koxo commented Apr 20, 2023

Hi,
Thank you for your response.
In a network environment with connected drive, i use this drive to open the project and it seems good.
I have look at the source of pio and i have found a problem in "fs.py" :

def to_unix_path(path):
if not IS_WINDOWS or not path:
return path
return re.sub(r"[\\]+", "/", path)

This function replaces the '\' by '/', i think that the "+" is the problem in the reg expression.

def to_unix_path(path):
if not IS_WINDOWS or not path:
return path
return re.sub(r"[\\]", "/", path)

i have try this :

import re

IS_WINDOWS = 1

def to_unix_path(path):
if not IS_WINDOWS or not path:
return path
return re.sub(r"[\]+", "/", path)

def to_unix_path2(path):
if not IS_WINDOWS or not path:
return path
return re.sub(r"[\]", "/", path)

print("*** no modification ****")

path = "P:\Documents\Platformio\Projects\Test"
path = to_unix_path(path)
print("local (OK) :", path)

path = "\\dc1\ameunier$\Documents\Platformio\Projects\Test"
path = to_unix_path(path)
print("network (bad) :", path)

print("*** with modification ****")

path = "P:\Documents\Platformio\Projects\Test"
path = to_unix_path2(path)
print("local (OK) :", path)

path = "\\dc1\ameunier$\Documents\Platformio\Projects\Test"
path = to_unix_path2(path)
print("network (OK) :", path)

-->

*** no modification ****
local (OK) : P:/Documents/Platformio/Projects/Test
network (bad) : /dc1/ameunier$/Documents/Platformio/Projects/Test
*** with modification ****
local (OK) : P:/Documents/Platformio/Projects/Test
network (OK) : //dc1/ameunier$/Documents/Platformio/Projects/Test

Best regards.
Koxo

@ivankravets ivankravets added this to the 6.1.7 milestone Apr 20, 2023
@ivankravets
Copy link
Member

We have significantly improved support for network drives on Windows in the latest development version. See #3417

Please re-test with pio upgrade --dev.

Does it work now without any issues?

@koxo
Copy link
Author

koxo commented Apr 20, 2023

Hi Ivan,

I have see the beta update.

In fact you have modify function "to_unix_path" :

def to_unix_path(path):
if not IS_WINDOWS or not path:
return path
return path.replace("\\", "/")

So it's a little similar as my post above. (note that the two backslash of the reg expression were remove by github, i have modify this).

So it's better to directly make a replace directly, reg expressions are not necessary.

So it's good for me.

Thank you.

Koxo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants