Chris Hofstaedtler <z...@debian.org> writes:

>>podman run -it --rm debian:trixie
>>apt-get update
>>apt-get install -y --no-install-recommends gradle
>>PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
>>gradle
>>/bin/gradle: 23: cd: can't cd to /bin/../share/gradle/bin/..
>
> I'll point out that this is not even trying to build a Debian package,
> so the typical Debian package build environment would be irrelevant
> here.

Right, I was just giving a way to reproduce the problem.  Packages that
rely on 'gradle' during build will fail with that error message too,
when built with a PATH that has /bin before /usr/bin.

>>The problem seems that it is generating a relative path to its own
>>command expanded via PATH, which doesn't work because there is no /share
>>symlink but there is /usr/share/.
>>
>>Is this a problem in 'gradle' (and other packages) that should be
>>reported and fixed?
> IMO yes, see below.
>
>> What severity?
>
> normal?

Thanks -- I opened
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1104784

>>What can packages assume about PATH?  What can packages not assume?  In
>>particular wrt ordering.  Are there written down rules for this?
>
> Probably in POSIX. Per my understanding PATH is defined to be used in
> a specific algorithm, which is basically "stat the name of the
> executable you are looking for in these directories, in the given
> order". Everything else is probably unspecified, and deriving file
> system paths that are not actually given in PATH is undefined
> behaviour, and can just break.

I think there could be a Debian policy that says that packages MUST NOT
assume anything about PATH except that it should somewhere include
/usr/bin (and maybe also /usr/games) during build.  It seems common in
Debian to add /*/sbin too, but when building as non-root, I don't think
/*/sbin should be part of PATH and packages shouldn't assume this.

> If a program needs to know a path to supporting files, this path
> should be known at build time of that program (here: gradle), and then
> be baked into it (and maybe also be configurable at runtime).

Agreed.

/Simon

Attachment: signature.asc
Description: PGP signature

Reply via email to