diff --git a/src/cmd/flux.c b/src/cmd/flux.c index 1af6c6ac6417..3e19b90ed628 100644 --- a/src/cmd/flux.c +++ b/src/cmd/flux.c @@ -87,7 +87,7 @@ static void usage (void) ); } -int setup_lua_env (const char *exedir) +int setup_lua_env (const char *topdir) { char *s; @@ -96,9 +96,9 @@ int setup_lua_env (const char *exedir) * paths configurable on installation. */ s = getenv ("LUA_CPATH"); - setenvf ("LUA_CPATH", 1, "%s/../bindings/lua/.libs/?.so;%s", exedir, s ? s : ";;"); + setenvf ("LUA_CPATH", 1, "%s/src/bindings/lua/.libs/?.so;%s", topdir, s ? s : ";;"); s = getenv ("LUA_PATH"); - setenvf ("LUA_PATH", 1, "%s/../bindings/lua/?.lua;%s", exedir, s ? s : ";;"); + setenvf ("LUA_PATH", 1, "%s/src/bindings/lua/?.lua;%s", topdir, s ? s : ";;"); return (0); } @@ -108,10 +108,14 @@ int main (int argc, char *argv[]) bool hopt = false; bool vopt = false; char *flux_exe_dir = dir_self (); + char *flux_top_builddir = getenv ("FLUX_TOP_BUILDDIR"); log_init ("flux"); - setup_lua_env (flux_exe_dir); + if (!flux_top_builddir && strcmp (flux_exe_dir, X_BINDIR) != 0) + flux_top_builddir = "../.."; + + setup_lua_env (flux_top_builddir); while ((ch = getopt_long (argc, argv, OPTIONS, longopts, NULL)) != -1) { switch (ch) { @@ -149,10 +153,6 @@ int main (int argc, char *argv[]) argc -= optind; argv += optind; - /* We are executing 'flux' from a path that is not the installed path. - * Presume we are in $top_builddir/src/cmd and set up environment - * accordingly. - */ if (strcmp (flux_exe_dir, X_BINDIR) != 0) { glob_t gl; char *modpath;