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

host-mnt can be in different formats #20

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Bazek
Copy link

@Bazek Bazek commented Feb 24, 2021

My possible paths are:

/run/desktop/mnt/host/C/some-path
C:\some-path

@masquevil
Copy link

Hi @Bazek , do you know how to build this on my local PC? I want to use this~

@@ -24,8 +28,8 @@ def docker_bind_to_windows_path(path):
str: Converts Hyper-V mount path to Windows path (e.g. /C/some-path -> C:/some-path).

"""
expr = re.compile('^(?:/host_mnt)?/([a-zA-Z])/(.*)$')
match = re.match(expr, path)
expr = re.compile(r'^(?:/host_mnt/|/run/desktop/mnt/host/)?([a-zA-Z]):?[/\\](.*)$')
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not ^(?:/host_mnt|/run/desktop/mnt/host)?/([a-zA-Z]):?[/\\](.*)$?. Otherwise we will break compatibility with old versions (e.g. expression in your PR does not match /C/some-path)

@slippycheeze
Copy link

Hoi. It'd be great if this change, or something similar, was merged into the pypi release. I hit the same issue, because /run/desktop/mnt/host/${drive}/... on my system...

@biplobmanna
Copy link

Just came across this issue, and since many systems have different host paths, why not have some sort of flag / arguments passed through cmd while running the program. That way we can also preserve the backwards compatibility, and different paths can also be accommodated?

(my path was in C:/something/something format)

@biplobmanna
Copy link

From what I observe, we have 2 cases to consider:

  1. *nix style path of format /some/mnt/or/host/path/ preceding the actual system path
    eg: /run/desktop/mnt/host/C/some/path/to/the/thing or /host_mnt/C/some/path/to/the/thing

  2. Windows style path, eg: C:\some\path\to\the\thing

Assuming that the path that is passed will always be a valid path (in any format) we can modify the function to include 2 steps:

  1. Check if the path is a proper Windows Style path
    if so, return original path

  2. Extract only the <drive>/path/to/the/thing from the path provided and convert it into a valid Windows path

This way backwards compatibility will also be maintained, since this case covers the original case of /host_mnt/C/some/path

I will create a PR for this.

@sergiu-enache
Copy link

sergiu-enache commented Jul 18, 2023

any chance the PR can be merged?

I can manually modify the scripts and it works fine for me, but I'd want to pass this tool for my whole team and I'd hate to tell them to manually apply fix.

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

Successfully merging this pull request may close these issues.

6 participants