Derive the env from already-resolved roots. Falls back to home-derived Windows AppData roots when those env vars are unset, so a Desktop user is never misreported as having no OpenCode install just because %APPDATA% / %LOCALAPPDATA% are absent in this process environment. Kept in lockstep with the CLI's opencode-detect.ts fallbacks.
(
home: Option<PathBuf>,
appdata: Option<PathBuf>,
localappdata: Option<PathBuf>,
xdg_config_home: Option<PathBuf>,
xdg_data_home: Option<PathBuf>,
)
| 603 | /// %LOCALAPPDATA% are absent in this process environment. Kept in lockstep |
| 604 | /// with the CLI's opencode-detect.ts fallbacks. |
| 605 | fn resolve( |
| 606 | home: Option<PathBuf>, |
| 607 | appdata: Option<PathBuf>, |
| 608 | localappdata: Option<PathBuf>, |
| 609 | xdg_config_home: Option<PathBuf>, |
| 610 | xdg_data_home: Option<PathBuf>, |
| 611 | ) -> Self { |
| 612 | let appdata = appdata.or_else(|| home.as_ref().map(|h| h.join("AppData").join("Roaming"))); |
| 613 | let localappdata = |
| 614 | localappdata.or_else(|| home.as_ref().map(|h| h.join("AppData").join("Local"))); |
| 615 | Self { |
| 616 | home, |
| 617 | appdata, |
| 618 | localappdata, |
| 619 | xdg_config_home, |
| 620 | xdg_data_home, |
| 621 | mac_system_applications: PathBuf::from("/Applications"), |
| 622 | } |
| 623 | } |
| 624 | } |
| 625 | |
| 626 | fn env_path(name: &str) -> Option<PathBuf> { |
no outgoing calls