Skip to content

Installing and compiling only using cargo #661

Open

Description

@GeorgeWashingTongue

Description

Installing and compiling only using cargo.

Something like this:
cargo install pommemc-client

Motivation

The user doesn't have to download and install anything or use another tool.

Activity

  1. marie-bnl commented on Nov 4, 2026

    @marie-bnl

    This discussion seems relevant: https://users.rust-lang.org/t/is-cargo-feasible-as-a-more-general-purpose-package-manager/11067/6.


    It seems unlikely to me that this could be done with reasonable effort. You'd need pyronyx to ship the Vulkan SDK which it doesn't do, and I think same thing for each other dependency that is a binding of a C library.

    Now as someone says in the discussion some -sys crates already do ship the shared libraries they depend on, maybe we could take inspiration for making a PR to pyronix. But this would have to be dealt with case-by-case on every bindings crate.


    If what you want is to build pomme-client with a single command, Nix can easily do that, managing all dependencies transparently and without installing them on your system, and has been made for the purpose. You can:

    It is very flexible too so you can easily do every middleground between these options as well (define a package but manually run its phases outside the sandbox, build the package from your local Pomme source, build the package but with your own patched dependencies...) thanks to overrides.


    It has its quirks too, Nix expects its store to be at /nix/store so you need to either (a) install it as root, (b) have shared namespaces enabled in your kernel, (c) set a different store directory at the risk of invalidating all existing caches and thus needing to build everything.

    There might be other options out there with the same purpose but not that I know of. Anyway, it seems easier to use a package manager rather than just cargo.


    EDIT: As for other similar options, Conan and other C/C++ package managers definitely look worth investigating. They're not intended at being a system-wide package manager so might not have the quirks of Nix, and we might be able to interact with them from Rust, effectively making it possible to install all dependencies and build with a single cargo command.

  2. marie-bnl commented on Nov 4, 2026

    @marie-bnl

    So I've made a conanfile.txt.

    [requires]
    dbus/1.15.8
    eudev/3.2.14
    shaderc/2026.4
    vulkan-headers/1.4.357.0
    vulkan-loader/1.4.357.0
    

    And I've run conan install. The issue is I still had to install all these libraries on my system.

    libfontenc         libxdmcp           libxv
    libice             libxext            libxxf86vm
    libsm              libxi              libxcb-util
    libx11             libxinerama        libxcb-wm
    libxau             libxkbfile         libxcb-image
    libxaw             libxpm             libxcb-keysyms
    libxcb             libxrandr          libxcb-render-util
    libxcomposite      libxres            libxcb-cursor
    libxcursor         libxscrnsaver      util-linux
    libxdamage         libxtst
    

    The reason is xorg/system depends on them and Conan only provides header files for X11 libraries, because supposedly it works better using the system's libraries and a majority of users expect their system libraries to be used. See conan-io/conan#16483

    Now these libraries might be installed by default on a lot of distros? It wasn't available right away on my side because I use NixOS but maybe it wouldn't be so much of an issue for most people.

    I does, however, make you not have to install the Vulkan SDK and shaderc.


    I've also tried vcpkg and couldn't get it to work yet but looks promising. It lacks udev but has dbus, Vulkan, shaderc, and seems to have xorg libraries. However I don't know how it could be integrated given, for example libdbus, is part of a workspace dependency and you can't have a workspace-wide build.rs (I think?).

  3. marie-bnl commented on Nov 4, 2026

    @marie-bnl

    Okay I think I've figured out what the issue exactly is.

    In order to tell pyronyx where the Vulkan SDK is, I need to set the VULKAN_SDK environment variable. However, each build.rs runs in its own process so setting an env variable there doesn't change anything, and using cargo::rustc-env only sets it for the compiler, not the build script of pyronyx.

    The same applies for other dependencies like libdbus-sys or libudev-sys, I would need to set PKG_CONFIG_PATH.

    It works if I set these in my shell session, but I can't do that from a build script, so I still need to set up my environment before running cargo build.

    The hard part is not downloading the libraries and setting the environment but communicating it to a dependency's build script from our build script.

    Again, it could work by patching the dependency but it would add a maintenance burden.


    However it should be relatively easy to add a script / support a package manager to run before cargo build that downloads all dependencies (from vcpkg?) in a directory and sets the appropriate environment variables for the native libraries to be found, without installing them system-wide.

  4. Purdze commented on Nov 4, 2026

    @Purdze
    Collaborator

    cargo install from crates.io won't happen: crates.io doesn't allow git deps or [patch], and we pin azalea by git rev and patch azalea-block. Every workspace crate would also need publishing, the SteelMC submodule included

    If you don't want to install anything, grab a release build

    For building from source, we can cut native deps instead and ship precompiled SPIR-V so shaderc and the Vulkan SDK aren't needed to build and bundle OpenAL.

    After that, cargo install --git https://github.com/PommeMC/Client pomme-client should work with just Rust on Windows/macOS. Linux still needs dbus/udev dev packages. Nix users have #868

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions