I'm trying to build a manifest for a Rust project, using `alpine/edge`.
To install Rust, it uses `rustup`, which installs `rustup-init` on
Alpine.
Calling it changes `$PATH` by sourcing environment variables from
`$HOME/.cargo/env` in `$HOME/.profile`.
`$HOME/.profile` doesn't seem to be read on running a task, therefore
making any tools installed by `rustup-init` unavailable, unless
specified with their full path.
Does a way around specifying the full path to the executable every time,
manually or with an environment variable in the build manifest, exist?
I'd like to avoid this.
If all fails, I've seen other projects on sr.ht use the `archlinux`
image instead, where it seems to be very straight forward.
Thanks.
--
witcher
https://wiredspace.de
witcher@wiredspace.de writes:
> I'm trying to build a manifest for a Rust project, using `alpine/edge`.> To install Rust, it uses `rustup`, which installs `rustup-init` on> Alpine.
What is rustup-init? I also installed rust using rustup on my machine
but don't have something called rustup-init...
> Calling it changes `$PATH` by sourcing environment variables from> `$HOME/.cargo/env` in `$HOME/.profile`.> `$HOME/.profile` doesn't seem to be read on running a task, therefore> making any tools installed by `rustup-init` unavailable, unless> specified with their full path.
Couldn't you put a "source ~/.profile" into the rc file of the shell
used by default on that image? Or just run that command as first step
of the build?
> If all fails, I've seen other projects on sr.ht use the `archlinux`> image instead, where it seems to be very straight forward.
Yes, that's what I'm using, too. My manifests are just like this:
--8<---------------cut here---------------start------------->8---
image: archlinux
packages:
- rust
sources:
- https://git.sr.ht/...
tasks:
- build: |
cd foobar
cargo build
cargo test
cargo clippy
--8<---------------cut here---------------end--------------->8---
Bye,
Tassilo
On Wed, 04 May 2022 20:53 +0200, witcher@wiredspace.de wrote:
>I'm trying to build a manifest for a Rust project, using `alpine/edge`.>To install Rust, it uses `rustup`, which installs `rustup-init` on>Alpine.>Calling it changes `$PATH` by sourcing environment variables from>`$HOME/.cargo/env` in `$HOME/.profile`.>`$HOME/.profile` doesn't seem to be read on running a task, therefore>making any tools installed by `rustup-init` unavailable, unless>specified with their full path.>>Does a way around specifying the full path to the executable every time,>manually or with an environment variable in the build manifest, exist?>I'd like to avoid this.
See the section in the docs about the build environment:
https://man.sr.ht/builds.sr.ht/#build-environment
You can modify the .buildenv file, which is sourced at the beginning of
each task. So in the task that runs rustup, simply add
echo '. $HOME/.cargo/env' >> ~/.buildenv
Then before each subsequent task, that file will be sourced and your
PATH variable should be modified accordingly.
A simpler, but less flexible approach, is to simply modify your
environment to use whatever PATH you want: https://man.sr.ht/builds.sr.ht/manifest.md#environment