From b5be72bff79075ef4b5b51922da15e003c274b9b Mon Sep 17 00:00:00 2001
From: Ben Noordhuis <info@bnoordhuis.nl>
Date: Sun, 11 Sep 2022 09:13:45 +0200
Subject: [PATCH] Canonicalize executable path

When looking up the runtime/ directory relative to the executable path,
canonicalize the path first in case the executable is a symbolic link.

Fixes #3768
---
 helix-loader/src/lib.rs | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/helix-loader/src/lib.rs b/helix-loader/src/lib.rs
index 015b39a5..3c9905f5 100644
--- a/helix-loader/src/lib.rs
+++ b/helix-loader/src/lib.rs
@@ -42,8 +42,10 @@ pub fn runtime_dir() -> PathBuf {
     }
 
     // fallback to location of the executable being run
+    // canonicalize the path in case the executable is symlinked
     std::env::current_exe()
         .ok()
+        .and_then(|path| std::fs::canonicalize(path).ok())
         .and_then(|path| path.parent().map(|path| path.to_path_buf().join(RT_DIR)))
         .unwrap()
 }