Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save djpowell/1682601 to your computer and use it in GitHub Desktop.
Save djpowell/1682601 to your computer and use it in GitHub Desktop.
Fix lein bootstrap for Windows msysGit users
From 525365caf9635b2e0f2a06eb8993bb95febf1b20 Mon Sep 17 00:00:00 2001
From: David Powell <djpowell@djpowell.net>
Date: Thu, 26 Jan 2012 12:29:53 +0000
Subject: [PATCH] Fix shell to git for msysgit users on Windows
---
src/leiningen/git_deps.clj | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/src/leiningen/git_deps.clj b/src/leiningen/git_deps.clj
index 762eed8..0c5b9a0 100644
--- a/src/leiningen/git_deps.clj
+++ b/src/leiningen/git_deps.clj
@@ -28,11 +28,17 @@
(string/split #"\.")
butlast)))
+;; msys git on windows is on the path as a git.cmd batch file, which
+;; must be run via the command shell
+(def ^{:private true} shell-prefix
+ (when (re-matches #".*Windows.*" (System/getProperty "os.name"))
+ [(System/getenv "ComSpec") "/C"]))
+
(defn- exec
"Run a command, throwing an exception if it fails, returning the
result as with clojure.java.shell/sh."
[& args]
- (let [{:keys [exit out err] :as result} (apply sh/sh args)]
+ (let [{:keys [exit out err] :as result} (apply sh/sh (concat shell-prefix args))]
(if (zero? exit)
result
(throw
--
1.7.4
@dscho
Copy link

dscho commented Jan 26, 2012

Anything we can do to make this more convenient? I could imagine that putting the git.exe directory into the PATH instead of git.cmd should work without any changes...

@djpowell
Copy link
Author

Yeah, putting a copy of git.exe on the path, rather than the .cmd file works.
Interestingly though, if you have both git.exe and git.cmd on the path, the git.cmd file always gets used in preference, even if the exe comes earlier in the path.
Putting symlinks, created by mklink.exe, on the path rather than .cmd flies also works, but they are only available on Windows 7 and Vista.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment