Skip to content

Commit a419b00

Browse files
fix(install): refresh the workspace venv without stripping the developer's extras
Both installer paths -- scripts/install.sh and `studyloop install tools` (install_workspace_tools) -- ran a plain `uv sync --all-packages` before installing the tool venvs. That form removes every package the lock does not require for the requested extras, so a developer who had synced the semantic (or web, or content) extra into .venv lost it the moment they reinstalled the tools. Found live on the Mac Mini today: the tool reinstall silently removed sqlite-vec and onnxruntime from a .venv synced an hour earlier with --all-extras. It is also the mechanism behind the first report of this day: a .venv/bin/session-maint with no sqlite-vec, shadowing a correct ~/.local/bin/session-maint on PATH, printing "Semantic layer not installed" with a hint that reinstalled the wrong venv. Both call sites now pass --inexact ("do not remove extraneous packages"): the workspace is still brought up to date, nothing the developer added is taken away. Proven on a scratch uv workspace: an extra survives `uv sync --all-packages --inexact` and is removed by the plain form. Tests pin the flag at both sites (installers.py command list, and a contract test over install.sh's sync line).
1 parent 7f72744 commit a419b00

4 files changed

Lines changed: 34 additions & 4 deletions

File tree

‎packages/studyloop/src/studyloop/installers.py‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1337,7 +1337,13 @@ def install_workspace_tools(
13371337
installed: list[str] = []
13381338

13391339
if sync_workspace:
1340-
_run(["uv", "sync", "--all-packages"], cwd=repo_root)
1340+
# --inexact: refresh the workspace venv without REMOVING what the
1341+
# developer synced into it. A plain `uv sync --all-packages` strips
1342+
# every extra (semantic, web, content), which is how a developer's
1343+
# .venv/bin/session-maint lost sqlite-vec straight after an install
1344+
# and printed "Semantic layer not installed" for a tool venv that was
1345+
# already correct.
1346+
_run(["uv", "sync", "--all-packages", "--inexact"], cwd=repo_root)
13411347

13421348
packages_dir = repo_root / "packages"
13431349
# Pins every `uv tool install` below to the INVOKING interpreter's minor

‎packages/studyloop/tests/test_install_script_contract.py‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,3 +84,20 @@ def test_uv_tool_smoke_pins_the_interpreter_like_the_installer() -> None:
8484
text = (repo_root / "scripts/smoke-uv-tool-install.sh").read_text()
8585
assert ".python-version" in text
8686
assert text.count("--python") >= 2, "both uv tool install calls must pass --python"
87+
88+
89+
def test_install_script_workspace_sync_keeps_what_the_developer_synced() -> None:
90+
"""``scripts/install.sh`` syncs the workspace with ``--inexact`` for the same
91+
reason ``install_workspace_tools`` does: a plain ``uv sync --all-packages``
92+
removes every extra the developer had synced into ``.venv`` (semantic, web,
93+
content), and a ``.venv/bin/session-maint`` that just lost sqlite-vec is how
94+
one machine printed "Semantic layer not installed" straight after an install."""
95+
repo_root = Path(__file__).resolve().parents[3]
96+
script = (repo_root / "scripts" / "install.sh").read_text(encoding="utf-8")
97+
sync_lines = [
98+
line
99+
for line in script.splitlines()
100+
if "uv sync" in line and not line.lstrip().startswith("#")
101+
]
102+
assert sync_lines, "install.sh no longer syncs the workspace?"
103+
assert all("--inexact" in line for line in sync_lines), sync_lines

‎packages/studyloop/tests/test_installers_workspace_tools.py‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,12 @@ def test_install_workspace_tools_installs_expected_tool_commands(tmp_path: Path)
3636

3737
assert installed == ["agent-session-tools", "studyloop"]
3838
assert run.call_args_list == [
39-
call(["uv", "sync", "--all-packages"], cwd=repo_root),
39+
# --inexact: the installer refreshes the workspace venv but must not
40+
# REMOVE what the developer synced into it (the semantic/web/content
41+
# extras). A plain `uv sync --all-packages` strips every extra, which
42+
# is how a developer's .venv/bin/session-maint lost sqlite-vec and
43+
# printed "Semantic layer not installed" right after an install.
44+
call(["uv", "sync", "--all-packages", "--inexact"], cwd=repo_root),
4045
call(
4146
[
4247
"uv",
@@ -99,7 +104,7 @@ def test_install_workspace_tools_can_skip_sync_and_force(tmp_path: Path) -> None
99104

100105
assert installed == ["agent-session-tools", "studyloop"]
101106
commands = [args.args[0] for args in run.call_args_list]
102-
assert ["uv", "sync", "--all-packages"] not in commands
107+
assert not any(command[:2] == ["uv", "sync"] for command in commands)
103108
assert all("--force" not in command for command in commands)
104109
assert all(command[:5][:4] == ["uv", "tool", "install", "--python"] for command in commands)
105110
assert all(command[4] == _PY_VER for command in commands)

‎scripts/install.sh‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,9 @@ fi
162162

163163
if ! $TOOLS_ONLY; then
164164
step "Syncing workspace"
165-
(cd "$REPO_DIR" && uv sync --all-packages)
165+
# --inexact: do not strip extras the developer already synced into .venv
166+
# (see install_workspace_tools in packages/studyloop/src/studyloop/installers.py).
167+
(cd "$REPO_DIR" && uv sync --all-packages --inexact)
166168
info "Workspace synced"
167169
fi
168170

0 commit comments

Comments
 (0)