Replies: 1 comment 6 replies
-
|
Rsbuild checks the output directory before cleaning, and the situation you described should not happen.
|
Beta Was this translation helpful? Give feedback.
6 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment

Uh oh!
There was an error while loading. Please reload this page.
-
Description
When configuring
output.distPath.rootas/, runningrsbuild dev(orbuild) may result in deleting files under the system root directory.This is extremely dangerous and can cause irreversible system damage (data loss, OS corruption).
In my case, this configuration caused large parts of my macOS system directories to be deleted, requiring a full OS reinstall.
Steps to Reproduce
pnpm run devExpected Behavior
rsbuild should refuse to use dangerous root paths such as:
/C:\other system root directories
At minimum, rsbuild should throw an explicit error, for example:
Refusing to clean output directory "/". This path is unsafe.
Actual Behavior
rsbuild attempts to clean the output directory before starting dev/build.
When distPath.root is set to /, this leads to deletion attempts on the system root directory.
Why this is dangerous
Many users may confuse distPath.root with publicPath
Dev mode still performs output directory cleanup
There is currently no safeguard against critical filesystem paths
This behavior can easily affect experienced developers and is not an obvious misuse.
Suggested Fixes
One or more of the following safeguards would greatly improve safety:
Block /, C:, and other filesystem root paths explicitly
Ensure distPath.root must be inside the project directory by default
Require an explicit --force or dangerouslyAllowRootOutput flag
Add prominent documentation warnings
Environment
System:
OS: macOS 15.7
CPU: (8) arm64 Apple M3
Memory: 63.23 MB / 16.00 GB
Shell: 5.9 - /bin/zsh
Browsers:
Chrome: 143.0.7499.147
Safari: 18.6
npmPackages:
@rsbuild/core: ^1.3.6 => 1.3.16
@rsbuild/plugin-babel: ^1.0.6 => 1.0.6
@rsbuild/plugin-less: ^1.2.2 => 1.2.4
@rsbuild/plugin-react: ^1.2.0 => 1.3.0
Beta Was this translation helpful? Give feedback.
All reactions