如何将工作区(一个简单的项目)从 windows 文件系统 (/mnt/) 移动到 linux (~/home)

tah*_*tof 8 linux windows wsl-2

我正在开发一个 Django 项目(没有)并尝试使用 WSL2。

因此,如果我使用 Windows 中的 Ubuntu 终端创建一个项目并尝试在 VScode 中运行它,我会收到这条小消息,

在此处输入图片说明

我根本不知道该怎么做,

这是我第一次尝试使用 WSL2(很棒),如果有人可以提供帮助,非常感谢。

Ras*_*lav 24

If you have your project in some mounted folder -> linux path starting with /mnt/ e.g. /mnt/c/Users/rasto/Desktop/some_folder/my_project/

When you open VS Code in this directory (via running command code . or opening the VS Code from windows) you get the warning:

This workspace is on the Windows file system (/mnt/). For best performance, we recommend moving the workspace to the Linux file system (~/home).

The solution is easy -> move/copy the project folder to ~/my_project/ directory:

In WSL terminal:

Recursively copy all files from source-path to destination-path and if the folder ~/my_project/ does not exists, it will be created

 cp -R /mnt/c/Users/rasto/Desktop/some_folder/my_project/ ~/my_project
Run Code Online (Sandbox Code Playgroud)

Move to the directory in your terminal

cd ~/my_project
Run Code Online (Sandbox Code Playgroud)

And open VS Code from console with

code .
Run Code Online (Sandbox Code Playgroud)

Note: To open VS Code from terminal you must have installe extension Remote Development extension pack

注意2:要从 Windows 文件资源管理器访问 linux 文件夹,只需右键单击 VS Code资源管理器在资源管理器中显示,或使用以下路径:\\wsl$\Ubuntu-18.04\home\rasto\my_projects