Skip to content

Comments

Improve directory watching for macOS compatibility#349

Open
aomsinister wants to merge 2 commits intoBedrock-OSS:developfrom
aomsinister:main
Open

Improve directory watching for macOS compatibility#349
aomsinister wants to merge 2 commits intoBedrock-OSS:developfrom
aomsinister:main

Conversation

@aomsinister
Copy link

Description

Fixes the regolith watch command failing on macOS with the error:

[ERROR] Could not start watching `./packs/RP`
[ERROR] lstat packs/RP/...: no such file or directory

Problem

The watch command was using the experimental "..." recursive watching syntax (filepath.Join(root, "...")) from the fsnotify fork, which doesn't work reliably on macOS.

Solution

  • Replaced the "..." syntax with filepath.WalkDir to manually traverse and add each subdirectory to the watcher
  • Added the os import for os.DirEntry
  • This approach provides better cross-platform compatibility

Testing

Tested on:

  • macOS (darwin/amd64) - ✅ Watch command now works
  • The fix maintains compatibility with the existing watcher behavior on other platforms

Changes

  • Modified regolith/watcher.go:
    • Updated watch() function to use filepath.WalkDir
    • Added os to imports

Nusiq and others added 2 commits January 25, 2026 22:41
Refactor directory watching to add root and subdirectories for macOS compatibility.
@Nusiq Nusiq changed the base branch from main to develop February 12, 2026 18:51
@Nusiq
Copy link
Member

Nusiq commented Feb 12, 2026

Sweet. This probably means we could also switch back to the official fsnotify and close this: #298

Unfortunately, no. See the comment below.

@Nusiq
Copy link
Member

Nusiq commented Feb 12, 2026

I found an issue with this approach on Windows that seems to be very small and but I'm worried it could cause issues on real big projects.

I'm using the most simple setup you can imagine - here is my config.json:

{
	"$schema": "https://raw.githubusercontent.com/Bedrock-OSS/regolith-schemas/main/config/v1.7.json",
	"author": "Your name",
	"name": "Project name",
	"packs": {
		"behaviorPack": "./packs/BP",
		"resourcePack": "./packs/RP"
	},
	"regolith": {
		"dataPath": "./packs/data",
		"filterDefinitions": {},
		"formatVersion": "1.7.0",
		"profiles": {
			"default": {
				"export": {
					"bpPath": "build/bp",
					"rpPath": "build/rp",
					"target": "local"
				},
				"filters": []
			}
		}
	}
}

The issue I experienced can be reproduced with following steps:

  1. Create a new project, and replace config.json with the config file mentioned above.
  2. Run regolith watch
  3. Using VSCode add deeply nested path in BP. For example 1/2/3/4.txt
image

I don't think doing it via VSCode is necessary but I'm listing the exact steps I followed. The problem is in step 4.

  1. Delete the path created in previous step. The file can't be deleted without admin permission:
image

What's interesting is that you can safely delete the file if you don't go all the way down to the folder 1 or 2. Deleting 3 works.

Performing the same steps using current stable release (1.7.0) doesn't have that issue.

Also, by chaotically adding and removing files I managed to break the watcher completely once. Unfortunately, I don't know how to reproduce this.


I could approve this PR, but only if the alternative watcher behavior is for macOS only with other systems using the old implementation. We already have some system-specific implementations for Windows vs other systems in the code so it's not a big issue. The only problem is that I don't have MacOS and I wouldn't be able to maintain that part.

@Nusiq Nusiq self-requested a review February 12, 2026 20:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants