[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non-root "Luarocks install" should suggest --local installation #1668

Open
vadcx opened this issue Apr 25, 2024 · 2 comments
Open

Non-root "Luarocks install" should suggest --local installation #1668

vadcx opened this issue Apr 25, 2024 · 2 comments

Comments

@vadcx
Copy link
vadcx commented Apr 25, 2024

lock, err = fs.lock_access(path.root_dir(cfg.root_dir), args.force_lock)
if not lock then
err = args.force_lock
and ("failed to force the lock" .. (err and ": " .. err or ""))
or (err and err ~= "File exists")
and err
or "try --force-lock to overwrite the lock"
die("command '" .. args.command .. "' " ..
"requires exclusive write access to " .. path.root_dir(cfg.root_dir) .. " - " ..
err, cmd.errorcodes.LOCK)
end
end

user$ luarocks install busted

Error: command 'install' requires exclusive access to /usr - use --force-lock to overwrite the lock

I think it would have been better (looking at current distro, security, package manager trends) to install locally by default. I think pip, npm do it this way. #1491 doesn't inspire confidence to say the least. Failing local per-default that I expected to find a way to install locally with a command-line parameter.

luarocks --local install busted actually works, but it's not under luarocks install --help instead it's in luarocks --help global help:

   --tree <tree>         Which tree to operate on.
   --local               Use the tree in the user's home directory.
                         To enable it, see '/usr/bin/luarocks help path'.
   --global              Use the system tree when `local_by_default` is `true`.

I missed it until I went digging for this option, because I expected this option to appear in my activity scope, so to say, in luarocks install --help. Added terminology (tree) doesn't help either without RTFMing. And all I wanted was to run a package's tests...

I suggest the above error message to be extended:

  1. "Use --local if you want to install locally for your user"
  2. What is a lock anyway? I can only guess that /usr meant the system directory /usr/. It'd help here and in cases where the path was set to God-knows-where to also provide a uid/gid stat for that path (nix only):
    Error: command 'install' requires exclusive access to /usr (root:root) - use --force-lock to overwrite the lock
$ stat --format '(%U:%G)' /usr
(root:root)
@alerque
Copy link
Contributor
alerque commented Apr 26, 2024

Since we already understand that we don't have root permissions, suggesting --local and/or --tree as user level alternatives at this point actually sounds like a pretty good idea.

@hishamhm
Copy link
Member

The lines above attempt a permissions check before the lock file check:

https://github.com/luarocks/luarocks/blob/f8579e9d1019dd6e6629858c3935ffc7bca28eb0/src/luarocks/cmd.lua#L746C1-L750C1

The original intention of the code already is to suggest --local when you attempt an operation on a tree for which you have no write permissions:

https://github.com/luarocks/luarocks/blob/master/src/luarocks/fs/lua.lua#L1231-L1248

The issue here is why didn't this error trigger first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants