Skip to content

Cannot create new model in SQLMesh Browser UI if the project is a symlinked directory #5860

Description

@p-j-smith

Hi, thanks for making SQLMesh!

I'm running into a issue with creating new models when launching the UI if the project is a symlinked directory. There are a couple of problems:

  • files created in the UI are not picked up unless the browser is refreshed
  • new models are not picked up even if the browser is refreshed
  • changes to models are not picked up unless the browser is refreshed

Making a change to an existing model then refreshing the browser will enable the UI to pick up new models added.

To reproduce

# Create a SLQMesh project
rm -rf ~/sqlmesh-repro
mkdir -p ~/sqlmesh-repro/real
cd ~/sqlmesh-repro/real
uv venv --python 3.13
source .venv/bin/activate
uv pip install "sqlmesh[web]"
sqlmesh init duckdb

# Symlink to another directory and launch the UI
ln -s ~/sqlmesh-repro/real ~/sqlmesh-repro/linked
sqlmesh -p ~/sqlmesh-repro/linked ui

Then try to create a new model in the UI. It will only be picked up if an existing model is modified and the browser is then refreshed.

Cause

I think part of the problem is in web/server/watcher.py. The watcher watches the project at the path you launched with (i.e. the symlinked path) so the change events coming from watchfiles.awatch carry symlinked paths. But the list of model directories it checks each event against is built with .resolve(), which expands the symlink back to the real location:

paths = [
(settings.project_path / c.AUDITS).resolve(),
(settings.project_path / c.MACROS).resolve(),
(settings.project_path / c.MODELS).resolve(),
(settings.project_path / c.METRICS).resolve(),
(settings.project_path / c.SEEDS).resolve(),
]

This means the following check is always False for symlinked files:

in_paths = any(is_relative_to(path, p) for p in paths)

And so changes are not picked up by the watcher. I'm not sure why refreshing the browser would make a difference, nor why modifying an existing model is needed for new models to be picked up?

I appreciate the browser is deprecated, but I'm finding it quite useful for now, and I'm happy to make a PR to fix this.


Environment:

sqlmesh: 0.235.4
python: 3.13
os: macOS (Darwin 24.5.0, x86_64)


Here's a video showing the broken behaviour:

sqlmesh-ui-new-model-with-symlinked-project.mov

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions