{"record":{"id":"9c181163af06bfdf","repo":"pola-rs/polars","slug":"cargo-manifest-dir-not-set","errorCode":null,"errorMessage":"CARGO_MANIFEST_DIR not set","messagePattern":"CARGO_MANIFEST_DIR not set","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/polars-arrow/src/io/ipc/read/flight.rs","lineNumber":417,"sourceCode":"            if option_recordbatch.is_some() {\n                return Ok(option_recordbatch);\n            }\n        }\n        Ok(None)\n    }\n}\n\n#[cfg(test)]\nmod test {\n    use std::path::{Path, PathBuf};\n\n    use tokio::fs::File;\n\n    use super::*;\n    use crate::record_batch::RecordBatch;\n\n    fn get_file_path() -> PathBuf {\n        let polars_arrow = std::env::var(\"CARGO_MANIFEST_DIR\").expect(\"CARGO_MANIFEST_DIR not set\");\n        Path::new(&polars_arrow).join(\"../../py-polars/tests/unit/io/files/foods1.ipc\")\n    }\n\n    fn read_file(path: &Path) -> RecordBatch {\n        let mut file = std::fs::File::open(path).unwrap();\n        let md = crate::io::ipc::read::read_file_metadata(&mut file).unwrap();\n        let mut ipc_reader = crate::io::ipc::read::FileReader::new(&mut file, md, None, None);\n        ipc_reader.next().unwrap().unwrap()\n    }\n\n    #[tokio::test]\n    async fn test_file_flight_simple() {\n        let path = &get_file_path();\n        let mut file = tokio::fs::File::open(path).await.unwrap();\n        let stream = into_flight_stream(&mut file).await.unwrap();\n\n        let mut c = FlightstreamConsumer::new(Box::pin(stream)).await.unwrap();\n        let b = c.next_batch().await.unwrap().unwrap();","sourceCodeStart":399,"sourceCodeEnd":435,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/crates/polars-arrow/src/io/ipc/read/flight.rs#L399-L435","documentation":"The test helper get_file_path panics via expect() because the CARGO_MANIFEST_DIR environment variable is not set. This variable is set by cargo during `cargo test` but is absent when tests run through other harnesses or environments. It is used to locate the sample foods1.ipc file relative to the crate.","triggerScenarios":"Running the polars-arrow IPC tests (test_file_flight_simple, test_file_flight_amortized) outside of a cargo-managed invocation, e.g. via a custom test runner, IDE debugger, or a stripped environment where std::env::var(\"CARGO_MANIFEST_DIR\") returns Err.","commonSituations":"Running tests through tools that sanitize env vars (docker with minimal env, `env -i`), executing the compiled test binary directly instead of `cargo test`, or CI systems that invoke the test executable without cargo.","solutions":["Run the tests via `cargo test -p polars-arrow` so cargo sets CARGO_MANIFEST_DIR automatically.","If invoking the binary directly, export CARGO_MANIFEST_DIR=<path to crates/polars-arrow> before running.","Replace the env lookup in the test with a compile-time path such as env!(\"CARGO_MANIFEST_DIR\") or an absolute path fixture."],"exampleFix":"// before\nlet polars_arrow = std::env::var(\"CARGO_MANIFEST_DIR\").expect(\"CARGO_MANIFEST_DIR not set\");\n// after\nlet polars_arrow = env!(\"CARGO_MANIFEST_DIR\");","handlingStrategy":"validation","validationCode":"if std::env::var(\"CARGO_MANIFEST_DIR\").is_err() {\n    panic!(\"Run tests via `cargo test` or set CARGO_MANIFEST_DIR to the polars-arrow crate path\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always run crate tests with `cargo test`, never the raw test binary","Set required env vars explicitly in CI before invoking test harnesses","Prefer env!() (compile-time) over runtime env lookups for test fixtures"],"tags":["rust","testing","environment-variables"],"backgroundTag":"missing-env-var","analyzedSha":"fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e","analyzedAt":"2026-09-18T22:14:11.667Z","contentChangedAt":"2026-09-18T22:14:11.667Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}