ruby-install icon indicating copy to clipboard operation
ruby-install copied to clipboard

Installing system Ruby should check permissions before compiling

Open rennex opened this issue 8 years ago • 2 comments

I used ruby-install --system --latest ruby, and after some minutes of compilation, it failed:

Permission denied @ rb_sysopen - /usr/local/share/man/man1/ruby.1 (Errno::EACCES)

Without digging too deep, I assume this happened because I didn't use sudo. Running the command again with sudo succeeded, but it meant downloading the tarball again and waiting for the recompilation. Maybe there was a way to resume the previous attempt, but finding that out from docs would've taken longer :)

So I would suggest checking in the beginning if sudo will be needed and hasn't been used, before spending time doing lots of work. Or alternatively, let the user enter their password into sudo when that's needed.

rennex avatar Oct 16 '18 22:10 rennex

Going to close since I couldn't come up with a solution that covers all edge cases (ex: ruby-install --install-dir /usr/local, ruby-install --install-dir /some/other/dir, or when /usr/local is writable by a special user group that the user belongs to or a file-system ACL, etc). Even if I wrote a function which checks if each parent directory is writable, that could still be fooled by symlinks. Plus, ruby-build does check permissions before compiling either. I ended up just changing the example in the README to be sudo ruby-install --system ....

postmodern avatar Feb 01 '25 09:02 postmodern

Ended up adding a basic permissions check that recursively tests the installation directory's parent directories for writability (see eeb4575). This will catch when you run ruby-install --system without sudo. This will be released in 0.10.0.

postmodern avatar Feb 02 '25 07:02 postmodern