From a027595f718c6b05a8fbd4feae1605bff3fed5b9 Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Tue, 24 Mar 2015 00:16:33 -0300 Subject: Let's try harder to fail if CWD does not exist. --- src/luarocks/command_line.lua | 4 ++-- src/luarocks/fs/lua.lua | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/luarocks/command_line.lua b/src/luarocks/command_line.lua index 9cc34c42..4ff22c6e 100644 --- a/src/luarocks/command_line.lua +++ b/src/luarocks/command_line.lua @@ -192,8 +192,8 @@ function command_line.run_command(...) cfg.variables[k] = v end end - - if not fs.exists(".") then + + if not fs.current_dir() then die("Current directory does not exist. Please run LuaRocks from an existing directory.") end diff --git a/src/luarocks/fs/lua.lua b/src/luarocks/fs/lua.lua index b3d3f6f1..c3f92bda 100644 --- a/src/luarocks/fs/lua.lua +++ b/src/luarocks/fs/lua.lua @@ -207,8 +207,13 @@ end -- Allows leaving a directory (e.g. for deleting it) in -- a crossplatform way. function fs_lua.change_dir_to_root() - table.insert(dir_stack, lfs.currentdir()) + local current = lfs.currentdir() + if not current then + return false + end + table.insert(dir_stack, current) lfs.chdir("/") -- works on Windows too + return true end --- Change working directory to the previous in the dir stack. -- cgit v1.2.3-55-g6feb