regolith
regolith copied to clipboard
The `regolith watch` command deadlock
Running regolith watch on a project without rp, bp and data folders crashes Regolith.
Steps to reproduce the issue:
- Create regolith project (
regolith init) - Delete the
datafolder. - Run
regolith watch - Regolith will crash with following error:
[22:43:24] bb> regolith init
[INFO] Initializing Regolith project...
[INFO] Regolith project initialized.
[INFO] Finished
[22:43:31] bb> regolith watch
[INFO] Regolith project cache is in:
C:\Users\Laptop\AppData\Local\regolith\project-cache\8c81d497d3d3fd94cc8b127ecbc4193f
[WARN] resource folder "./packs/RP" does not exist
[WARN] behavior folder "./packs/BP" does not exist
[WARN] data folder "./packs/data" does not exist
[INFO] Moving files to target directory.
[INFO] Exporting behavior pack to "C:\Users\Laptop\AppData\Local\Packages\Microsoft.MinecraftUWP_8wekyb3d8bbwe\LocalState\games\com.mojang/development_behavior_packs/Project name_bp".
[INFO] Copying ACL from parent directory.
Source: C:\Users\Laptop\AppData\Local\Packages\Microsoft.MinecraftUWP_8wekyb3d8bbwe\LocalState\games\com.mojang\development_behavior_packs
Target: C:\Users\Laptop\AppData\Local\Packages\Microsoft.MinecraftUWP_8wekyb3d8bbwe\LocalState\games\com.mojang/development_behavior_packs/Project name_bp
[INFO] Exporting project to "C:\Users\Laptop\AppData\Local\Packages\Microsoft.MinecraftUWP_8wekyb3d8bbwe\LocalState\games\com.mojang\development_resource_packs\Project name_rp".
[INFO] Copying ACL from parent directory.
Source: C:\Users\Laptop\AppData\Local\Packages\Microsoft.MinecraftUWP_8wekyb3d8bbwe\LocalState\games\com.mojang\development_resource_packs
Target: C:\Users\Laptop\AppData\Local\Packages\Microsoft.MinecraftUWP_8wekyb3d8bbwe\LocalState\games\com.mojang/development_resource_packs/Project name_rp
[INFO] Successfully ran the "default" profile.
[INFO] Press Ctrl+C to stop watching.
fatal error: all goroutines are asleep - deadlock!
goroutine 1 [chan receive (nil chan)]:
github.com/Bedrock-OSS/regolith/regolith.(*RunContext).AwaitInterruption(...)
D:/projects/Regolith/regolith/regolith/regolith/filter.go:93
github.com/Bedrock-OSS/regolith/regolith.runOrWatch({0x0, 0x0}, 0x0?, 0x1)
D:/projects/Regolith/regolith/regolith/regolith/main_functions.go:280 +0x9ac
github.com/Bedrock-OSS/regolith/regolith.Watch(...)
D:/projects/Regolith/regolith/regolith/regolith/main_functions.go:303
main.main.func7(0xc000005200?, {0xe5f150?, 0x0?, 0x0?})
D:/projects/Regolith/regolith/regolith/main.go:291 +0x4c
github.com/spf13/cobra.(*Command).execute(0xc000005200, {0xe5f150, 0x0, 0x0})
D:/projects/Regolith/regolith/regolith/vendor/github.com/spf13/cobra/command.go:920 +0x847
github.com/spf13/cobra.(*Command).ExecuteC(0xc000004300)
D:/projects/Regolith/regolith/regolith/vendor/github.com/spf13/cobra/command.go:1044 +0x3bd
github.com/spf13/cobra.(*Command).Execute(...)
D:/projects/Regolith/regolith/regolith/vendor/github.com/spf13/cobra/command.go:968
main.main()
D:/projects/Regolith/regolith/regolith/main.go:380 +0x14d7
goroutine 6 [chan send]:
github.com/Bedrock-OSS/regolith/regolith.CheckUpdate({0x9de22b, 0xb}, 0x0?)
D:/projects/Regolith/regolith/regolith/regolith/update.go:18 +0x95
created by main.main
D:/projects/Regolith/regolith/regolith/main.go:184 +0x125
The problem is caused by the StartWatchingSourceFiles function that creates yieldChanges closure which tries to start watching a directory, but when it doesn't exist it skips the error silently.
https://github.com/Bedrock-OSS/regolith/blob/a2616aa29cca8cc8230b67f5927d6bb4c4f48730/regolith/filter.go#L73-L83