~sircmpwn/sr.ht-discuss

4 2

[builds.sr.ht] different PATH for build and ssh session

Details
Message ID
<738b288c-be49-4bdb-af3d-bc05eaa33d52@www.fastmail.com>
DKIM signature
missing
Download raw message
I have a build running on alpine/latest.

When I echo $PATH from the build manifest, it outputs:
/bin:/usr/bin:/sbin:/usr/sbin

However if I log into the vm (after a build failure for instance) and run echo $PATH, I get:
/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/sbin:/usr/local/bin

---

I don't know if this behavior is intended, or specific to the alpine image.

---

In my case, I am building a software from source and running `sudo make install`

The command could not be found by the builder,
but it worked just fine when logging via ssh (since the software was installed in /usr/local/bin).
https://builds.sr.ht/~oliverpool/job/574101
Details
Message ID
<CE08D2HXA33P.RTUCKWNL5279@taiga>
In-Reply-To
<738b288c-be49-4bdb-af3d-bc05eaa33d52@www.fastmail.com> (view parent)
DKIM signature
fail
Download raw message
DKIM signature: fail
The SSH session starts a login shell, the build scripts do not.
Details
Message ID
<526b512a-c448-495f-bfdd-fbbd632dbd70@www.fastmail.com>
In-Reply-To
<CE08D2HXA33P.RTUCKWNL5279@taiga> (view parent)
DKIM signature
missing
Download raw message
Thanks for the explanation.

As a newbie, I think it would be a usability improvement to fix this.
But I have no idea, what the preferred solution would be:
- recommend installation of software in /usr/bin (instead of /usr/local/bin)
by running `sudo make PREFIX="/usr" install` in the official builds.sr.ht docs
- adjust the PATH of the build scripts to add /usr/local/bin (like it is done in /etc/profile)
- adjust the PATH of the login shell, to remove /usr/local/bin
- document this subtle difference on the official builds.sr.ht doc

I currently use the first solution.
Should I send a patch to the builds doc? 
In https://man.sr.ht/builds.sr.ht/manifest.md#tasks

> The $PATH in the build scripts may differ from the login shell, hence you may
> need to adjust the install directory if you intend to install and new command.
Details
Message ID
<CE09CNZ7Z7DQ.1QC44MOS3WOYR@taiga>
In-Reply-To
<526b512a-c448-495f-bfdd-fbbd632dbd70@www.fastmail.com> (view parent)
DKIM signature
fail
Download raw message
DKIM signature: fail
On Fri Sep 3, 2021 at 2:39 PM CEST, Olivier C wrote:
> Thanks for the explanation.
>
> As a newbie, I think it would be a usability improvement to fix this.

It is not a bug. It's just how Unix works.

> But I have no idea, what the preferred solution would be:

You should just source /etc/profile in your build script, perhaps?

. /etc/profile
Details
Message ID
<c3921ca7-dff6-4778-9575-7c7d05b0dfa7@www.fastmail.com>
In-Reply-To
<CE09CNZ7Z7DQ.1QC44MOS3WOYR@taiga> (view parent)
DKIM signature
missing
Download raw message
> > As a newbie, I think it would be a usability improvement to fix this.
> 
> It is not a bug. It's just how Unix works.

I am just a software developer, not a Unix expert. I don't mean that there
is a bug in Unix. I just want to show that using builds.sr.ht is not as simple
as it could be and I want to help make it a bit easier to use for other users.

> You should just source /etc/profile in your build script, perhaps?
> 
> . /etc/profile

Thanks, this is much better to have a consistent behavior between building
and ssh-debugging.

Thinking about it, it might suffice to add an hint in the build-ssh documentation:
https://man.sr.ht/builds.sr.ht/build-ssh.md

> Beware that the login shell may have additional startup scripts, compared to the build script (sourcing /etc/profile for $PATH for instance).
Reply to thread Export thread (mbox)