Skip to content

fix: copy libsteam_api to build output and improve installation docs#27

Merged
unhappychoice merged 1 commit intomainfrom
fix/libsteam-api-so-not-found
Feb 16, 2026
Merged

fix: copy libsteam_api to build output and improve installation docs#27
unhappychoice merged 1 commit intomainfrom
fix/libsteam-api-so-not-found

Conversation

@unhappychoice
Copy link
Owner

@unhappychoice unhappychoice commented Feb 16, 2026

Summary

Fixes the libsteam_api.so: cannot open shared object file error reported by users (e.g., on Fedora 43).

Changes

  • build.rs: Auto-copy libsteam_api.so / .dylib / .dll from steamworks-sys build output to target/<profile>/ so it sits next to the binary and is resolved by $ORIGIN rpath
  • README.md: Remove cargo install installation method (cargo install only copies the binary, not the shared library, and there is no way to fix this within Cargo's constraints). Add FAQ entry for the libsteam_api.so error
  • install.sh: Warn if the shared library is missing after installation

Background

steamfetch dynamically links against libsteam_api.so (bundled by steamworks-sys). The existing $ORIGIN rpath means the library must be in the same directory as the binary. The install script and Homebrew handle this, but cargo build left the .so deep inside target/build/steamworks-sys-*/out/ — not next to the binary. cargo install is worse: it only copies the binary to ~/.cargo/bin/, and there is no mechanism in Cargo to install additional files.

Summary by CodeRabbit

  • Documentation

    • Enhanced setup documentation with detailed troubleshooting guidance for library resolution issues.
  • Improvements

    • Automated Steam API library management during build and installation processes.
    • Added runtime verification to detect and warn about missing platform-specific library files during installation.

- build.rs: auto-copy libsteam_api shared library to target/<profile>/
  so it is found at runtime via $ORIGIN rpath
- README: remove cargo install section (cannot bundle .so), add FAQ
  for libsteam_api.so error
- install.sh: warn if shared library is missing after installation
@coderabbitai
Copy link

coderabbitai bot commented Feb 16, 2026

📝 Walkthrough

Walkthrough

The PR refactors library handling for Steam API shared objects: build.rs now includes dedicated functions to copy the Steam API library to the output directory and configure rpath for runtime resolution. Documentation is updated to explain library requirements, and the install script adds verification warnings for missing libraries.

Changes

Cohort / File(s) Summary
Documentation Updates
README.md
Removed crates.io installation block; enhanced Build from Source section and FAQ with details about libsteam_api.so library handling and automatic copying to target/release/.
Build System Refactoring
build.rs
Extracted library handling into dedicated functions: set_rpath() for linker configuration, copy_steam_api_library() for copying the library to output, find_steam_api_lib() for locating the built library, and steam_api_lib_name() for OS-specific naming.
Installation Script Enhancement
install.sh
Added runtime verification warnings to detect missing platform-specific Steam API library files (libsteam_api.so on Linux, libsteam_api.dylib on macOS) after installation.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Poem

🐰 With whiskers twitched, the rabbit builds with care,
Libraries copied, paths configured fair,
From source to runtime, the steam flows free,
A hop, a skip—the binary's spree! 🚀

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the two main changes: copying libsteam_api to build output and improving documentation.
Docstring Coverage ✅ Passed Docstring coverage is 83.33% which is sufficient. The required threshold is 80.00%.
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into main

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/libsteam-api-so-not-found

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@unhappychoice unhappychoice merged commit 3d7b294 into main Feb 16, 2026
7 of 8 checks passed
@unhappychoice unhappychoice deleted the fix/libsteam-api-so-not-found branch February 16, 2026 17:28
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@build.rs`:
- Around line 50-53: The current silent ignore of std::fs::copy hides failures;
replace the unused-result call with proper error handling: call
std::fs::copy(&lib_src, &lib_dst) and match its Result, and on Err emit a
build-time hint via println!("cargo:warning=...") including the error message
and the lib_src/lib_dst paths (reference symbols: lib_src, lib_dst,
std::fs::copy, and the cargo:warning mechanism) so users see why the copy failed
during cargo build.
🧹 Nitpick comments (2)
build.rs (2)

24-26: Doc comment mentions cargo install but it won't actually help there.

The copy targets target/<profile>/, not ~/.cargo/bin/, so cargo install users won't benefit from this logic. Since the README already dropped cargo install as an installation method, consider updating this comment to avoid confusion.

Suggested wording
-/// Copy libsteam_api shared library next to the output binary so it can be found at runtime.
-/// This handles `cargo build` and `cargo install` cases where the library would otherwise
-/// only exist deep inside the build directory.
+/// Copy libsteam_api shared library next to the output binary so it can be found at runtime.
+/// Without this, the library only exists deep inside the build directory (target/build/.../out/).

56-56: Prefer &Path over &PathBuf for function parameters.

Clippy's ptr_arg lint flags this — &Path is the idiomatic borrow type and avoids requiring callers to hold a PathBuf.

Proposed fix
-fn find_steam_api_lib(build_dir: &PathBuf, lib_name: &str) -> Option<PathBuf> {
+fn find_steam_api_lib(build_dir: &std::path::Path, lib_name: &str) -> Option<PathBuf> {

Comment on lines +50 to +53
let lib_dst = profile_dir.join(lib_name);
if lib_src != lib_dst {
let _ = std::fs::copy(&lib_src, &lib_dst);
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Silent copy failure hides the exact problem this PR aims to fix.

If std::fs::copy fails (e.g., permissions, disk full), the build silently succeeds but the library is missing at runtime — the same user-facing error this PR addresses. Emit a cargo:warning so users get a build-time hint.

Proposed fix
     let lib_dst = profile_dir.join(lib_name);
     if lib_src != lib_dst {
-        let _ = std::fs::copy(&lib_src, &lib_dst);
+        if let Err(e) = std::fs::copy(&lib_src, &lib_dst) {
+            println!(
+                "cargo:warning=Failed to copy {} to {}: {}",
+                lib_src.display(),
+                lib_dst.display(),
+                e
+            );
+        }
     }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
let lib_dst = profile_dir.join(lib_name);
if lib_src != lib_dst {
let _ = std::fs::copy(&lib_src, &lib_dst);
}
let lib_dst = profile_dir.join(lib_name);
if lib_src != lib_dst {
if let Err(e) = std::fs::copy(&lib_src, &lib_dst) {
println!(
"cargo:warning=Failed to copy {} to {}: {}",
lib_src.display(),
lib_dst.display(),
e
);
}
}
🤖 Prompt for AI Agents
In `@build.rs` around lines 50 - 53, The current silent ignore of std::fs::copy
hides failures; replace the unused-result call with proper error handling: call
std::fs::copy(&lib_src, &lib_dst) and match its Result, and on Err emit a
build-time hint via println!("cargo:warning=...") including the error message
and the lib_src/lib_dst paths (reference symbols: lib_src, lib_dst,
std::fs::copy, and the cargo:warning mechanism) so users see why the copy failed
during cargo build.

@coderabbitai coderabbitai bot mentioned this pull request Feb 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant