Description: Fix QProcess environment variables for Node.js server launch
 QProcess does not inherit environment variables by default, causing the
 Node.js streaming server (server.js) to fail at startup with "path argument
 must be of type string" errors. This patch ensures HOME, USER, and PWD
 environment variables are available to the spawned server process.
 .
 Without these variables, Node.js path.join() operations fail when trying
 to construct cache directory paths, preventing the streaming server from
 starting and causing "Error while starting streaming server" messages.
Author: Juan Manuel Méndez Rey <vejeta@gmail.com>
Origin: vendor
Forwarded: not-needed
Last-Update: 2025-10-01

--- stremio-4.4.169.orig/stremioprocess.cpp
+++ stremio-4.4.169/stremioprocess.cpp
@@ -56,6 +56,20 @@ void Process::start(const QString &progr
     QObject::connect(this, &QProcess::readyReadStandardError, this, &Process::onStdErr);
     QObject::connect(this, &QProcess::started, this, &Process::onStarted);
 
+    // Set up environment variables for Node.js server
+    QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
+    // Ensure essential environment variables are set for server.js
+    if (!env.contains("HOME")) {
+        env.insert("HOME", QStandardPaths::writableLocation(QStandardPaths::HomeLocation));
+    }
+    if (!env.contains("USER")) {
+        env.insert("USER", qgetenv("USER"));
+    }
+    if (!env.contains("PWD")) {
+        env.insert("PWD", QDir::currentPath());
+    }
+    this->setProcessEnvironment(env);
+
     QProcess::start(program, args);
 }
 
--- stremio-4.4.169.orig/stremioprocess.h
+++ stremio-4.4.169/stremioprocess.h
@@ -1,9 +1,11 @@
 #ifndef STREMIOPROCESS_H
 #define STREMIOPROCESS_H
 #include <QProcess>
+#include <QProcessEnvironment>
 #include <QVariant>
 #include <QStandardPaths>
 #include <QObject>
+#include <QDir>
 #include <iostream>
 
 class Process : public QProcess {
