diff --git a/pd/nw/dialog_search.html b/pd/nw/dialog_search.html
index 28c9bf4703603103de52ceaf335baa38dde11e1d..b89fd90a5f2ebfeec191588c667e1e01702d447e 100644
--- a/pd/nw/dialog_search.html
+++ b/pd/nw/dialog_search.html
@@ -91,7 +91,7 @@ function finish_build() {
 }
 
 function build_index() {
-    var doc_path = path.join(pdgui.get_gui_dir(), "doc");
+    var doc_path = path.join(pdgui.get_lib_dir(), "doc");
     pdgui.post("doc path is " + doc_path);
     dive(doc_path, read_file, finish_build);
 }
diff --git a/pd/nw/pdgui.js b/pd/nw/pdgui.js
index f4e723a62d9264697e6529be0a911b26260b2876..6d4a393ebdaab44f216984cb9059c5c6a3b63526 100644
--- a/pd/nw/pdgui.js
+++ b/pd/nw/pdgui.js
@@ -2,6 +2,7 @@
 
 var pwd;
 var gui_dir;
+var lib_dir;
 var last_clipboard_data;
 
 exports.set_pwd = function(pwd_string) {
@@ -20,6 +21,14 @@ exports.get_gui_dir = function() {
     return gui_dir;
 }
 
+function gui_set_lib_dir(dir) {
+    lib_dir = dir;
+}
+
+exports.get_lib_dir = function() {
+    return lib_dir;
+}
+
 exports.get_pd_opendir = function() {
     if (pd_opendir) {
         return pd_opendir;
diff --git a/pd/src/s_main.c b/pd/src/s_main.c
index 295270d32db50205e8773733f1531d189e3fed99..31cc2ee8e9bf003427351e750692f844c4e23842 100644
--- a/pd/src/s_main.c
+++ b/pd/src/s_main.c
@@ -298,8 +298,8 @@ int sys_main(int argc, char **argv)
         return (0);
     if (sys_startgui(sys_guidir->s_name))       /* start the gui */
         return(1);
-        /* check if we are unique, otherwise, just focus existing
-        instance, and if necessary open file inside it */\
+        /* send the libdir to the GUI */
+    gui_vmess("gui_set_lib_dir", "s", sys_libdir->s_name);
     if (sys_openlist)
     {
         // send the files to be opened to the GUI. We send them one
@@ -311,6 +311,10 @@ int sys_main(int argc, char **argv)
             gui_vmess("gui_build_filelist", "s", nl->nl_string);
         }
     }
+        /* check if we are unique, otherwise, just focus existing
+           instance, and if necessary open file inside it. This doesn't
+           yet work with the new GUI because we need to set it up to
+           allow multiple instances. */
     gui_vmess("gui_check_unique", "i", sys_unique);
     if (sys_externalschedlib)
         return (sys_run_scheduler(sys_externalschedlibname,