Skip to content

Commit 7910dde

Browse files
authored
devenv: Make init script more robust for devpod environments (#92)
The remount --make-shared / only works in codespaces which have specific Docker privileges. In devpod with rootless podman, the root filesystem may already have shared propagation or we may not have permission to remount. Use findmnt -J with jq for proper JSON parsing instead of string grep. Also add guards for: - /dev/kvm which may not exist in all environments - /usr/share/containers/containers.conf which may not exist Additionally, add tmux to common packages (used by devaipod's tmux command for split-view agent+shell sessions). Assisted-by: OpenCode (Claude sonnet-4-20250514) Signed-off-by: Colin Walters <walters@verbum.org>
1 parent 8e5c628 commit 7910dde

2 files changed

Lines changed: 22 additions & 7 deletions

File tree

devenv/devenv-init.sh

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,26 @@
11
#!/bin/bash
22
set -euo pipefail
33
# Set things up so that podman can run nested inside the privileged
4-
# docker container of a codespace.
4+
# docker container of a codespace or devpod.
55

6-
# Fix the propagation
7-
sudo mount -o remount --make-shared /
6+
# Fix the propagation - only needed in some environments (e.g., codespaces)
7+
# In devpod with rootless podman, / may already have shared propagation
8+
# or we may not have permission to remount it.
9+
propagation=$(findmnt -J -o TARGET,PROPAGATION / | jq -r '.filesystems[0].propagation // "unknown"')
10+
if [ "$propagation" = "private" ]; then
11+
if mount -o remount --make-shared / 2>/dev/null; then
12+
echo "Set / to shared propagation"
13+
else
14+
echo "Warning: Could not set / to shared propagation (may not be needed)"
15+
fi
16+
fi
817

918
# This is actually safe to expose to all users really, like Fedora derivatives do
10-
chmod a+rw /dev/kvm
19+
if [ -e /dev/kvm ]; then
20+
chmod a+rw /dev/kvm 2>/dev/null || true
21+
fi
1122

12-
# Handle nested cgroups
13-
sed -i -e 's,^#cgroups =.*,cgroups = "no-conmon",' /usr/share/containers/containers.conf
14-
sed -i -e 's,^#cgroup_manager =.*,cgroup_manager = "cgroupfs",' /usr/share/containers/containers.conf
23+
# Handle nested cgroups - update containers.conf if it exists and has the settings commented out
24+
if [ -f /usr/share/containers/containers.conf ]; then
25+
sed -i -e 's,^#cgroups =.*,cgroups = "no-conmon",' -e 's,^#cgroup_manager =.*,cgroup_manager = "cgroupfs",' /usr/share/containers/containers.conf
26+
fi

devenv/packages-common.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ rsync
1212
# Sandboxing (used by devaipod and flatpak)
1313
bubblewrap
1414

15+
# Terminal multiplexer (used by devaipod tmux command)
16+
tmux
17+
1518
# General build env (note: we install rust through rustup later)
1619
gcc
1720
clang

0 commit comments

Comments
 (0)