tcdi/plrust

Verification failure - No such file or directory

Closed this issue · 2 comments

After following the install process I'm getting a panic on every attempt to create a function (backtrace below)

Screenshot 2023-07-31 at 1 29 52 PM

I can see the functions being written in the work dir
Screenshot 2023-07-31 at 1 31 25 PM

and can cargo build them as the postgres user

System:

  • arm64
  • ubuntu 20.04
  • postgres 15.1

Any ideas what might be going on here? Happy to run any tests that would provide more info. Thanks!

@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

/// `cargo` needs a PATH in order to find its tools and we have some rules about setting that up...

it was a path issue. After setting the path manually its passing that point

thanks for the help!