aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/luarocks/cmd.lua13
-rw-r--r--src/luarocks/fs/unix/tools.lua5
2 files changed, 12 insertions, 6 deletions
diff --git a/src/luarocks/cmd.lua b/src/luarocks/cmd.lua
index ca22c0db..b6d0d47e 100644
--- a/src/luarocks/cmd.lua
+++ b/src/luarocks/cmd.lua
@@ -732,12 +732,15 @@ function cmd.run_command(description, commands, external_namespace, ...)
732 if cmd_mod.needs_lock and cmd_mod.needs_lock(args) then 732 if cmd_mod.needs_lock and cmd_mod.needs_lock(args) then
733 lock, err = fs.lock_access(path.root_dir(cfg.root_dir), args.force_lock) 733 lock, err = fs.lock_access(path.root_dir(cfg.root_dir), args.force_lock)
734 if not lock then 734 if not lock then
735 local try_force = args.force_lock 735 err = args.force_lock
736 and (" - failed to force the lock" .. (err and ": " .. err or "")) 736 and ("failed to force the lock" .. (err and ": " .. err or ""))
737 or " - use --force-lock to overwrite the lock" 737 or (err and err ~= "File exists")
738 and err
739 or "try --force-lock to overwrite the lock"
740
738 die("command '" .. args.command .. "' " .. 741 die("command '" .. args.command .. "' " ..
739 "requires exclusive access to " .. path.root_dir(cfg.root_dir) .. 742 "requires exclusive write access to " .. path.root_dir(cfg.root_dir) .. " - " ..
740 try_force, cmd.errorcodes.LOCK) 743 err, cmd.errorcodes.LOCK)
741 end 744 end
742 end 745 end
743 746
diff --git a/src/luarocks/fs/unix/tools.lua b/src/luarocks/fs/unix/tools.lua
index efd4d624..a0fba784 100644
--- a/src/luarocks/fs/unix/tools.lua
+++ b/src/luarocks/fs/unix/tools.lua
@@ -319,7 +319,10 @@ function tools.is_superuser()
319end 319end
320 320
321function tools.lock_access(dirname, force) 321function tools.lock_access(dirname, force)
322 fs.make_dir(dirname) 322 local ok, err = fs.make_dir(dirname)
323 if not ok then
324 return nil, err
325 end
323 326
324 local tempfile = dir.path(dirname, ".lock.tmp." .. tostring(math.random(100000000))) 327 local tempfile = dir.path(dirname, ".lock.tmp." .. tostring(math.random(100000000)))
325 328