How to get an arch linux codespace? #126419
-
Select Topic AreaQuestion BodyI a trying to build a project that requires arch linux, as it won't work on other distros. How do I create an arch linux based codespace? |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 4 replies
This comment was marked as off-topic.
This comment was marked as off-topic.
-
|
I get sent to recovery container |
Beta Was this translation helpful? Give feedback.
-
|
@FunnyCheese4Me the correct solution is too minimal try this one FROM archlinux:latest
# Update and install base dependencies, sudo, git, and github-cli
# Also install 'which' as it's often used by scripts and might be missing
RUN pacman -Syu --noconfirm && \
pacman -S --noconfirm bash sudo git github-cli which less && \
pacman -Scc --noconfirm
# Create the codespace user with a home directory, add to wheel group (for sudo)
# Set bash as the default shell
RUN useradd -m -G wheel -s /bin/bash codespace && \
echo 'codespace ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/codespace && \
chmod 0440 /etc/sudoers.d/codespace
{
"name": "Arch Linux Codespace with Dockerfile",
"build": {
"dockerfile": "Dockerfile"
},
"remoteUser": "codespace",
"containerEnv": {
"GIT_EDITOR": "code --wait"
},
"postStartCommand": "echo \"Attempting to configure Git. GIT_COMMITTER_NAME='${GIT_COMMITTER_NAME}', GIT_COMMITTER_EMAIL='${GIT_COMMITTER_EMAIL}'\"\nCURRENT_GIT_USER=$(git config --global --get user.name)\nCURRENT_GIT_EMAIL=$(git config --global --get user.email)\necho \"Current git config user.name='${CURRENT_GIT_USER}', user.email='${CURRENT_GIT_EMAIL}'\"\nif [ -z \"${GIT_COMMITTER_NAME}\" ] || [ -z \"${GIT_COMMITTER_EMAIL}\" ]; then\n echo 'Warning: GIT_COMMITTER_NAME or GIT_COMMITTER_EMAIL is empty. Cannot automatically configure Git identity from these. Attempting gh auth setup-git.'\n if command -v gh >/dev/null && gh auth status >/dev/null 2>&1; then\n echo 'GitHub CLI is installed and authenticated. Running gh auth setup-git...'\n gh auth setup-git\n echo \"Git config after gh auth setup-git: user.name='$(git config --global user.name)', user.email='$(git config --global user.email)'\"\n else\n echo 'Warning: GitHub CLI not available or not authenticated. Please configure git manually: git config --global user.name \\\"Your Name\\\" && git config --global user.email \\\"you@example.com\\\"'\n fi\nelif [ -z \"${CURRENT_GIT_USER}\" ] || [ -z \"${CURRENT_GIT_EMAIL}\" ] || [ \"${CURRENT_GIT_USER}\" != \"${GIT_COMMITTER_NAME}\" ] || [ \"${CURRENT_GIT_EMAIL}\" != \"${GIT_COMMITTER_EMAIL}\" ]; then\n echo 'Configuring Git user name and email using Codespaces environment variables...'\n git config --global user.name \"${GIT_COMMITTER_NAME}\"\n git config --global user.email \"${GIT_COMMITTER_EMAIL}\"\n echo \"Git configured with user: $(git config --global user.name), email: $(git config --global user.email)\"\nelse\n echo 'Git user name and email already configured and match GIT_COMMITTER variables.'\nfi\necho 'Final git config:'\ngit config --global --list | grep user",
"customizations": {
"vscode": {
"settings": {
"terminal.integrated.defaultProfile.linux": "bash",
"terminal.integrated.profiles.linux": {
"bash": {
"path": "/bin/bash"
}
}
}
}
}
}This will make git be already integrated with github codespaces, so you dont need to register twice with git just like with the ubuntu images |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
|
You can run Arch Linux in GitHub Codespaces by using a custom devcontainer. You don’t need a VM or Folder structure .your-repo/
└─ .devcontainer/
├─ devcontainer.json
└─ Dockerfile.devcontainer/devcontainer.json {
"name": "Arch Codespace",
"build": { "dockerfile": "Dockerfile" },
"remoteUser": "vscode",
"updateRemoteUserUID": true,
"postCreateCommand": "sudo pacman -Syu --noconfirm"
}.devcontainer/Dockerfile FROM archlinux:latest
RUN pacman -Sy --noconfirm archlinux-keyring && \
pacman -Syu --noconfirm && \
pacman -S --noconfirm base-devel git sudo
ARG USERNAME=vscode
ARG USER_UID=1000
ARG USER_GID=1000
RUN groupadd -g $USER_GID $USERNAME && \
useradd -m -u $USER_UID -g $USER_GID $USERNAME && \
echo "$USERNAME ALL=(ALL) NOPASSWD:ALL" >/etc/sudoers.d/90-$USERNAME && \
chmod 0440 /etc/sudoers.d/90-$USERNAME
USER $USERNAME
WORKDIR /workspacesOpen the repo in Codespaces; it will build and start an Arch-based dev container. |
Beta Was this translation helpful? Give feedback.
Create an Arch Linux Dockerfile and run the devcontainer with the docker image.
DockerfileThen instruct GitHub Codespaces to build this Docker environment when initializing your codespace.
.devcontainer/devcontainer.json{ "name": "Arch Linux Codespace", "build": { "dockerfile": "Dockerfile" }, "settings": {}, "extensions": [], "postCreateCommand": "echo 'Environment ready!'" }