summaryrefslogtreecommitdiff
path: root/Annex
diff options
context:
space:
mode:
Diffstat (limited to 'Annex')
-rw-r--r--Annex/Path.hs25
1 files changed, 17 insertions, 8 deletions
diff --git a/Annex/Path.hs b/Annex/Path.hs
index ac4e77645..8209e5ba0 100644
--- a/Annex/Path.hs
+++ b/Annex/Path.hs
@@ -11,7 +11,9 @@ module Annex.Path where
import Common
import Config.Files
-import System.Environment
+import Utility.Env
+
+import System.Environment (getExecutablePath)
{- A fully qualified path to the currently running git-annex program.
-
@@ -19,15 +21,22 @@ import System.Environment
- well, it returns the complete path to the program. But, on other OSs,
- it might return just the basename. Fall back to reading the programFile,
- or searching for the command name in PATH.
+ -
+ - The standalone build runs git-annex via ld.so, and defeats
+ - getExecutablePath. It sets GIT_ANNEX_PROGRAMPATH to the correct path
+ - to the wrapper script to use.
-}
programPath :: IO FilePath
-programPath = do
+programPath = go =<< getEnv "GIT_ANNEX_PROGRAMPATH"
+ where
+ go (Just p) = return p
+ go Nothing = do
#if MIN_VERSION_base(4,6,0)
- exe <- getExecutablePath
- p <- if isAbsolute exe
- then return exe
- else readProgramFile
+ exe <- getExecutablePath
+ p <- if isAbsolute exe
+ then return exe
+ else readProgramFile
#else
- p <- readProgramFile
+ p <- readProgramFile
#endif
- maybe cannotFindProgram return =<< searchPath p
+ maybe cannotFindProgram return =<< searchPath p