From 12ad795500252a9ce8f09d5b68dc37e1db3cfde5 Mon Sep 17 00:00:00 2001 From: "Mads R. B. Kristensen" Date: Tue, 20 Feb 2018 10:16:19 +0100 Subject: [PATCH] Fixed #499 --- core/jitk/codegen_util.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/core/jitk/codegen_util.cpp b/core/jitk/codegen_util.cpp index 42071c5be..249b3dcf5 100644 --- a/core/jitk/codegen_util.cpp +++ b/core/jitk/codegen_util.cpp @@ -53,14 +53,22 @@ boost::filesystem::path write_source2file(const std::string &src, } boost::filesystem::path get_tmp_path(const ConfigParser &config) { - boost::filesystem::path tmp_path; + boost::filesystem::path tmp_path, unique_path; const boost::filesystem::path tmp_dir = config.defaultGet("tmp_dir", ""); if (tmp_dir.empty()) { tmp_path = boost::filesystem::temp_directory_path(); } else { tmp_path = boost::filesystem::path(tmp_dir); } - return tmp_path / boost::filesystem::unique_path("bh_%%%%"); + // On some systems `boost::filesystem::unique_path()` throws a runtime error + // when `LC_ALL` is undefined (or invalid). In this case, we set `LC_ALL=C` and try again. + try { + unique_path = boost::filesystem::unique_path("bh_%%%%"); + } catch(std::runtime_error &e) { + setenv("LC_ALL", "C", 1); // Force C locale + unique_path = boost::filesystem::unique_path("bh_%%%%"); + } + return tmp_path / unique_path; } void create_directories(const boost::filesystem::path &path) {