Closed olirice closed 1 year ago
@olirice, I think that's saying the process can't find cargo
.
And "the process" would be the connected Postgres backend. PL/Rust will expect Rust to be installed by the postgres
user (or whomever the postgres server runs as) and will look in ~/.cargo/bin
.
The ubuntu systemd scripts for Postgres completely sanitize the environment before starting Postgres -- there's not even a PATH
.
The logic for figuring this out is:
/// `cargo` needs a PATH in order to find its tools and we have some rules about setting that up...
///
/// If the `plrust.PATH_override` GUC is set, we just blindly use it. Otherwise, if PATH is set,
/// we'll use that. Otherwise we'll create one of `~/.cargo/bin:/usr/bin` and hope it's good enough.
fn configure_path(command: &mut Command) -> eyre::Result<()> {
if let Some(path) = PLRUST_PATH_OVERRIDE.get() {
// we were configured with an explicit $PATH to use
command.env("PATH", path);
} else {
let is_empty = match std::env::var("PATH") {
Ok(s) if s.trim().is_empty() => true,
Ok(_) => false,
Err(VarError::NotPresent) => true,
Err(e) => return Err(eyre::eyre!(e)),
};
if is_empty {
// the environment has no $PATH, so lets try and make a good one based on where
// we'd expect 'cargo' to be installed
if let Ok(path) = home::cargo_home() {
let path = path.join("bin");
command.env(
"PATH",
std::env::join_paths(vec![path.as_path(), std::path::Path::new("/usr/bin")])?,
);
} else {
// we don't have a home directory... where could cargo be? Ubuntu installed cargo
// at least puts it in /usr/bin
command.env("PATH", "/usr/bin");
}
}
}
Ok(())
}
EDIT: That comes from https://github.com/tcdi/plrust/blob/29b7643ee3f2c5534b25d667fee824619a6fc9f6/plrust/src/user_crate/cargo.rs#L43
it was a path issue. After setting the path manually its passing that point
thanks for the help!
After following the install process I'm getting a panic on every attempt to create a function (backtrace below)
I can see the functions being written in the work dir
and can
cargo build
them as thepostgres
userSystem:
Any ideas what might be going on here? Happy to run any tests that would provide more info. Thanks!