cli icon indicating copy to clipboard operation
cli copied to clipboard

Provide the option to resolve relative workspace path as symlinked path, not real path

Open ThePlenkov opened this issue 1 year ago • 9 comments

Hi,

This issue is a follow-up issue for those following issues:

  • https://github.com/docker/for-win/issues/14380
  • https://github.com/microsoft/vscode-remote-release/issues/10301

So the problem is following, somehow docker CLI doesn't like to mount folders, which are mount to WSL at same time. However if this folder like /mnt/wsl/workspace symlinked to something like ~/workspace , then when I mount it from ~/workspace - it works. However it doesn't work in VS Code, because it still resolves path to real path.

So I tried to test it just with devcontainers CLI and here is what I see:

If I run like this:

cd ~/workspace
devcontainer up --workspace-folder .

Then it doesn't work. It means that container is up and running, but workspace folder in the devctontainer is empty - there are no files. In Docker Desktop I can see that it resolves . into /mnt/wsl/worspace

However when I run the command like this:

devcontainer up --workspace-folder /home/myuser/workspace

Then devcontainer is up but also files are there. In the Docker Desktop I can see that the path is not changed.

So what I'd like CLI to do - whenever I provide a relative path like ., can it please follow cwd where I am in and not resolve it to a real path?

ThePlenkov avatar Nov 18 '24 10:11 ThePlenkov

~~We are using path.resolve(process.cwd(), workspaceFolderArg) to resolve the relative path. That seems to preserve the symlink and I would expect it to behave the same as with the absolute path to the symlinked folder.~~

chrmarti avatar Dec 17 '24 10:12 chrmarti

My above comment is incorrect: node -p 'process.cwd()' prints the target path and not the symlinked path. For some reason Node.js follows the symlink for that.

chrmarti avatar Dec 17 '24 10:12 chrmarti

I found one hacky way,not sure if it's a good solution https://stackoverflow.com/questions/24112452/node-dirname-process-cwd-are-reporting-actual-directory-instead-of-symlinke

ThePlenkov avatar Dec 17 '24 12:12 ThePlenkov

@chrmarti is there a way to use something like process.env.PWD ? process.env.PWD : process.cwd( ). I mean in Windows it just doesn't make sense. But for UNIX systems it would work perfectly

ThePlenkov avatar Dec 17 '24 13:12 ThePlenkov

As alternative - devcontainer to provide the option/flag to set cwd explicitly. So we can just run something like devcontainers up --cwd=$pwd

ThePlenkov avatar Dec 17 '24 13:12 ThePlenkov

@chrmarti I'm not sure if it matters, but I noticed in the console when I start a container:

Running Dev Containers CLI:   up --container-session-data-folder /tmp/devcontainers-aca8bcf8-4f9a-49a1-abe5-a3dccf5bf7f51734715720359 --workspace-folder /mnt/wsl/workspace/ubuntu/payops-service-db --workspace-mount-consistency cached 

I honestly have no idea - but just thought - is there a way to switch this mount consistency somehow and not to produce this --workspace-mount-consistency cached ?

I would like to use it only as a test

Thanks

ThePlenkov avatar Dec 20 '24 17:12 ThePlenkov

@ThePlenkov The Dev Containers extension has a setting for that:

Image

chrmarti avatar Jan 23 '25 07:01 chrmarti

Yes I saw it unfortunately it didn't help to solve my issue

ThePlenkov avatar Jan 23 '25 07:01 ThePlenkov

This seems to be a Docker issue: https://github.com/docker/for-win/issues/14380

chrmarti avatar Jan 23 '25 08:01 chrmarti