Installing system Ruby should check permissions before compiling
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.
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 ....
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.