Skip to content

Commit c06c411

Browse files
Fix macOS deps storage location to use Application Support
macOS App Translocation makes the app bundle read-only when launched from Downloads. Deps must be stored in ~/Library/Application Support/ instead of inside the app bundle. Updated both Flutter DependencyManager and Rust DependencyLocator to use ~/Library/Application Support/VapourBox/deps/ on macOS. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent b5db2e1 commit c06c411

2 files changed

Lines changed: 44 additions & 19 deletions

File tree

app/lib/services/dependency_manager.dart

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -187,12 +187,15 @@ class DependencyManager {
187187
// Fall back to production path (will trigger download)
188188
return prodDeps;
189189
} else if (Platform.isMacOS) {
190-
// Production: In .app bundle: Contents/Frameworks
191-
final contentsDir = path.dirname(path.dirname(appDir));
192-
final frameworksDir = path.join(contentsDir, 'Frameworks');
193-
194-
if (await Directory(frameworksDir).exists()) {
195-
return Directory(frameworksDir);
190+
// First check Application Support (where downloaded deps go)
191+
final home = Platform.environment['HOME'];
192+
if (home != null) {
193+
final appSupportDeps = Directory(path.join(
194+
home, 'Library', 'Application Support', 'VapourBox', 'deps', platformId
195+
));
196+
if (await appSupportDeps.exists()) {
197+
return appSupportDeps;
198+
}
196199
}
197200

198201
// Development: go up to project root and find deps/macos-arm64 or macos-x64
@@ -206,8 +209,11 @@ class DependencyManager {
206209
return Directory(await devDepsX64.resolveSymbolicLinks());
207210
}
208211

209-
// Fall back to production-style path (will trigger download)
210-
return Directory(path.join(appDir, 'deps', platformId));
212+
// Fall back to Application Support (will trigger download)
213+
final home2 = Platform.environment['HOME'] ?? '/tmp';
214+
return Directory(path.join(
215+
home2, 'Library', 'Application Support', 'VapourBox', 'deps', platformId
216+
));
211217
}
212218

213219
throw UnsupportedError('Unsupported platform');

worker/src/dependency_locator.rs

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,25 @@ impl DependencyLocator {
2929
Ok(Self { base_path, platform })
3030
}
3131

32-
/// Find the deps directory by searching upward from the executable.
32+
/// Find the deps directory by searching various locations.
3333
fn find_deps_directory(exe_path: &Path) -> Result<PathBuf> {
34+
// On macOS, first check Application Support (where downloaded deps go)
35+
#[cfg(target_os = "macos")]
36+
{
37+
if let Some(home) = env::var_os("HOME") {
38+
let app_support_deps = PathBuf::from(home)
39+
.join("Library")
40+
.join("Application Support")
41+
.join("VapourBox")
42+
.join("deps");
43+
if app_support_deps.join("macos-arm64").exists()
44+
|| app_support_deps.join("macos-x64").exists() {
45+
return Ok(app_support_deps);
46+
}
47+
}
48+
}
49+
50+
// Search upward from executable
3451
let mut current = exe_path.parent();
3552

3653
while let Some(dir) = current {
@@ -47,19 +64,21 @@ impl DependencyLocator {
4764
}
4865
}
4966

50-
// On macOS, check in Contents/ for app bundle
51-
#[cfg(target_os = "macos")]
52-
{
53-
let contents_deps = dir.join("Contents").join("deps");
54-
if contents_deps.exists() {
55-
return Ok(contents_deps);
56-
}
57-
}
58-
5967
current = dir.parent();
6068
}
6169

62-
// Fallback to relative path
70+
// Fallback: Application Support on macOS, relative path otherwise
71+
#[cfg(target_os = "macos")]
72+
{
73+
if let Some(home) = env::var_os("HOME") {
74+
return Ok(PathBuf::from(home)
75+
.join("Library")
76+
.join("Application Support")
77+
.join("VapourBox")
78+
.join("deps"));
79+
}
80+
}
81+
6382
Ok(PathBuf::from("deps"))
6483
}
6584

0 commit comments

Comments
 (0)