How to Organize Portable Programs Jul. 9, 2026

Say bye to 3rd party software repositories that require root.

Portable Programs Defined

Paths

Avoid managing /opt/app as root.

chown -R admin:admin /opt/app

Examples

/opt/app
├── deno
├── uv
│   ├── uv
│   └── uvx
└── zig
     ├── bin
     │   └── zig
     ├── doc
     │   └── langref.html
     └── lib
         └── zig

Apps can be versioned, symlink current to active version.

cd /opt/app/go
ln -s go1.26 current
/opt/app
└── go
     ├── current -> go1.26
     ├── go1.25
     └── go1.26

app-path

We want apps in PATH. Write /opt/app/app-path:

#!/bin/sh
for base in /opt/app "$HOME/app"; do
  [ -d "$base" ] || continue
  path="$path:$base"
  for app in "$base"/*; do
    if [ -d "$app/current" ]; then
      app="$app/current"
    fi
    if [ -d "$app/bin" ]; then
      path="$path:$app/bin"
    elif [ -d "$app" ]; then
      path="$path:$app"
    fi
  done
done
printf "%s" "${path#:}"

The script is in Public Domain.

All users can write this in their .bashrc:

export PATH="$(sh /opt/app/app-path):$PATH"

Source it (. ~/.bashrc) and they have all portable programs in PATH.