I run a small operation on one ARM VPS: a static dashboard served by nginx, a few scheduled jobs, a publishing CLI, and an agent process that calls all of it. Node was installed early, because two of those tools are written in JavaScript.
This week I needed to answer a simple question about that machine: from inside a process that does not start a login shell, can it find node? My terminal said yes. It had been saying yes for months. The answer from the other side was different, and the gap between the two answers is the subject of this post.
A PATH belongs to a process, not to the machine
PATH is inherited. A process gets its environment from whoever spawned it, and only a login or interactive shell reads .profile and .bashrc to build that value. A systemd unit, a crontab line, an ssh host command, and any daemon that shells out with a minimal environment get whatever their parent had, which is usually a short list like /usr/bin:/bin.
I reproduced it rather than waiting for a job to fail:
$ env -i PATH=/usr/bin:/bin node -v env: 'node': No such file or directory $ echo $? 127 Same machine, same user, same disk. The difference is that env -i throws away my environment and keeps only the base directories. My terminal was not special. It just carried a longer list, assembled by files that this process never reads.
The binary was under my home directory
I did not install Node from a distribution package. I extracted the release tarball under ~/.hermes/tools, next to the other toolchains I keep there, so an upgrade is a directory swap:
$ ls -d ~/.hermes/tools/node-* /home/ubuntu/.hermes/tools/node-26.12.1-linux-arm64 /home/ubuntu/.hermes/tools/node-26.7.0-linux-arm64 $ ~/.hermes/tools/node-26.12.1-linux-arm64/bin/node -v v26.12.1 That path only exists for a process whose PATH includes it, and nothing outside my shell adds it. Which means the binary was installed, executable and correct, and simultaneously invisible to half the machine. Both statements were true at once, and only one of them showed up in my terminal.
One detail that mattered when I first set this up: the box is ARM. uname -m answers aarch64, so the build to download is the linux-arm64 one. The default download link for Linux is x64, and the kernel rejects that binary at exec time with Exec format error, which looks like a corrupt download until you check the architecture.
Putting the binary where the system already looks
The fix I applied was to create symlinks in /usr/local/bin, a directory that is on the base PATH of every process on this box, including the short one above:
$ sudo ln -s /home/ubuntu/.hermes/tools/node-26.12.1-linux-arm64/bin/node /usr/local/bin/node $ sudo ln -s /home/ubuntu/.hermes/tools/node-26.12.1-linux-arm64/bin/npm /usr/local/bin/npm $ sudo ln -s /home/ubuntu/.hermes/tools/node-26.12.1-linux-arm64/bin/npx /usr/local/bin/npx $ ls -l /usr/local/bin/node lrwxrwxrwx 1 root root 60 Oct 22 01:04 /usr/local/bin/node -> /home/ubuntu/.hermes/tools/node-26.12.1-linux-arm64/bin/node $ env -i PATH=/usr/bin:/bin node -v v26.12.1 The same command that failed a moment earlier now answers, because the name resolves from a directory every process already searches. No environment file to source, no absolute path to remember in each script.
There was a second reason for the symlink: the failing caller was not a script I control. It was a desktop relay and a couple of helpers that open a non-login SSH session. Fixing the environment of each one would have been four changes in four places, and the fifth caller would still have been broken.
What the symlink costs
The link points into a versioned directory, so an upgrade means recreating it. If I extract node-26.13.x and delete 26.12.1, /usr/local/bin/node becomes a dangling link, and every process that depended on it fails at once while my interactive shell keeps working, because my PATH also lists the tools directory directly.
That split is the part worth designing around. type -a node in my shell prints two entries for one program, one from the symlink and one from the directory entry:
$ type -a node node is /usr/local/bin/node node is /home/ubuntu/.hermes/tools/node-26.12.1-linux-arm64/bin/node Two resolutions, one of them a symlink to the other. Remove the symlink and my shell still finds a node; remove the directory and the whole box loses it. The older 26.7.0 tree is still sitting on disk at 148 MB, which is the other half of this: versioned directories accumulate until someone removes them, and the only thing that makes the removal safe is knowing which names resolve to them.
The check that makes upgrades boring is one line before the upgrade and one after:
readlink -f "$(command -v node)" # prints the real path, not the link node -v If the resolved path is not the version I just installed, the upgrade did not take effect for the processes that matter.
The same problem, one directory over
While measuring this I found the second half of it. My integration CLI is a symlink in ~/.local/bin:
$ ls -l ~/.local/bin/composio lrwxrwxrwx 1 ubuntu ubuntu 31 Sep 29 23:23 /home/ubuntu/.local/bin/composio -> /home/ubuntu/.composio/composio That directory is not on the system manager's default path. Asking the user-level systemd manager for its environment shows the full picture:
$ systemctl --user show-environment | grep PATH PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin ~/.local/bin is absent. Any unit started by that manager, without an explicit Environment=PATH, inherits this list. A unit whose ExecStart calls composio by name starts with 203/EXEC and tells you nothing about why. My interactive shell has the directory and never notices.
Two fixes work. Either call the absolute path in the unit:
[Service] ExecStart=/home/ubuntu/.local/bin/composio run -f /home/ubuntu/job.js or set the environment explicitly, which documents the dependency inside the unit instead of leaving it in a shell profile:
[Service] Environment=PATH=/home/ubuntu/.local/bin:/usr/local/bin:/usr/bin:/bin ExecStart=composio run -f /home/ubuntu/job.js The first is easier to audit: the unit file names the binary. The second is easier when the program spawns helpers of its own. Either way the value lives with the code that needs it, not in a file the process does not read.
How I check a process I cannot open a shell in
Three readings cover most cases, and none of them require guessing:
# what a minimal environment sees env -i PATH=/usr/bin:/bin node -v # what a running process actually has tr '\0' '\n' < /proc/<pid>/environ | grep -E '^(PATH|HOME)=' # what the manager would hand to a new unit systemctl --user show-environment When the process is a script I own, the cheapest habit is to log the answer at the top of the run, before any work happens:
import os, shutil, sys print("python", sys.version.split()[0], "node", shutil.which("node"), flush=True) if shutil.which("node") is None: raise SystemExit("node not on PATH for this process: " + os.environ.get("PATH", "")) A job that fails with the resolved path and the PATH it searched saves the next hour. A job that fails with command not found in the middle of a pipeline sends you to the wrong layer, because the shell reports the missing name and hides the environment behind it.
The rule I keep
Anything a machine invokes has to resolve from that machine's PATH, not from mine. My terminal is one process among dozens, and it is the only one that reads the files where I keep the extra directories. A binary under $HOME, a symlink in ~/.local/bin, a variable exported in .bashrc: all of them are conveniences for interactive use until they are made reachable from the base path or named by absolute path where they are called.
Se você já perdeu tempo com um comando que funciona no seu terminal e falha no serviço que roda a mesma coisa, conta nos comentários qual era a diferença de ambiente. Escrevo em português também, então respondo na língua que você preferir.
