Note: to make this question more concrete I will use the installation of the rustc package as an example. Nonetheless, the question is intended to apply to packages in general.

I am on a system using Debian Stable. I want to install the rustc package from the Unstable distribution (it does not exist in Stable, for now). I add the Unstable sources to my /etc/apt/sources.list file

# Unstable
deb http://ftp.debian.org/debian unstable main contrib non-free
deb-src http://ftp.debian.org/debian unstable main contrib non-free

and run apt update, followed by apt install rustc. APT refuses to install because of dependency problems, as expected.

The following packages have unmet dependencies:
 rustc : Depends: libstd-rust-dev (= 1.12.0+dfsg1-1) but it is not going to be installed
         Depends: binutils (>= 2.26) but 2.25-5 is to be installed
         Recommends: rust-gdb but it is not going to be installed or
                     rust-lldb but it is not going to be installed

The only means that occurs to me of installing the package in the repositories is to build it from source. I read this page on Debian wiki, which suggests that a package from Unstable can be build with this procedure:

  1. add a deb-src line for sid to your sources.list
  2. apt-get update
  3. apt-get build-dep PACKAGE_NAME
  4. apt-get -b source PACKAGE_NAME

But step 3. fails with unmet dependencies.

So my question is if it is possible to build packages from Unstable and installing them in a Stable system. If so, how would it be done? I imagine there must be a way to build/download all dependencies and incorporate them in the final binaries of the package I want. And then install that package.

  • You could also consider upgrading all packages from stable to unstable that rustc needs. Use aptitude for a GUI that shows you what packages are involved.
    – dirkt
    Oct 7, 2016 at 9:43
  • And if you always want the newest rust version, compiling rust from source (not the debian package, upstream source) directly and installing it into /usr/local instead of fighting dependency hell might be easier.
    – dirkt
    Oct 7, 2016 at 9:44

2 Answers 2


First of all, adding unstable to a stable system as you did is a really bad idea: the distribution tools will consider unstable packages as valid upgrade targets, and even if you're careful, you'll typically end up needing to upgrade a widely-used library, and you'll end up with most of your packages tracking unstable in short order. (Use pinning if you really have to.)

Regarding your question, in general it is possible to build an unstable source package in stable, following the procedure you link to. As you indicate, this may well involve back-porting dependencies, or adapting the source package so it can be built in stable. If the apt-get build-dep step fails, this is the reason: some of the unstable source package's build-dependencies can't be satisfied in stable. You need to repeat this process until you've back-ported everything required, installing the generated packages as you go. For popular packages, it's worth filing a bug to ask for an official backport.

Note that when apt-get build-dep fails, you'll need to install the build-dependencies manually. dpkg-buildpackage will tell you what's missing, which is useful if you're back-porting build-dependencies: as you add back-ported build-dependencies, the list of missing packages reported by dpkg-buildpackage will shrink, and when it stops complaining you know you're done. This also takes into account any changes you make to the build-dependencies in debian/control (which apt-get build-dep won't).

For rustc things are a lot more complicated: rustc needs itself to build, so it needs to be "bootstrapped". This was done a few months ago in unstable, with the collaboration of the FTP masters; it's not something that's easy to replicate in a clean fashion in a stable system.

So to actually get rustc installed on a stable system, here's how I'd go about it...

  1. Back-port binutils (with DEB_BUILD_OPTIONS=nocross,nomult,nogold to avoid building the cross-toolchain, and gold which can't be built with Jessie's g++).
  2. Install libllvm3.8 from Jessie backports.
  3. Install libstd-rust-dev, libstd-rust-1.12 and rustc from unstable.
  • yep, much better with the link and explanation.
    – ilkkachu
    Oct 7, 2016 at 12:30
  • I was trying to follow your steps, but building binutils from unstable failed some hours into compilation... Oct 9, 2016 at 0:28
  • Building with DEB_BUILD_OPTIONS=nocross,nomult,nogold in the environment (so DEB_BUILD_OPTIONS=nocross,nomult,nogold dpkg-buildpackage -us -uc for example) works for me and produces a package quite quickly. Oct 9, 2016 at 15:06
  • Thank you. It compiled successfully with DEB_BUILD_OPTIONS='nocross nomult nogold' dpkg-buildpackage -us -uc. Oct 9, 2016 at 18:37

I read your note, but just in case you actually wanted rustc, you can try installing the testing/stretch version: https://packages.debian.org/stretch/rustc

Testing/stretch is not as new as unstable, but it's definitely newer than stable.

You could try getting the source with apt-get source and modify the ./debian/control file to not require specific versions, but I'm not sure it'll be able to build. Also, it's easier for me to just sudo dpkg-buildpackage -B -us -uc instead of the other methods listed on that wiki.

  • Thank you for your answer. I saw rustc is also available in stretch. But trying to install it still results in dependency problems. Oct 7, 2016 at 9:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .