HumanSignal/label-studio · error · RuntimeError
{path} {what} already exists. Use "--force" option to recrea
Error message
{path} {what} already exists. Use "--force" option to recreate it. What it means
already_exists_error is a helper that raises RuntimeError when a filesystem resource (project dir, storage dir) the CLI/setup tries to create already exists on disk. Label Studio refuses to clobber existing directories unless explicitly told with --force.
Source
Thrown at label_studio/io_storages/filesystem.py:82
self.data.pop(int(key), None)
self._save()
def remove_all(self, ids=None):
if ids is None:
self.data = {}
else:
[self.data.pop(i, None) for i in ids]
self._save()
def empty(self):
return len(self.data) == 0
def sync(self):
pass
def already_exists_error(what, path):
raise RuntimeError(
'{path} {what} already exists. Use "--force" option to recreate it.'.format(path=path, what=what)
)
class DirJSONsStorage(BaseStorage):
description = 'Directory with JSON task files'
def __init__(self, **kwargs):
super(DirJSONsStorage, self).__init__(**kwargs)
os.makedirs(self.path, exist_ok=True)
self.cache = {}
@property
def readable_path(self):
return self.path
def get(self, id):
if id in self.cache:View on GitHub (pinned to 0b49e9b539)
Solutions
- Pass the --force option to recreate/overwrite the existing path if its contents can be discarded
- Use a new unique path/name for the new storage or project
- Manually move/rename the existing directory before re-running
- If the directory is stale from a failed prior run, delete it first
Example fix
# before label-studio init ./myproject # second run: already exists # after label-studio init ./myproject --force
Defensive patterns
Strategy: try-catch
Validate before calling
import os
def path_is_free(path):
return not os.path.exists(path) Type guard
def is_new_dir(path):
import os
return os.path.isdir(path) is False Try / catch
try:
create_storage(path)
except RuntimeError as e:
if 'already exists' in str(e) and '--force' not in sys.argv:
logger.error('%s — rerun with --force or pick a new path', e) Prevention
- Check os.path.exists() before scripted creation
- Use unique, timestamped paths for automated runs
- Clean up partially created directories after failed runs
- Only use --force when the existing contents are disposable
When it happens
Trigger: Running the filesystem storage creation/setup command a second time against the same path, or a prior run partially created the directory, so the target {path} already exists on disk.
Common situations: Re-running a scripted initialization after a first run succeeded; switching data directories but reusing an old project name; Docker volume remounts leaving stale directories.
Related errors
- Absolute local path "{self.path}" does not exist
- Failed to read file {path}: {str(e)}
- token_exists
- Provide --project <id> or --organization <id>
- Project {project_id} not found
AI-assisted analysis of HumanSignal/label-studio@0b49e9b539 (2026-08-29).
Data as JSON: /api/errors/86cfef4b41715e5d.
Report an issue: GitHub.