1

I am trying to package my Rust application for Debian but I encounter some issues. I try to build with

debuild -us -uc

but it gives the error

Running "rustc --version" gave "[Errno 2] No such file or directory: 'rustc': 'rustc'"

From the command cd debian/build && meson --prefix=/usr ../.. But when try to run it manually it doesn't give any errors. Why can't it see rustc?

Aiono
  • 133
  • 4

1 Answers1

1

debuild intentionally sanitizes the environment for security reasons, according to the manual page:

As environment variables can affect the building of a package, often unintentionally, debuild sanitises the environment by removing all environment variables except for TERM, HOME, LOGNAME, GNUPGHOME, PGPPATH, GPG_AGENT_INFO, GPG_TTY, DBUS_SESSION_BUS_ADDRESS, FAKEROOTKEY, DEBEMAIL, DEB_*, the (C, CPP, CXX, LD and F)FLAGS variables and their _APPEND counterparts and the locale variables LANG and LC_*. TERM is set to dumb if it is unset, and PATH is set to /usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11.

In general, you should not build a Debian package using software that is not also a Debian package because it's impossible to produce a reproducible build and for others to build the package outside of your environment. Therefore, the best solution is to use the Debian rustc package, use a newer version from Debian unstable, or build a newer rustc if you require one. If you are sure that you really want to do this anyway and thoroughly understand the consequences, there are configuration options to adjust the PATH environment variable.

bk2204
  • 3,571
  • 5
  • 9
  • That makes sense. But if I want to only publish the binary package, I don't see any reason for this. – Aiono Jan 23 '21 at 09:30
  • TBH, if you don’t care about build dependencies, and you want to use compilers which aren’t packaged, it sounds like you’d be better off using `dpkg-deb -b` rather than trying to start with a source package. – Stephen Kitt Jan 25 '21 at 08:20