Skip to content

Commit d56f902

Browse files
authored
feat: sudo requirement non root user & improve installation error handling (#589)
1 parent 3c77a7b commit d56f902

File tree

5 files changed

+46
-11
lines changed

5 files changed

+46
-11
lines changed

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ You can customize your installation by providing the following optional paramete
6969
Example with optional parameters:
7070

7171
```bash
72-
nixopus install \
72+
sudo nixopus install \
7373
--api-domain nixopusapi.example.tld \
7474
--view-domain nixopus.example.tld \
7575
--verbose \
@@ -79,11 +79,14 @@ nixopus install \
7979
Example for custom ip setup:
8080

8181
```bash
82-
nixopus install \
82+
sudo nixopus install \
8383
--host-ip 10.0.0.154 \
8484
--verbose
8585
```
8686

87+
> [!NOTE]
88+
> Running `nixopus install` requires root privileges (sudo) to install system dependencies like Docker. If you encounter permission errors, make sure to run the command with `sudo`.
89+
8790
You can also install the CLI and run `nixopus install` with options in a single command, refer [installation documentation](https://docs.nixopus.com/install/#installation-options) for more details on options
8891

8992
## About the Name

cli/app/commands/install/deps.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,12 @@ def install_dep(dep, package_manager, logger, dry_run=False):
6464
if dry_run:
6565
logger.info(f"[DRY RUN] Would run: {install_command}")
6666
return True
67-
subprocess.check_call(install_command, shell=True)
67+
result = subprocess.run(install_command, shell=True, capture_output=True, text=True)
68+
if result.returncode != 0:
69+
error_output = result.stderr.strip() or result.stdout.strip()
70+
if error_output:
71+
logger.error(f"Installation command output: {error_output}")
72+
raise subprocess.CalledProcessError(result.returncode, install_command, result.stdout, result.stderr)
6873
return True
6974
if package_manager == "apt":
7075
cmd = ["sudo", "apt-get", "install", "-y", package]
@@ -86,6 +91,15 @@ def install_dep(dep, package_manager, logger, dry_run=False):
8691
return True
8792
subprocess.check_call(cmd, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
8893
return True
94+
except subprocess.CalledProcessError as e:
95+
error_msg = str(e)
96+
if "docker" in package.lower() and (e.returncode == 100 or "permission" in error_msg.lower()):
97+
logger.error(failed_to_install.format(dep=package, error=f"Exit code {e.returncode}"))
98+
logger.error("Docker installation requires root privileges.")
99+
logger.error("Please run: sudo nixopus install")
100+
else:
101+
logger.error(failed_to_install.format(dep=package, error=e))
102+
return False
89103
except Exception as e:
90104
logger.error(failed_to_install.format(dep=package, error=e))
91105
return False

cli/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "nixopus"
3-
version = "0.1.27"
3+
version = "0.1.28"
44
description = "A CLI for Nixopus"
55
authors = ["Nixopus <[email protected]>"]
66
readme = "README.md"

docs/cli/installation.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,11 +190,11 @@ Once the CLI is installed, you can use it to install Nixopus on your VPS:
190190
::: code-group
191191

192192
```bash [Basic Installation]
193-
nixopus install
193+
sudo nixopus install
194194
```
195195

196196
```bash [With Custom Domains]
197-
nixopus install \
197+
sudo nixopus install \
198198
--api-domain api.example.com \
199199
--view-domain app.example.com \
200200
--verbose
@@ -205,11 +205,15 @@ nixopus preflight
205205
```
206206

207207
```bash [Install Dependencies Only]
208-
nixopus install deps
208+
sudo nixopus install deps
209209
```
210210

211211
:::
212212

213+
::: warning Root Privileges Required
214+
The `nixopus install` command requires root privileges to install system dependencies like Docker. Always use `sudo` unless you're already running as root. If you encounter permission errors or "exit status 100", ensure you're using sudo.
215+
:::
216+
213217
::: tip Preflight Check
214218
Always run `nixopus preflight` before installation to verify your system meets all requirements. This can save time by catching issues early.
215219
:::

docs/install/index.md

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,13 @@ curl -sSL https://install.nixopus.com | bash -s -- --skip-nixopus-install
6161
Once the CLI is installed, you can install Nixopus on your VPS:
6262

6363
```bash
64-
nixopus install
64+
sudo nixopus install
6565
```
6666

67+
::: warning Sudo Required
68+
Running `nixopus install` requires root privileges to install system dependencies (like Docker). Always use `sudo` when running the install command. If you encounter "exit status 100" or permission errors, ensure you're using sudo.
69+
:::
70+
6771
::: info CLI Verification
6872
Before proceeding, verify the CLI is working:
6973
```bash
@@ -251,27 +255,37 @@ If you've already installed the CLI separately, you can run `nixopus install` di
251255
::: code-group
252256

253257
```bash [With Domains]
254-
nixopus install \
258+
sudo nixopus install \
255259
--api-domain api.example.com \
256260
--view-domain example.com \
257261
--verbose
258262
```
259263

260264
```bash [With IP]
261-
nixopus install \
265+
sudo nixopus install \
262266
--host-ip 192.168.1.100 \
263267
--verbose
264268
```
265269

266270
```bash [Custom Ports]
267-
nixopus install \
271+
sudo nixopus install \
268272
--api-port 9000 \
269273
--view-port 9001 \
270274
--timeout 600
271275
```
272276

273277
:::
274278

279+
::: tip Why Sudo?
280+
The `nixopus install` command needs root privileges to:
281+
282+
- Install Docker and other system dependencies
283+
- Configure system-level services
284+
- Set up network configurations
285+
286+
If you're already running as root user, you can omit `sudo`.
287+
:::
288+
275289
## Accessing Nixopus
276290

277291
After successful installation, access your Nixopus instance:

0 commit comments

Comments
 (0)