Uploading debug files in CI
If you ship stripped binaries, Flare needs the debug files of every build you deploy. Your CI is the natural place to upload them: the debug files are sitting right there after the build, and the upload is done before the new binary handles its first request.
This page has a working setup for GitHub Actions on Linux, macOS and Windows runners, for Docker builds, and for any other CI system. If you'd like to know why each platform needs different settings first, read release builds and debug files.
What every pipeline does
Whatever runs your builds, the steps are the same:
- Install the
cargo-flareappCLI. - Build your app with debug info.
- On Linux, move the debug info out of the binary into a
.debugfile. - Upload the debug files with
cargo flareapp upload-debug-files. - Ship the binary without its debug files.
Store the private API key of your project as a secret in your CI, and hand it to the CLI as FLARE_KEY. The CLI has no flag for the key on purpose, so it never ends up in your build logs.
Every pipeline on this page uses this release profile:
Cargo.toml
[profile.release]
debug = "limited"
GitHub Actions
Add FLARE_KEY as a repository secret under Settings → Secrets and variables → Actions. Then pick the runner your release builds on:
@verbatim
.github/workflows/release.yml
name: Release
on:
push:
tags: ['v*']
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@stable
- name: Install the Flare CLI
run: cargo install cargo-flareapp --locked
- name: Build
run: cargo build --release --locked
env:
RUSTFLAGS: -C link-arg=-Wl,--build-id
- name: Split the debug info from the binary
run: |
objcopy --only-keep-debug target/release/my-app target/release/my-app.debug
objcopy --strip-debug --strip-unneeded target/release/my-app
objcopy --add-gnu-debuglink=target/release/my-app.debug target/release/my-app
- name: Upload debug files to Flare
run: cargo flareapp upload-debug-files target/release
env:
FLARE_KEY: ${{ secrets.FLARE_KEY }}
# Deploy target/release/my-app from here, without my-app.debug.
.github/workflows/release.yml
name: Release
on:
push:
tags: ['v*']
jobs:
build:
runs-on: macos-latest
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@stable
- name: Install the Flare CLI
run: cargo install cargo-flareapp --locked
- name: Build
run: cargo build --release --locked
env:
CARGO_PROFILE_RELEASE_SPLIT_DEBUGINFO: packed
- name: Upload debug files to Flare
run: cargo flareapp upload-debug-files target/release
env:
FLARE_KEY: ${{ secrets.FLARE_KEY }}
# Deploy target/release/my-app from here, without my-app.dSYM.
.github/workflows/release.yml
name: Release
on:
push:
tags: ['v*']
jobs:
build:
runs-on: windows-latest
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@stable
- name: Install the Flare CLI
run: cargo install cargo-flareapp --locked
- name: Build
run: cargo build --release --locked
- name: Upload debug files to Flare
run: cargo flareapp upload-debug-files target/release
env:
FLARE_KEY: ${{ secrets.FLARE_KEY }}
# Deploy target\release\my-app.exe from here, without my_app.pdb.
Replace my-app with the name of your binary. A few things are different per platform:
- Linux needs a build ID in the binary, which is what the
RUSTFLAGSline takes care of. If you already put the flag in.cargo/config.toml, as described in step 2 of the upload guide, you can leave the line out. The debug info sits inside the binary, soobjcopymoves it tomy-app.debugfirst. The CLI uploads that file. See step 3 of the upload guide for what each command does. - macOS needs
split-debuginfo = "packed", so Cargo writes a.dSYMbundle that the CLI can upload. The environment variable sets it for this job only. - Windows needs nothing extra. The MSVC toolchain on the Windows runners writes the debug info to a
.pdbfile next to your.exe. The steps run in PowerShell there, and the commands are the same.
You don't have to tell Flare which commit you built. flareapp::config!() reads GITHUB_SHA while your app compiles, so every report already carries the commit. See application info.
Building for every platform at once
Shipping a tool that runs on all three? One job with a build matrix covers them. The platform-specific steps only run on the platform that needs them:
.github/workflows/release.yml
name: Release
on:
push:
tags: ['v*']
jobs:
build:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@stable
- name: Install the Flare CLI
run: cargo install cargo-flareapp --locked
- name: Ask the linker for a build ID
if: runner.os == 'Linux'
run: echo "RUSTFLAGS=-C link-arg=-Wl,--build-id" >> "$GITHUB_ENV"
- name: Put the debug info in a .dSYM bundle
if: runner.os == 'macOS'
run: echo "CARGO_PROFILE_RELEASE_SPLIT_DEBUGINFO=packed" >> "$GITHUB_ENV"
- name: Build
run: cargo build --release --locked
- name: Split the debug info from the binary
if: runner.os == 'Linux'
run: |
objcopy --only-keep-debug target/release/my-app target/release/my-app.debug
objcopy --strip-debug --strip-unneeded target/release/my-app
objcopy --add-gnu-debuglink=target/release/my-app.debug target/release/my-app
- name: Upload debug files to Flare
run: cargo flareapp upload-debug-files target/release
env:
FLARE_KEY: ${{ secrets.FLARE_KEY }}
@endverbatim
Speeding up the CLI install
cargo install compiles the CLI from source, which adds a few minutes to a cold runner. Cache ~/.cargo/bin between runs to skip that: when the same version of cargo-flareapp is already installed, cargo install sees it and stops right away.
Docker
Many Rust apps go to production as a Docker image. Split off and upload the debug info in the build stage, and copy only the stripped binary into the final image:
Dockerfile
FROM rust:1-trixie AS build
WORKDIR /app
RUN cargo install cargo-flareapp --locked
COPY . .
ARG FLARE_GIT_HASH
ENV RUSTFLAGS="-C link-arg=-Wl,--build-id"
RUN cargo build --release --locked
RUN objcopy --only-keep-debug target/release/my-app target/release/my-app.debug \
&& objcopy --strip-debug --strip-unneeded target/release/my-app \
&& objcopy --add-gnu-debuglink=target/release/my-app.debug target/release/my-app
RUN --mount=type=secret,id=flare_key \
FLARE_KEY="$(cat /run/secrets/flare_key)" cargo flareapp upload-debug-files target/release
FROM debian:trixie-slim
COPY --from=build /app/target/release/my-app /usr/local/bin/my-app
CMD ["my-app"]
Build it with the key as a secret, and the commit as a build argument:
Terminal
docker build \
--secret id=flare_key,env=FLARE_KEY \
--build-arg FLARE_GIT_HASH="$(git rev-parse HEAD)" \
.
Pass the key as a secret, not as a build argument. Build arguments end up in the history of your image, and anyone who pulls the image can read them. Secrets are only there while the one RUN step runs.
The commit is a build argument because a Docker build can't see the variables of your CI. With FLARE_GIT_HASH set during cargo build, the commit is baked into your binary, just like on GitHub Actions.
Because the CLI is installed before COPY . ., Docker caches that layer, and it only gets installed again when the image of the build stage changes.
Other CI systems
GitLab CI, CircleCI, Bitbucket Pipelines, Jenkins, Azure Pipelines and the rest all come down to a few shell commands. On a Linux or macOS runner:
Terminal
cargo install cargo-flareapp --locked
RUSTFLAGS="-C link-arg=-Wl,--build-id" cargo build --release --locked
objcopy --only-keep-debug target/release/my-app target/release/my-app.debug
objcopy --strip-debug --strip-unneeded target/release/my-app
objcopy --add-gnu-debuglink=target/release/my-app.debug target/release/my-app
cargo flareapp upload-debug-files target/release
Terminal
cargo install cargo-flareapp --locked
CARGO_PROFILE_RELEASE_SPLIT_DEBUGINFO=packed cargo build --release --locked
cargo flareapp upload-debug-files target/release
Terminal
cargo install cargo-flareapp --locked
cargo build --release --locked
cargo flareapp upload-debug-files target\release
Each of these expects FLARE_KEY in the environment, so add it as a secret or protected variable in your CI. In GitLab, that's a masked variable under Settings → CI/CD → Variables.
GitLab CI, CircleCI and Bitbucket Pipelines give the commit to your build in CI_COMMIT_SHA, CIRCLE_SHA1 and BITBUCKET_COMMIT, and flareapp::config!() reads those on its own. Jenkins and Azure Pipelines use other names, so set FLARE_GIT_HASH before the build:
Terminal
# Jenkins, with the Git plugin
export FLARE_GIT_HASH="$GIT_COMMIT"
Terminal
# Azure Pipelines, on a Windows agent
$env:FLARE_GIT_HASH = "$(Build.SourceVersion)"
Running the build on your own machine, or on a server that deploys itself? The same commands work there. Leave the key out of your shell history by exporting it from a file or a password manager, rather than typing it in front of the command.
Reading the output
The CLI prints one line for every file it finds:
uploaded target/release/my-app.debug (c1877035-9a24-3a67-aa37-a2c7360781ed)
already on Flare target/release/my-worker.debug
skipped target/release/my-tool: the file has no debug information
- uploaded: Flare didn't have this file yet, and now it does.
- already on Flare: Flare has this exact file already, from an earlier run or an earlier build of the same code. Nothing to do.
- skipped: Flare can't use this file, and the line says why. One skipped file doesn't stop the others from uploading.
A line that starts with warning: is worth a look, but it doesn't fail your build.
Add --dry-run to see the list without uploading anything. The files it would upload show up as would upload. It doesn't need an API key, so it's a quick way to check your build settings on a branch, before you add the secret.
When the upload fails
The CLI fails your build when something is wrong that would fail again on the next deploy:
FLARE_KEYisn't set.- It found no debug files that Flare can use, for example because you forgot the build ID on Linux or
packedon macOS. - Flare refused the upload, for example because the key is wrong, or because it's the public key instead of the private one.
When Flare or its file storage can't be reached, or answers with a 5xx, 408 or 429 status, the CLI tries again three times. If that doesn't help, it prints a warning and exits with code 0, so an outage on our side never blocks your deploy. Reports that arrive before the files are uploaded keep the frames the SDK could resolve in your app. Run the upload again once Flare is reachable, and the reports from then on are resolved.
Read more
- Troubleshooting: fixes for the most common upload errors, like
the file has no GNU build ID. - Release builds and debug files: why each platform needs different build settings.