Files
claude-desktop-debian/docs/BUILDING.md

155 lines
5.7 KiB
Markdown
Raw Normal View History

[< Back to README](../README.md)
# Building from Source
## Prerequisites
- Linux distribution (Debian/Ubuntu, Fedora/RHEL, or other)
- Git
- Basic build tools (automatically installed by the script)
## Build Instructions
```bash
# Clone the repository
git clone https://github.com/aaddrick/claude-desktop-debian.git
cd claude-desktop-debian
# Build with auto-detected format (based on your distro)
./build.sh
# Or specify a format explicitly:
./build.sh --build deb # Debian/Ubuntu .deb package
./build.sh --build rpm # Fedora/RHEL .rpm package
./build.sh --build appimage # Distribution-agnostic AppImage
./build.sh --build nix # Nix derivation (patch only, used by flake)
# Build with custom options
./build.sh --build deb --clean no # Keep intermediate files
# Build using a locally downloaded installer
# (useful when the bundled download URL is outdated)
./build.sh --exe /path/to/Claude-Setup.exe
```
The build script automatically detects your distribution and selects the appropriate package format:
| Distribution | Default Format | Package Manager |
|--------------|----------------|-----------------|
| Debian, Ubuntu, Mint | `.deb` | apt |
| Fedora, RHEL, CentOS | `.rpm` | dnf |
| NixOS | `nix` | nix |
| Arch Linux | `.AppImage` (via AUR) | yay/paru |
| Other | `.AppImage` | - |
## Build Environment Variables
The build pulls the Electron prebuilt binary from `github.com/electron/electron/releases` via `@electron/get`. Two upstream environment variables let you redirect that fetch:
- `ELECTRON_MIRROR` — base URL to fetch Electron releases from instead of GitHub. Useful for mirrors or local proxies. Example: `ELECTRON_MIRROR=https://npmmirror.com/mirrors/electron/`.
- `ELECTRON_CUSTOM_DIR` — overrides the path segment after the mirror. Defaults to `v{version}`.
The cache location is fixed at `~/.cache/electron/` (resolved by `@electron/get` via `envPaths`) and is reused across builds. `ELECTRON_CACHE` is **not** read by `@electron/get` — set `ELECTRON_MIRROR` if you need to avoid the public CDN.
The pinned Electron version lives in `scripts/setup/dependencies.sh` (`electron_version`) and must match `build-reference/app-extracted/package.json` — the upstream Claude Desktop `app.asar` is built against a specific Electron major and running a different one is unsupported.
## Installing the Built Package
### For .deb packages (Debian/Ubuntu)
```bash
sudo apt install ./claude-desktop_VERSION_ARCHITECTURE.deb
# Or: sudo dpkg -i ./claude-desktop_VERSION_ARCHITECTURE.deb
# If you encounter dependency issues:
sudo apt --fix-broken install
```
### For .rpm packages (Fedora/RHEL)
```bash
sudo dnf install ./claude-desktop-VERSION-1.ARCH.rpm
# Or: sudo rpm -i ./claude-desktop-VERSION-1.ARCH.rpm
```
### For AppImages
```bash
# Make executable
chmod +x ./claude-desktop-*.AppImage
# Run directly
./claude-desktop-*.AppImage
# Or integrate with your system using Gear Lever
```
**Note:** AppImage login requires proper desktop integration. Use [Gear Lever](https://flathub.org/apps/it.mijorus.gearlever) or manually install the provided `.desktop` file to `~/.local/share/applications/`.
**Automatic Updates:** AppImages downloaded from GitHub releases include embedded update information and work seamlessly with Gear Lever for automatic updates. Locally-built AppImages can be manually configured for updates in Gear Lever.
### For NixOS
The repository includes a Nix flake. Build and install directly:
```bash
# Build the package
nix build .#claude-desktop
# Build the FHS-wrapped variant (for MCP server support)
nix build .#claude-desktop-fhs
# Run without installing
nix run .#claude-desktop
```
For declarative NixOS installation, see the [README](../README.md#using-nix-flake-nixos).
## Technical Details
### How It Works
Claude Desktop is an Electron application distributed for Windows. This project:
1. Downloads the official Windows installer
2. Extracts application resources
3. Replaces Windows-specific native modules with Linux-compatible implementations
4. Repackages as one of:
- **Debian package (.deb)**: For Debian, Ubuntu, and derivatives
- **RPM package (.rpm)**: For Fedora, RHEL, CentOS, and derivatives
- **AppImage**: Portable, distribution-agnostic executable
- **Nix package**: For NixOS, via the included flake
### Build Process
The build script (`build.sh`) handles:
- Dependency checking and installation
- Resource extraction from Windows installer
- Icon processing for Linux desktop standards
- Native module replacement
- Package generation based on selected format
### Automated Version Detection
A GitHub Actions workflow runs daily to check for new Claude Desktop releases:
1. Uses Playwright to resolve Anthropic's Cloudflare-protected download redirects
docs: refresh for scripts/ split layout Updates agent definitions, learnings, CLAUDE.md, and BUILDING.md so path references point at the new module files instead of the old monolithic build.sh. Agent definitions: .claude/agents/issue-triage.md — table of per-category investigation paths now points at scripts/patches/*.sh and scripts/packaging/*.sh instead of "build.sh (search patch_X)". .claude/agents/electron-linux-specialist.md — patching-functions table now includes each function's file location; directory tree illustration reflects the new scripts/ layout. Documentation: CLAUDE.md — "Working with Minified JavaScript" section points at scripts/patches/*.sh; frame-fix injection attributed to scripts/patches/app-asar.sh; the version-bump checks now grep scripts/setup/detect-host.sh. docs/BUILDING.md — automated version detection paragraph now mentions scripts/setup/detect-host.sh as the file that holds the URLs. docs/learnings/cowork-vm-daemon.md — Patch 6 pointer now says scripts/patches/cowork.sh; line-number references dropped in favour of anchor-based search (line numbers drift between releases). docs/learnings/plugin-install.md — Key Files section points at scripts/patches/cowork.sh for patch_cowork_linux. Historical changelog-style references (e.g. docs/cowork-linux-handover.md describing what was "added to build.sh" during initial cowork work) are intentionally left unchanged — they describe a point-in-time state of the codebase. Co-Authored-By: Claude <claude@anthropic.com>
2026-04-20 07:31:02 -04:00
2. Compares resolved URLs with those in `scripts/setup/detect-host.sh`
3. If a new version is detected:
docs: refresh for scripts/ split layout Updates agent definitions, learnings, CLAUDE.md, and BUILDING.md so path references point at the new module files instead of the old monolithic build.sh. Agent definitions: .claude/agents/issue-triage.md — table of per-category investigation paths now points at scripts/patches/*.sh and scripts/packaging/*.sh instead of "build.sh (search patch_X)". .claude/agents/electron-linux-specialist.md — patching-functions table now includes each function's file location; directory tree illustration reflects the new scripts/ layout. Documentation: CLAUDE.md — "Working with Minified JavaScript" section points at scripts/patches/*.sh; frame-fix injection attributed to scripts/patches/app-asar.sh; the version-bump checks now grep scripts/setup/detect-host.sh. docs/BUILDING.md — automated version detection paragraph now mentions scripts/setup/detect-host.sh as the file that holds the URLs. docs/learnings/cowork-vm-daemon.md — Patch 6 pointer now says scripts/patches/cowork.sh; line-number references dropped in favour of anchor-based search (line numbers drift between releases). docs/learnings/plugin-install.md — Key Files section points at scripts/patches/cowork.sh for patch_cowork_linux. Historical changelog-style references (e.g. docs/cowork-linux-handover.md describing what was "added to build.sh" during initial cowork work) are intentionally left unchanged — they describe a point-in-time state of the codebase. Co-Authored-By: Claude <claude@anthropic.com>
2026-04-20 07:31:02 -04:00
- Updates `scripts/setup/detect-host.sh` with new download URLs
- Updates `nix/claude-desktop.nix` with new version, URLs, and SRI hashes
- Creates a new release tag
- Triggers automated builds for both architectures
This ensures the repository stays up-to-date with official releases automatically.
### Manual Updates
If you need to build with a specific version before the automation catches it:
1. **Use a local installer**: Download the latest installer from [claude.ai/download](https://claude.ai/download) and build with:
```bash
./build.sh --exe /path/to/Claude-Setup.exe
```
docs: refresh for scripts/ split layout Updates agent definitions, learnings, CLAUDE.md, and BUILDING.md so path references point at the new module files instead of the old monolithic build.sh. Agent definitions: .claude/agents/issue-triage.md — table of per-category investigation paths now points at scripts/patches/*.sh and scripts/packaging/*.sh instead of "build.sh (search patch_X)". .claude/agents/electron-linux-specialist.md — patching-functions table now includes each function's file location; directory tree illustration reflects the new scripts/ layout. Documentation: CLAUDE.md — "Working with Minified JavaScript" section points at scripts/patches/*.sh; frame-fix injection attributed to scripts/patches/app-asar.sh; the version-bump checks now grep scripts/setup/detect-host.sh. docs/BUILDING.md — automated version detection paragraph now mentions scripts/setup/detect-host.sh as the file that holds the URLs. docs/learnings/cowork-vm-daemon.md — Patch 6 pointer now says scripts/patches/cowork.sh; line-number references dropped in favour of anchor-based search (line numbers drift between releases). docs/learnings/plugin-install.md — Key Files section points at scripts/patches/cowork.sh for patch_cowork_linux. Historical changelog-style references (e.g. docs/cowork-linux-handover.md describing what was "added to build.sh" during initial cowork work) are intentionally left unchanged — they describe a point-in-time state of the codebase. Co-Authored-By: Claude <claude@anthropic.com>
2026-04-20 07:31:02 -04:00
2. **Update the URL**: Modify the `claude_download_url` assignments in `scripts/setup/detect-host.sh` (inside the `detect_architecture` case statement).