From 9b1a2fc7473eeb268afe55b4bda770531c22a013 Mon Sep 17 00:00:00 2001 From: Andres Suarez Date: Thu, 23 Mar 2023 04:46:44 -0700 Subject: [PATCH] Panic with clear message when tonic_build OUT env is not set Summary: I was sloppy in D44322620 and: 1. Used `std::env::var` instead of `std::env::var_os`. The former does `OsString` to `String` conversion, which we don't care about because `.out_dir` expects `AsRef`. 2. Used `.unwrap` without including a message as to what expectation is being violated. In D44324686 I was sloppy by leaving a needless borrow. Reviewed By: yuyashiraki Differential Revision: D44324930 fbshipit-source-id: f5b0152793d8537c70398ed83402fb6301b72f16 --- protocol-rpc/build.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/protocol-rpc/build.rs b/protocol-rpc/build.rs index 9a3f012..e938490 100644 --- a/protocol-rpc/build.rs +++ b/protocol-rpc/build.rs @@ -13,10 +13,10 @@ fn main() -> Result<(), Box> { "suidcreate.proto", ]; let out_env = if cfg!(fbcode_build) { "OUT" } else { "OUT_DIR" }; - let out_dir = std::env::var_os(out_env).unwrap_or_else(|| panic!("env `{out_env}` not set")); + let out_dir = std::env::var_os(out_env).unwrap_or_else(|| panic!("env `{out_env}` is not set")); tonic_build::configure() - .out_dir(&out_dir) + .out_dir(out_dir) .compile( proto_files, // HACK: we need '.' directory for build with Buck