sveltejs / sapper

The next small thing in web development, powered by Svelte

Home Page:https://sapper.svelte.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Live reload does not work with WSL2

kaito3desuyo opened this issue · comments

Describe the bug
Live reload does not work with WSL2

Logs
No logs

To Reproduce

  1. npx degit "sveltejs/sapper-template#rollup" my-app (also same problem with webpack)
  2. App start with WSL2 (source code is located in /mnt/c/***)

Expected behavior
The app should be reloaded if the source code changes

Information about your Sapper Installation:

  • Your operating system: (e.x. OS X 10, Ubuntu Linux 19.10, Windows XP, etc)
    Windows 10 x64 2004 19041.172 (insider preview) + WSL2 Ubuntu 18.04

  • Your hosting environment: (i.e. Local, GCP, AWS, Now, etc...)
    Local

  • Sapper version (Please check you can reproduce the issue with the latest release!)
    v0.27.0

  • Svelte version (Please check you can reproduce the issue with the latest release!)
    v3.0.0

  • Whether your application uses Webpack or Rollup
    Rollup

Severity
Inhibits comfortable development.

Is the project directory outside the WSL root directory? I believe this is a know issue with WSL2. Try moving the project into your home dir.

Is the project directory outside the WSL root directory? I believe this is a know issue with WSL2. Try moving the project into your home dir.

yeah, source code located in /mnt/c/something.

When I created a project in the root directory of WSL, it worked fine.

Is the project directory outside the WSL root directory? I believe this is a know issue with WSL2. Try moving the project into your home dir.

yeah, source code located in /mnt/c/something.

When I created a project in the root directory of WSL, it worked fine.

Yep
It's all about the file sharing protocol. wsl2 now works with the 9P protocol, which may not currently support the file change event.
At this point, the easiest solution is to transfer files to the linux home directory.

P.S. Also, if you transfer files, wsl2 speed will increase

Huh I didn't realize that WSL2 didn't support file events on the host disk (yet?) and I no longer think I will be switching to it when it's officially released.

In any case, if this is a known limitation in WSL2, I think this should be closed. Sapper should have a reasonable expectation that certain features be available in its environment, and we don't want to have to worry about this specific case.

Using WSL 2 with docker containers

Deleting my node_modules in my project, and deleting rollup in my C:\Program Files\nodejs\node_modules global folder and force reinstalling with npm i -g rollup --force worked for me.

Make sure to install your code in a linux filesystem instead of using WSL file-sharing (eg: put your files in an Ubuntu filesystem, and use VSCode Remote-WSL extension)