Skip to content

Commit 1af0539

Browse files
authored
fix: Add rclone installation checks for Windows bisync commands (#427)
1 parent cad7019 commit 1af0539

File tree

3 files changed

+188
-21
lines changed

3 files changed

+188
-21
lines changed

src/basic_memory/cli/commands/cloud/rclone_commands.py

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
from rich.console import Console
1818

19+
from basic_memory.cli.commands.cloud.rclone_installer import is_rclone_installed
1920
from basic_memory.utils import normalize_project_path
2021

2122
console = Console()
@@ -27,6 +28,21 @@ class RcloneError(Exception):
2728
pass
2829

2930

31+
def check_rclone_installed() -> None:
32+
"""Check if rclone is installed and raise helpful error if not.
33+
34+
Raises:
35+
RcloneError: If rclone is not installed with installation instructions
36+
"""
37+
if not is_rclone_installed():
38+
raise RcloneError(
39+
"rclone is not installed.\n\n"
40+
"Install rclone by running: bm cloud setup\n"
41+
"Or install manually from: https://rclone.org/downloads/\n\n"
42+
"Windows users: Ensure you have a package manager installed (winget, chocolatey, or scoop)"
43+
)
44+
45+
3046
@dataclass
3147
class SyncProject:
3248
"""Project configured for cloud sync.
@@ -124,8 +140,10 @@ def project_sync(
124140
True if sync succeeded, False otherwise
125141
126142
Raises:
127-
RcloneError: If project has no local_sync_path configured
143+
RcloneError: If project has no local_sync_path configured or rclone not installed
128144
"""
145+
check_rclone_installed()
146+
129147
if not project.local_sync_path:
130148
raise RcloneError(f"Project {project.name} has no local_sync_path configured")
131149

@@ -180,8 +198,10 @@ def project_bisync(
180198
True if bisync succeeded, False otherwise
181199
182200
Raises:
183-
RcloneError: If project has no local_sync_path or needs --resync
201+
RcloneError: If project has no local_sync_path, needs --resync, or rclone not installed
184202
"""
203+
check_rclone_installed()
204+
185205
if not project.local_sync_path:
186206
raise RcloneError(f"Project {project.name} has no local_sync_path configured")
187207

@@ -249,8 +269,10 @@ def project_check(
249269
True if files match, False if differences found
250270
251271
Raises:
252-
RcloneError: If project has no local_sync_path configured
272+
RcloneError: If project has no local_sync_path configured or rclone not installed
253273
"""
274+
check_rclone_installed()
275+
254276
if not project.local_sync_path:
255277
raise RcloneError(f"Project {project.name} has no local_sync_path configured")
256278

@@ -291,7 +313,10 @@ def project_ls(
291313
292314
Raises:
293315
subprocess.CalledProcessError: If rclone command fails
316+
RcloneError: If rclone is not installed
294317
"""
318+
check_rclone_installed()
319+
295320
remote_path = get_project_remote(project, bucket_name)
296321
if path:
297322
remote_path = f"{remote_path}/{path}"

src/basic_memory/cli/commands/cloud/rclone_installer.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,11 +151,25 @@ def install_rclone_windows() -> None:
151151
except RcloneInstallError:
152152
console.print("[yellow]scoop installation failed[/yellow]")
153153

154-
# No package manager available
155-
raise RcloneInstallError(
156-
"Could not install rclone automatically. Please install a package manager "
157-
"(winget, chocolatey, or scoop) or install rclone manually from https://rclone.org/downloads/"
154+
# No package manager available - provide detailed instructions
155+
error_msg = (
156+
"Could not install rclone automatically.\n\n"
157+
"Windows requires a package manager to install rclone. Options:\n\n"
158+
"1. Install winget (recommended, built into Windows 11):\n"
159+
" - Windows 11: Already installed\n"
160+
" - Windows 10: Install 'App Installer' from Microsoft Store\n"
161+
" - Then run: bm cloud setup\n\n"
162+
"2. Install chocolatey:\n"
163+
" - Visit: https://chocolatey.org/install\n"
164+
" - Then run: bm cloud setup\n\n"
165+
"3. Install scoop:\n"
166+
" - Visit: https://scoop.sh\n"
167+
" - Then run: bm cloud setup\n\n"
168+
"4. Manual installation:\n"
169+
" - Download from: https://rclone.org/downloads/\n"
170+
" - Extract and add to PATH\n"
158171
)
172+
raise RcloneInstallError(error_msg)
159173

160174

161175
def install_rclone(platform_override: Optional[str] = None) -> None:

0 commit comments

Comments
 (0)