hatch icon indicating copy to clipboard operation
hatch copied to clipboard

Local dependency specification with context formatting for NFS path breaks

Open clint-enki opened this issue 2 years ago • 3 comments

I'm running a VM with VirtualBox to test out an application in Windows. The repository is mounted into the VM using NFS (VirtualBox mounts paths under //vboxsvr), and there is a local dependency that's in that NFS directory. The context formatting that works on native Linux or Windows breaks in this case, i.e.

dependencies = [
  # ...
  "foo @ {root:parent:uri}/foo",  # This equates to: file:////vboxsvr/my_repo/foo
]

However, this works:

dependencies = [
  # ...
  "foo @ file://vboxsvr/my_repo/foo",
]

It seems like for the NFS path should only contain the first two path separators, and not the four that the uri context formatter adds.

This is a niche edge case. Would it be possible to detect if the path for a dependency is in a UNC path, i.e. is prefixed by //, and then the uri context formatter would only add the file: prefix.

My work around is to detect the VM, and set an env var and then do this:

dependencies = [
  # ...
  "foo @ {env:PROJ_URI_VM:{root:parent:uri}}/foo",
]

Setup:

  • hatch 1.9.0
  • python 3.11.7
  • Windows 11 VM

clint-enki avatar Dec 19 '23 10:12 clint-enki

Hey! I think rather than handling your edge case directly I should call os.path.normpath internally. Would that suffice?

ofek avatar Dec 19 '23 14:12 ofek

@ofek I tested that out on my side and it didn't fix the issue (I made the changes in fs.py). This is quite a niche issue. I've run into bigger issues in that cmd.exe can't handle the UNC path anyway. I don't mind if we close the issue.

clint-enki avatar Jan 02 '24 08:01 clint-enki

What did you try exactly?

ofek avatar Jan 02 '24 18:01 ofek