From bd7c95771edbb6af0129b65a12600fe2800671aa Mon Sep 17 00:00:00 2001
From: Jonathan Wilkes <jon.w.wilkes@gmail.com>
Date: Fri, 4 Dec 2015 18:30:16 -0500
Subject: [PATCH] fall back to HOME environment variable for pwd if PWD doesn't
 exist

---
 pd/nw/index.js | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/pd/nw/index.js b/pd/nw/index.js
index f6b8ecff8..5e306c6c5 100644
--- a/pd/nw/index.js
+++ b/pd/nw/index.js
@@ -3,8 +3,10 @@ var gui = require("nw.gui");
 var pdgui = require("./pdgui.js");
 var pd_menus = require("./pd_menus.js");
 
-// we're using pwd in fileDialog
-var pwd = process.env.PWD;
+// we're using pwd in fileDialog. If you start Pd by clicking the app bundle
+// in OSX, the PWD environment variable doesn't exist. In that case we use
+// HOME instead.
+var pwd = process.env.PWD !== undefined ? process.env.PWD : process.env.HOME;
 
 // gui preset
 pdgui.skin.apply(this);
-- 
GitLab