Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run apt-get update before trying to install clang #622

Merged
merged 1 commit into from
May 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 35 additions & 24 deletions crates/arroyo-compiler-service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,38 +168,19 @@ impl CompileService {
}
}

async fn check_cc(&self) -> anyhow::Result<()> {
if binary_present("cc").await {
return Ok(());
}

if !bool_config(INSTALL_CLANG_ENV, false) {
let error = "UDF compilation requires clang or gcc to be available. Ensure you have a \
working C compilation environment.";
error!("{}", error);
bail!("{}", error);
}

info!(
"cc is not available, but required for UDF compilation. Attempting to install clang."
);
async fn run_command(action: &str, command: &mut Command) -> anyhow::Result<()> {
let output = timeout(
Duration::from_secs(2 * 60),
Command::new("apt-get")
.arg("-y")
.arg("install")
.arg("clang")
command
.stdout(Stdio::inherit())
.stderr(Stdio::inherit())
.output(),
)
.await
.map_err(|e| anyhow!("Timed out while installing clang for UDF compilation after {e}"))?
.map_err(|e| anyhow!("Failed to install clang via apt-get: {e}"))?;
.map_err(|e| anyhow!("Timed out while {action} for UDF compilation after {e}"))?
.map_err(|e| anyhow!("Failed while {action} via apt-get: {e}"))?;

if output.status.success() {
info!("clang successfully installed...");
} else {
if !output.status.success() {
error!(
"Failed to install clang, will not be able to compile UDFs\
\n------------------------------\
Expand All @@ -215,6 +196,36 @@ impl CompileService {

Ok(())
}

async fn check_cc(&self) -> anyhow::Result<()> {
if binary_present("cc").await {
return Ok(());
}

if !bool_config(INSTALL_CLANG_ENV, false) {
let error = "UDF compilation requires clang or gcc to be available. Ensure you have a \
working C compilation environment.";
error!("{}", error);
bail!("{}", error);
}

info!(
"cc is not available, but required for UDF compilation. Attempting to install clang."
);

Self::run_command("updating apt", Command::new("apt-get").arg("update")).await?;

Self::run_command(
"installing clang",
Command::new("apt-get")
.arg("-y")
.arg("install")
.arg("clang"),
)
.await?;

Ok(())
}
}

fn dylib_path(name: &str, definition: &str) -> String {
Expand Down
Loading