Skip to content

armgit / raea

Public Imported from GitHub
0

Render Anything Engine: tell your AI what to make. Videos, motion graphics, 3D and games as React and TypeScript, rendered on your own GPU. Rust + Bevy, macOS, Linux and Windows.

Git on a PC without it: found or fetched once, as the app's host does (#169)

shinyobjectzb60d90147352
diff --git a/Cargo.lock b/Cargo.lock
index 7a25bb1b..a475148c 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -14051,6 +14051,7 @@ dependencies = [
"raea-app-registry",
"raea-core-brief",
"raea-core-facts",
+ "raea-io-assets",
"raea-io-home",
"serde_json",
]
diff --git a/NOTICE b/NOTICE
index 2f9f860e..c678e6f9 100644
--- a/NOTICE
+++ b/NOTICE
@@ -30,6 +30,10 @@ paths for Windows in runtime/bundle). Its bin\ also carries, each with its licen
uv (uv.exe; Astral, MIT OR Apache-2.0).
The Windows app adds Git for Windows with Git LFS (dugite-native; GPLv2 and its parts' licences, in git\), which raea
runs as a separate program; its complete corresponding source is published as the release tools-git-<tag>-sources.
+raea.exe, on a PC with no Git, fetches the same build once into its tools cache (io/assets git()).
+The Windows and Linux builds' JavaScript engine, QuickJS (rquickjs, MIT), carries FormatJS's Intl polyfills (MIT,
+Copyright FormatJS) and the Unicode CLDR locale data they're made with (Unicode-3.0), packed in
+runtime/jsengine/js/intl.pack; both licences are in runtime/jsengine/js/intl/LICENSE-FormatJS.md and in the pack.
The native target (engine/rune, docs/targets.feature) builds on Rune (https://github.com/anomalyco/rune, Copyright
2026 Anomaly, MIT; LICENSES/rune-0.0.1/repository-LICENSE): rune, rune-kit and their crates, by a pinned rev.
diff --git a/apps/workspace/Cargo.toml b/apps/workspace/Cargo.toml
index bcb95114..e61be5e6 100644
--- a/apps/workspace/Cargo.toml
+++ b/apps/workspace/Cargo.toml
@@ -11,6 +11,8 @@ dunce = "1"
# the controller schema (core/brief controller.rs): a controller file is checked and normalized against it
raea-core-brief = { path = "../../core/brief" }
raea-io-home = { path = "../../io/home" }
+# git, which a workspace is: the PATH's, else on Windows the app's or raea's own (raea_io_assets::git)
+raea-io-assets = { path = "../../io/assets" }
serde_json = "1"
# a project's compositions, components and controllers read from their source (docs/projects.feature PJ8)
raea-app-registry = { path = "registry" }
diff --git a/apps/workspace/src/controllers.rs b/apps/workspace/src/controllers.rs
index f57f299e..6e7f6abf 100644
--- a/apps/workspace/src/controllers.rs
+++ b/apps/workspace/src/controllers.rs
@@ -62,10 +62,10 @@ pub(crate) fn overrides(from: &Path) -> Vec<(String, String)> {
}
fn commit(ws: &Path, paths: &[&Path], what: &str, by: &str) -> R<()> {
- let mut add = Command::new("git");
+ let mut add = Command::new(workspace::program());
add.arg("-C").arg(ws).args(["add", "-A", "--"]).args(paths);
- add.status().map_err(|e| format!("git: {e}"))?;
- let ok = workspace::git_cmd().arg("-C").arg(ws).args(["-c", &format!("user.name={by}"), "commit", "-q", "-m", &format!("{by}: {what}"), "--"]).args(paths).status().map_err(|e| format!("git: {e}"))?;
+ add.status().map_err(workspace::missing)?;
+ let ok = workspace::git_cmd().arg("-C").arg(ws).args(["-c", &format!("user.name={by}"), "commit", "-q", "-m", &format!("{by}: {what}"), "--"]).args(paths).status().map_err(workspace::missing)?;
if ok.success() { Ok(()) } else { Err(format!("couldn't commit {what}")) }
}
diff --git a/apps/workspace/src/workspace.rs b/apps/workspace/src/workspace.rs
index 80d1b76d..8d36c5cb 100644
--- a/apps/workspace/src/workspace.rs
+++ b/apps/workspace/src/workspace.rs
@@ -13,7 +13,7 @@ const USAGE: &str = "usage: raea workspace [--json] | raea workspace init [NAME]
/// full name (a CI runner's, a container's) has no name either ("empty ident name ... not allowed"), and git has no
/// fallback below user.name to give it, so when no user.name is set the author and committer are named for the account.
pub(crate) fn git_cmd() -> Command {
- let mut c = Command::new("git");
+ let mut c = Command::new(program());
let user = std::env::var("USER").unwrap_or_else(|_| "raea".into());
if std::env::var_os("EMAIL").is_none() {
c.env("EMAIL", format!("{user}@raea.local"));
@@ -24,14 +24,33 @@ pub(crate) fn git_cmd() -> Command {
c
}
+/// The git raea runs (raea_io_assets::git: the PATH's, else on Windows the app's or raea's own, fetched once), found
+/// once a process; "git" when there's none, its spawn then failing as `missing` says.
+fn found() -> &'static Result<std::path::PathBuf, String> {
+ static GIT: std::sync::OnceLock<Result<std::path::PathBuf, String>> = std::sync::OnceLock::new();
+ GIT.get_or_init(raea_io_assets::git)
+}
+
+pub(crate) fn program() -> std::path::PathBuf {
+ found().clone().unwrap_or_else(|_| "git".into())
+}
+
+/// A git that didn't start, said as why: there's no git here (and how to get one), or what the system said
+pub(crate) fn missing(e: std::io::Error) -> String {
+ match found() {
+ Err(why) if e.kind() == std::io::ErrorKind::NotFound => why.clone(),
+ _ => format!("git: {e}"),
+ }
+}
+
/// Whether git has a user.name to sign commits with (asked once a process).
fn has_name() -> bool {
static HAS: std::sync::OnceLock<bool> = std::sync::OnceLock::new();
- *HAS.get_or_init(|| Command::new("git").args(["config", "--get", "user.name"]).output().is_ok_and(|o| o.status.success() && !o.stdout.trim_ascii().is_empty()))
+ *HAS.get_or_init(|| Command::new(program()).args(["config", "--get", "user.name"]).output().is_ok_and(|o| o.status.success() && !o.stdout.trim_ascii().is_empty()))
}
pub(crate) fn git(dir: &Path, args: &[&str]) -> R<String> {
- let out = git_cmd().arg("-C").arg(dir).args(args).output().map_err(|e| format!("git: {e}"))?;
+ let out = git_cmd().arg("-C").arg(dir).args(args).output().map_err(missing)?;
if !out.status.success() {
return Err(format!("git {}: {}", args.join(" "), String::from_utf8_lossy(&out.stderr).trim()));
}
@@ -40,12 +59,12 @@ pub(crate) fn git(dir: &Path, args: &[&str]) -> R<String> {
/// `git config` on a file (or the global config when `file` is None), its output trimmed; Err when git says no.
pub(crate) fn config(file: Option<&Path>, args: &[&str]) -> R<String> {
- let mut c = Command::new("git");
+ let mut c = Command::new(program());
c.arg("config");
if let Some(f) = file {
c.arg("-f").arg(f);
}
- let out = c.args(args).output().map_err(|e| format!("git: {e}"))?;
+ let out = c.args(args).output().map_err(missing)?;
if !out.status.success() {
return Err(format!("git config {}: {}", args.join(" "), String::from_utf8_lossy(&out.stderr).trim()));
}
@@ -111,7 +130,8 @@ pub fn default_root(home: &Path) -> PathBuf {
if home.join("Library/Mobile Documents/com~apple~CloudDocs/Documents").is_dir() {
home.join("raea")
} else {
- home.join("Documents/raea")
+ // a folder at a time: on Windows "Documents/raea" printed as C:\Users\you\Documents/raea\...
+ home.join("Documents").join("raea")
}
}
diff --git a/io/assets/src/lib.rs b/io/assets/src/lib.rs
index 80022625..7dd3f151 100644
--- a/io/assets/src/lib.rs
+++ b/io/assets/src/lib.rs
@@ -25,7 +25,7 @@ pub use splat::{ensure_splat, splat_dir, splat_params};
mod local;
use local::*;
mod setup;
-pub use setup::{ffmpeg_tool, run_setup, setup_how, uv, venv_python};
+pub use setup::{ffmpeg_tool, git, run_setup, setup_how, uv, venv_python};
#[cfg(test)]
mod tests;
diff --git a/io/assets/src/setup.rs b/io/assets/src/setup.rs
index d2ae3756..5a13fe21 100644
--- a/io/assets/src/setup.rs
+++ b/io/assets/src/setup.rs
@@ -124,6 +124,62 @@ pub fn uv() -> Result<PathBuf, String> {
settle(&part, &dir, &bin, fetched, "uv")
}
+/// The Git for Windows raea fetches where there's none (the app's host, apps/app host/tools.ts WIN_GIT, fetches the same
+/// into the same folder, so either finds the other's): dugite-native's portable build with git-lfs, GitHub Desktop's
+const WIN_GIT_URL: &str = "https://github.com/desktop/dugite-native/releases/download/v2.56.0-2/dugite-native-v2.56.0-a44aeca-windows-x64.tar.gz";
+const WIN_GIT_DIR: &str = "git-v2.56.0-2-windows-x64";
+const WIN_GIT_SUM: &str = "f1e17876337d7be143e5d51976da36643d65528125cfbc14d57f171de0fd5f14";
+
+/// git, which a workspace is (raea workspace, project, controller): $RAEA_GIT, else the one on the PATH. On Windows,
+/// where Git is rarely installed, then the raea app's (its installer puts Git in its folder, which Settings > Apps
+/// keeps as InstallLocation), a Git for Windows that isn't on the PATH, and raea's own in $RAEA_TOOLS_CACHE (else
+/// ~/.cache/raea-tools), fetched there the first time (47 MB). Until 0.1.8 raea.exe took git from the PATH only, and on
+/// a PC with only the app's every workspace command failed with "git: program not found" (#169).
+pub fn git() -> Result<PathBuf, String> {
+ if let Some(p) = std::env::var_os("RAEA_GIT").map(PathBuf::from).filter(|p| p.is_file()) {
+ return Ok(p);
+ }
+ if let Some(p) = on_path("git") {
+ return Ok(p);
+ }
+ if !cfg!(windows) {
+ let how = if cfg!(target_os = "macos") { "xcode-select --install" } else { "apt install git, or dnf install git" };
+ return Err(format!("raea's workspaces are git repos, and git isn't installed: {how}"));
+ }
+ let cache = raea_io_home::env_path("RAEA_TOOLS_CACHE", ".cache/raea-tools").join(WIN_GIT_DIR);
+ let bin = cache.join("cmd").join("git.exe");
+ if let Some(p) = windows_gits().into_iter().chain([bin.clone()]).find(|p| p.is_file()) {
+ return Ok(p);
+ }
+ static FETCHING: std::sync::Mutex<()> = std::sync::Mutex::new(());
+ let _one = FETCHING.lock().unwrap_or_else(|e| e.into_inner());
+ if bin.is_file() {
+ return Ok(bin);
+ }
+ raea_io_home::offline("fetching Git for Windows: raea's workspaces are git repos")?;
+ eprintln!("raea: a workspace is a git repo, and this PC has no Git; fetching raea's own (Git for Windows, once, 47 MB) into {}", cache.display());
+ let part = cache.with_file_name(format!("{WIN_GIT_DIR}.part{}", std::process::id()));
+ let fetched = fetch_archive(&part, WIN_GIT_URL, "git.tar.gz", WIN_GIT_SUM, false, &[]);
+ // it runs before it's taken, as the app's host checks it
+ let runs = |p: &Path| std::process::Command::new(p).arg("--version").output().is_ok_and(|o| o.status.success());
+ let fetched = fetched.and_then(|()| if runs(&part.join("cmd").join("git.exe")) { Ok(()) } else { Err("the Git raea fetched doesn't run".into()) });
+ settle(&part, &cache, &bin, fetched, "Git for Windows")
+}
+
+/// The gits a Windows PC may have off its PATH: the raea app's (its install folder's git\cmd), else in the folder its
+/// installer uses by default, and Git for Windows' own for everyone and for the one account.
+fn windows_gits() -> Vec<PathBuf> {
+ let key = r"HKCU\Software\Microsoft\Windows\CurrentVersion\Uninstall\raea";
+ let reg = std::process::Command::new("reg").args(["query", key, "/v", "InstallLocation"]).output().ok();
+ let app = reg.and_then(|o| String::from_utf8_lossy(&o.stdout).lines().find_map(|l| l.trim().strip_prefix("InstallLocation").map(|v| v.trim().trim_start_matches("REG_EXPAND_SZ").trim_start_matches("REG_SZ").trim().to_string())));
+ let env = |k: &str| std::env::var_os(k).map(PathBuf::from);
+ let mut at: Vec<PathBuf> = app.filter(|d| !d.is_empty()).map(|d| PathBuf::from(d).join("git")).into_iter().collect();
+ at.extend(env("LOCALAPPDATA").map(|d| d.join("Programs").join("raea").join("git")));
+ at.extend(env("ProgramFiles").map(|d| d.join("Git")));
+ at.extend(env("LOCALAPPDATA").map(|d| d.join("Programs").join("Git")));
+ at.into_iter().map(|d| d.join("cmd").join("git.exe")).collect()
+}
+
/// A fetch's end: its `part` folder moved in as `dir` when it's whole and nothing got there first, the part removed,
/// and, once the tool is in place, the parts stopped fetches left beside it swept (`NAME.part<pid>`, from a Ctrl+C or
/// a killed process: FFmpeg's held a 114 MB zip, and each run made a new one). A part another process is still