ldconfig breaks when installing as user without permissions on `/etc/ld.so.cache`
- Dominant language
- Shell
- Stars
- 651
- Forks
- 35
- PR merge metrics
- No merged PRs in 30d
Description
If the user running multirust does not have write permissions on `/etc/ld.so.cache`, multirust will fail to run `ldconfig` with an error (in verbose mode) like
```
install: running ldconfig
/sbin/ldconfig.real: Can't create temporary cache file /etc/ld.so.cache~: Permission denied
install: WARNING: failed to run ldconfig. this may happen when not installing as root. run with --verbose to see the error
```
I assume that all non-root users trying to install Multirust will be using a custom prefix, though not all installations with a custom prefix are missing permissions in `/etc/` in the way that'll cause this error.
Changing the ldconfig command in `maybe_configure_ld()` in the output installation script to
```
if [ -n "${CFG_VERBOSE-}" ]; then
ldconfig -C $CFG_DESTDIR_PREFIX/ld.so.cache
```
makes it run successfully for me. I checked the [ld.so](http://man7.org/linux/man-pages/man8/ld.so.8.html) and [ldconfig](http://linux.die.net/man/8/ldconfig) man pages and didn't find any environment variables that can be used to override the default cache location.
Should we...
1) add a --ldconfig-cache option that'll always override the ldconfig cache location when present?
2) add a `--no-root` option that sets the ldconfig cache to somewhere local? (either in the `CFG_DESTDIR` or the current directory of the install script seem like safe bets)
3) default to setting the cache somewhere we know is writable whenever there's a custom destination directory set?
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in maybe_configure_ld() and inspect how the output installation script invokes ldconfig. Reproduce the custom-prefix install without write permission to /etc/ld.so.cache, then evaluate the proposed cache-location options. Done means a non-root custom-prefix installation no longer fails when ldconfig cannot write the system cache.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- shell
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100