mirror of
https://gitlab.com/vyla-entertainment/home.git
synced 2026-11-13 13:47:21 -05:00
fixed node program not found for C:\Users\sai\AppData\Local\Vyla Home\_up_\main.js
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "vyla-home",
|
||||
"version": "1.0.2",
|
||||
"version": "1.0.3",
|
||||
"description": "Vyla Home Desktop App Launcher",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
|
||||
@@ -59,11 +59,13 @@ class ServiceManager {
|
||||
|
||||
this.logToFile(name, `--- Starting ${name} in ${serviceDir} ---`);
|
||||
|
||||
const child = spawn('node', [scriptPath], {
|
||||
const nodeExecutable = process.env.NODE_EXE || 'node';
|
||||
|
||||
const child = spawn(nodeExecutable, [scriptPath], {
|
||||
cwd: serviceDir,
|
||||
env,
|
||||
stdio: ['ignore', 'pipe', 'pipe'],
|
||||
shell: process.platform === 'win32'
|
||||
shell: false
|
||||
});
|
||||
|
||||
this.processes[name] = {
|
||||
|
||||
2
src-tauri/Cargo.lock
generated
2
src-tauri/Cargo.lock
generated
@@ -4222,7 +4222,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "vyla-home"
|
||||
version = "1.0.2"
|
||||
version = "1.0.3"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"serde_json",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "vyla-home"
|
||||
version = "1.0.2"
|
||||
version = "1.0.3"
|
||||
description = "Vyla Home Desktop App Launcher"
|
||||
edition = "2021"
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@ struct BackendMessage {
|
||||
data: serde_json::Value,
|
||||
}
|
||||
|
||||
// Helper to remove the \\?\ prefix that Node.js chokes on
|
||||
fn clean_path(path: &std::path::Path) -> String {
|
||||
let s = path.to_string_lossy().to_string();
|
||||
if s.starts_with("\\\\?\\") {
|
||||
@@ -33,6 +32,72 @@ fn clean_path(path: &std::path::Path) -> String {
|
||||
}
|
||||
}
|
||||
|
||||
fn find_node_binary(app: &tauri::App) -> Option<String> {
|
||||
if let Ok(resource_dir) = app.path().resource_dir() {
|
||||
let candidates = [
|
||||
resource_dir.join("node.exe"),
|
||||
resource_dir.join("bin").join("node.exe"),
|
||||
resource_dir.join("_up_").join("node.exe"),
|
||||
];
|
||||
for candidate in candidates {
|
||||
if candidate.exists() {
|
||||
return Some(clean_path(&candidate));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if let Ok(path_var) = std::env::var("PATH") {
|
||||
for p in std::env::split_paths(&path_var) {
|
||||
let candidate = p.join("node.exe");
|
||||
if candidate.exists() {
|
||||
return Some(clean_path(&candidate));
|
||||
}
|
||||
#[cfg(not(windows))]
|
||||
{
|
||||
let candidate_unix = p.join("node");
|
||||
if candidate_unix.exists() {
|
||||
return Some(clean_path(&candidate_unix));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
{
|
||||
let default_paths = [
|
||||
r"C:\Program Files\nodejs\node.exe",
|
||||
r"C:\Program Files (x86)\nodejs\node.exe",
|
||||
];
|
||||
for path in default_paths {
|
||||
let candidate = std::path::Path::new(path);
|
||||
if candidate.exists() {
|
||||
return Some(clean_path(candidate));
|
||||
}
|
||||
}
|
||||
|
||||
if let Ok(local_app_data) = std::env::var("LOCALAPPDATA") {
|
||||
let candidate = std::path::PathBuf::from(local_app_data)
|
||||
.join("Programs")
|
||||
.join("nodejs")
|
||||
.join("node.exe");
|
||||
if candidate.exists() {
|
||||
return Some(clean_path(&candidate));
|
||||
}
|
||||
}
|
||||
|
||||
if let Ok(app_data) = std::env::var("APPDATA") {
|
||||
let candidate = std::path::PathBuf::from(app_data)
|
||||
.join("npm")
|
||||
.join("node.exe");
|
||||
if candidate.exists() {
|
||||
return Some(clean_path(&candidate));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
None
|
||||
}
|
||||
|
||||
fn resolve_script_and_root(app: &tauri::App) -> (String, String) {
|
||||
if let Ok(resource_dir) = app.path().resource_dir() {
|
||||
debug_log(&format!("Resource dir found: {:?}", resource_dir));
|
||||
@@ -117,13 +182,28 @@ fn main() {
|
||||
debug_log("Webview created");
|
||||
|
||||
let (main_js, root_dir) = resolve_script_and_root(app);
|
||||
let node_bin = match find_node_binary(app) {
|
||||
Some(bin) => bin,
|
||||
None => {
|
||||
debug_log("Node.js runtime not found anywhere");
|
||||
let _ = window.emit(
|
||||
"error",
|
||||
serde_json::json!({
|
||||
"message": "Node.js runtime not found on this system. Please install Node.js (https://nodejs.org) and restart Vyla Home."
|
||||
}),
|
||||
);
|
||||
return Ok(());
|
||||
}
|
||||
};
|
||||
|
||||
debug_log(&format!("Using Node binary: {}", node_bin));
|
||||
debug_log(&format!("Spawning node with script: {}", main_js));
|
||||
|
||||
let mut cmd = Command::new("node");
|
||||
let mut cmd = Command::new(&node_bin);
|
||||
cmd.arg(&main_js)
|
||||
.current_dir(&root_dir)
|
||||
.env("APPDATA_PATH", &app_data_str)
|
||||
.env("NODE_EXE", &node_bin)
|
||||
.stdout(Stdio::piped())
|
||||
.stderr(Stdio::piped());
|
||||
|
||||
@@ -172,6 +252,12 @@ fn main() {
|
||||
}
|
||||
Err(e) => {
|
||||
debug_log(&format!("FAILED to spawn Node: {}", e));
|
||||
let _ = window.emit(
|
||||
"error",
|
||||
serde_json::json!({
|
||||
"message": format!("Failed to launch backend runtime: {}", e)
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "https://raw.githubusercontent.com/tauri-apps/tauri/dev/tooling/cli/schema.json",
|
||||
"productName": "Vyla Home",
|
||||
"version": "1.0.2",
|
||||
"version": "1.0.3",
|
||||
"identifier": "com.vyla.home",
|
||||
"build": {
|
||||
"frontendDist": "../ui"
|
||||
|
||||
Reference in New Issue
Block a user