Skip to content

Commit 7c21aca

Browse files
authored
docs: wsl setup and expo router skip docs (#130)
1 parent bf54c6a commit 7c21aca

2 files changed

Lines changed: 97 additions & 112 deletions

File tree

.cursor/rules/wsl-unison-setup.mdc

Lines changed: 47 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,45 +10,73 @@ This project uses a dual-filesystem setup for development:
1010
- **Linux/WSL location** (primary development location):
1111
`/home/william/not_connected_to_windows/CalendarNotification`
1212

13-
- **Windows location** (accessible via WSL at `/mnt/c`):
14-
`/mnt/c/Users/william/unison-with-dropbox-symlinked-to-linux/CalendarNotification`
13+
- **Windows location** (for Android builds - use short path!):
14+
- **Short path**: `C:\dev\CN` or `/mnt/c/dev/CN` — BUILD FROM HERE
15+
- **Junction for backwards compat**: `C:\Users\william\unison-with-dropbox-symlinked-to-linux\CalendarNotification` → `C:\dev\CN`
1516

1617
## Sync Strategy
1718

18-
- **Unison** is used to sync files between the Linux and Windows filesystems
19-
- Most files are synced, but **`node_modules` is NOT synced** due to size
20-
- `node_modules` is installed separately on each side of the sync
19+
- **Unison** syncs files between Linux and Windows using profile `non_windows_cnplus.prf`
20+
- Syncs directly: `/mnt/c/dev/CN` ↔ `/home/william/not_connected_to_windows/CalendarNotification`
21+
- **`node_modules` is NOT synced** — install separately on each side
22+
- Run with: `unison non_windows_cnplus`
23+
24+
### ⚠️ CRITICAL: Never sync through the junction!
25+
26+
Unison must point to the **real short path** (`/mnt/c/dev/CN`), NOT the junction path. If you sync through the junction, Unison will replace your Linux directory with a symlink to `/mnt/c/...`, completely defeating the fast-filesystem setup and potentially destroying data.
2127

2228
## Implications
2329

2430
- When referencing paths, prefer the Linux location (`/home/william/not_connected_to_windows/CalendarNotification`)
25-
- If `node_modules` appears missing or incomplete, it may need to be installed separately on that side
31+
- If `node_modules` appears missing or incomplete, run `npm install` on that side
2632
- Git operations and file system operations are faster on the Linux side
27-
- Windows Android Studio builds must use the Windows-synced location
28-
- File system permission issues may occur when accessing Windows files from Linux and vice versus (hence keeping them separate)
33+
- **Windows Android builds**: Use `C:\dev\CN\android` (short path) to avoid 260-char path limit
34+
- File system permission issues may occur when accessing Windows files from Linux and vice versa (hence keeping them separate)
2935

3036
## Windows Long Path Issue (New Architecture)
3137

3238
React Native's New Architecture codegen creates very long file paths that can exceed Windows' 260-character limit. The long project path (`unison-with-dropbox-symlinked-to-linux`) makes this worse.
3339

34-
**Workaround**: Use `subst` to create a short drive letter alias:
40+
### What Doesn't Work
3541

36-
```cmd
37-
subst X: "C:\Users\william\unison-with-dropbox-symlinked-to-linux\CalendarNotification"
38-
```
42+
- **`subst` drive letter**: Node/Gradle can't properly resolve modules through virtual drives
43+
- **Junction pointing TO long path**: Build tools "see through" junctions and resolve to the real (long) path
44+
45+
### Solution: Short Path + Junction (December 2024)
46+
47+
Real files live at a short Windows path. Junction at old path provides backwards compatibility:
3948

40-
Then build from `X:\android` instead. This shortens paths significantly and avoids the ninja build errors like:
4149
```
42-
ninja: error: Stat(...): Filename longer than 260 characters
50+
Real files: C:\dev\CN ←── BUILD FROM HERE + UNISON SYNCS HERE
51+
52+
┌─────────┴─────────┐
53+
│ │
54+
Junction from old path Direct access
55+
(backwards compat only - DO NOT sync through this!)
4356
```
4457

45-
**Important**: The `subst` drive is only visible at the same elevation level where it was created. If you run `subst` from a non-Admin command prompt, you must use non-Admin Explorer/terminals to see the `X:` drive. Running as Admin won't see it (and vice versa).
58+
**Setup (one-time)**:
59+
```powershell
60+
# Move files to short path
61+
Move-Item "C:\Users\william\unison-with-dropbox-symlinked-to-linux\CalendarNotification" "C:\dev\CN"
4662

47-
To remove the substitution later:
48-
```cmd
49-
subst X: /d
63+
# Create junction at old location → short path
64+
cmd /c mklink /J "C:\Users\william\unison-with-dropbox-symlinked-to-linux\CalendarNotification" "C:\dev\CN"
5065
```
5166

67+
**Build from short path**:
68+
```powershell
69+
cd C:\dev\CN\android
70+
.\gradlew assembleDebug
71+
```
72+
73+
### Separate Issue: React Native 0.81.5 C++ Bug
74+
75+
After fixing paths, you may hit `std::format` compilation errors — this is an RN/NDK bug, not a path issue.
76+
**Quick fix**: Set `newArchEnabled=false` in `android/gradle.properties`
77+
78+
See full docs: `linuxshared_folder_usage_docs/windows_short_path_for_android_builds.md`
79+
5280
## NativeWind ESM Issue (Metro on Windows)
5381

5482
NativeWind v4 has a known issue where Metro cannot load the config on Windows due to ESM path handling. This causes errors like:
@@ -66,7 +94,7 @@ Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only URLs with a scheme in: file, data,
6694

6795
2. **Build on Windows** (uses pre-built bundle):
6896
```powershell
69-
cd X:\android
97+
cd C:\dev\CN\android
7098
.\gradlew assembleDebug
7199
```
72100

Lines changed: 50 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -1,102 +1,59 @@
11
# Expo Router Migration
22

3-
## Status: Blocked - Awaiting React Native Upgrade
3+
## Status: Evaluated & Intentionally Deferred
44

5-
## Summary
5+
## Decision (December 2025)
66

7-
Attempted migration to Expo Router v3 for file-based routing but encountered compatibility issues with the current bare React Native 0.74.5 setup.
7+
After upgrading to React Native 0.81.5 and Expo SDK 54 (which removed the original blockers), we re-evaluated Expo Router and decided **not to migrate**.
88

9-
## Current Setup (Working)
9+
### Why We're Skipping It
1010

11-
- **React Native**: 0.74.5
12-
- **Expo SDK**: 51
11+
| Factor | Assessment |
12+
|--------|------------|
13+
| **App complexity** | Only 3 screens (Home, Settings, SyncDebug) |
14+
| **Navigation needs** | Simple stack - no nested routes, tabs, or drawers |
15+
| **Deep linking** | Not needed for a sync settings UI |
16+
| **Web support** | Android-only app |
17+
| **Current solution** | React Navigation works perfectly fine |
18+
19+
### Cost vs Benefit
20+
21+
**Costs of migrating:**
22+
- Additional dependencies (`expo-router`, `expo-linking`, `expo-constants`, `@expo/metro-runtime`)
23+
- More complex Metro/Babel configuration
24+
- Migration effort (~2-4 hours)
25+
- Previous attempt had `require.context` issues in bare RN
26+
27+
**Benefits:**
28+
- File-based routing (marginal - we only have 3 screens)
29+
- Automatic deep links (not needed)
30+
- Slightly less boilerplate (trade ~50 lines in `index.tsx` for `_layout.tsx`)
31+
32+
**Verdict:** Over-engineering for a 3-screen settings UI.
33+
34+
## Current Setup (Working Well)
35+
36+
- **React Native**: 0.81.5
37+
- **Expo SDK**: 54
1338
- **Navigation**: React Navigation (`@react-navigation/native-stack`)
14-
- **UI Components**: Gluestack UI v1
15-
- **Styling**: NativeWind v2 (Tailwind for RN)
39+
- **UI Components**: Gluestack UI v2
40+
- **Styling**: NativeWind v4
1641
- **Entry Point**: `index.tsx` with explicit screen imports
42+
- **Screens**: `app/index.tsx`, `app/settings.tsx`, `app/sync-debug.tsx`
43+
44+
## When to Reconsider
45+
46+
Expo Router would make sense if the app grows to include:
47+
- 10+ screens with complex navigation flows
48+
- Nested navigators (tabs within stacks, drawers, etc.)
49+
- Web support requirements
50+
- Deep linking for sharing specific screens
51+
52+
## Historical Context
53+
54+
Originally blocked on RN 0.74.5 / Expo 51 due to:
55+
- `require.context` failures in bare RN
56+
- Dependency version conflicts with expo-module-gradle-plugin
57+
- NativeWind v4 / react-native-worklets incompatibilities
1758

18-
## Target Versions for Original Goals
19-
20-
| Package | Current | Target | Why |
21-
|---------|---------|--------|-----|
22-
| **React Native** | 0.74.5 | **0.76.x** | New Architecture required for worklets |
23-
| **Expo SDK** | 51 | **52** | Expo Router v4 + updated gradle plugins |
24-
| **Expo Router** | ❌ removed | **~4.x** | Better bare RN support in v4 |
25-
| **NativeWind** | 2.x | **4.x** | Requires RN 0.76+ for worklets |
26-
| **react-native-svg** | 15.2.0 (broken) | **15.x** | Compatible with RN 0.76+ |
27-
28-
### Upgrade Helper
29-
30-
Use this link to see all required changes:
31-
https://react-native-community.github.io/upgrade-helper/?from=0.74.5&to=0.76.0
32-
33-
## What We Tried
34-
35-
### Expo Router v3
36-
- File-based routing in `app/` directory
37-
- `require.context` for auto-discovery of routes
38-
- `ExpoRoot` component as entry point
39-
40-
### NativeWind v4
41-
- Direct Tailwind CSS integration
42-
- `withNativeWind` Metro wrapper
43-
44-
## Issues Encountered
45-
46-
### 1. `require.context` Failure
47-
Expo Router uses `require.context('./app')` to auto-discover route files. This relies on Metro's experimental features that didn't work in this bare RN setup - `ExpoRoot` couldn't find any routes, resulting in blank screens.
48-
49-
### 2. Dependency Version Conflicts
50-
- `expo-router@~3.5.x``expo-linking@~6.3.x` → expected newer gradle plugin infrastructure
51-
- `expo-module-gradle-plugin` version mismatches between Expo SDK 51 packages
52-
- `react-native-svg@15.x` incompatible with RN 0.74.5 (downgraded to 13.x)
53-
54-
### 3. NativeWind v4 Incompatibilities
55-
- Required `tailwindcss@3.x` (v4 not supported)
56-
- `react-native-worklets` incompatible with RN 0.74.5
57-
- `lightningcss` platform-specific binaries failed in Windows/WSL environment
58-
59-
### 4. Windows/WSL Environment
60-
- Separate `node_modules` on Windows and Linux due to file sync
61-
- Native binary dependencies (like `lightningcss`) need platform-specific builds
62-
63-
## Migration Checklist
64-
65-
### Prerequisites
66-
- [ ] Upgrade to React Native 0.76.x
67-
- [ ] Upgrade to Expo SDK 52
68-
- [ ] Verify New Architecture is enabled
69-
- [ ] Clean rebuild on Windows (`.\gradlew clean`)
70-
71-
### Migration Steps
72-
1. [ ] Add `expo-router@~4.x` and `expo-linking`
73-
2. [ ] Update `package.json` main to `"expo-router/entry"`
74-
3. [ ] Update `app.json` with expo-router plugin
75-
4. [ ] Recreate `app/_layout.tsx` with providers
76-
5. [ ] Update screen files to use `useRouter()` instead of `useNavigation()`
77-
6. [ ] Add NativeWind v4 + tailwindcss v3
78-
7. [ ] Update `metro.config.js` with `withNativeWind`
79-
8. [ ] Test on Windows/WSL environment
80-
9. [ ] Remove React Navigation packages
81-
82-
## Files to Reuse
83-
84-
These files were created and can be adapted:
85-
86-
| File | Status | Notes |
87-
|------|--------|-------|
88-
| `app/index.tsx` | ✅ Working | Update imports for expo-router |
89-
| `app/settings.tsx` | ✅ Working | Update imports for expo-router |
90-
| `app/sync-debug.tsx` | ✅ Working | No navigation changes needed |
91-
| `lib/components/ui/` | ✅ Working | Keep as-is |
92-
| `lib/theme/colors.ts` | ✅ Working | Keep as-is |
93-
| `lib/navigation/types.ts` | ⚠️ Remove | Not needed with expo-router |
94-
| `app/_layout.tsx` | ❌ Deleted | Recreate with expo-router imports |
95-
96-
## References
97-
98-
- [Expo Router Docs](https://docs.expo.dev/router/introduction/)
99-
- [NativeWind v4 Docs](https://www.nativewind.dev/)
100-
- [React Native Upgrade Helper](https://react-native-community.github.io/upgrade-helper/?from=0.74.5&to=0.76.0)
101-
- [Expo SDK 52 Release Notes](https://expo.dev/changelog)
102-
- [React Native 0.76 Release](https://reactnative.dev/blog)
59+
These blockers were resolved by upgrading to RN 0.81.5 / Expo 54, but the migration was deemed unnecessary for the app's scope.

0 commit comments

Comments
 (0)