I want to install Git locally to a user on a RHEL server (I don't have root access) What would be your cleanest/ most organized way of installing software to a local user account?

  • Installing everything in that users home directory?
  • What would the directory layout look like?
  • Would you install from source or RPM?
  • If from RPM would you use YUM or RPM?

There are ways to install rpms in a user directory using rpm, but I don't believe it is straight-forward. I don't believe there is a way with yum.

My standard practice has become to compile from source to a local directory in my home

$ mkdir ~/local
$ mkdir ~/local/bin
$ mkdir ~/local/lib
$ mkdir ~/local/include

I download source as I would to /usr/local when I have root, e.g., in ~/local/git.

When compiling I set the prefix to the local directory

$ configure --prefix=/home/user_name/local
$ make
$ make install

I then add ~/local/bin to my $PATH in .bash_profile.

Of course, the pain with installing from source is that you don't get automatic dependency resolution. If you find that you need to install dependencies, compile and install them as above. Then when you compile git, you need to update the compile flags so they look in the correct location for the dependency's libraries and include files:

./configure --prefix=/home/user_name/local LDFLAG='-L/home/user_name/local/lib' CFLAGS='-I/home/user_name/local/include' CPPFLAGS='-I/home/user_name/local/include' CXXFLAGS='-I/home/user_name/local/include'
| improve this answer | |
  • This worked perfectly, thanks for the advice! – wiredin Apr 25 '13 at 20:15

An .rpm file is actually a form of cpio archive, which is a lot like a simple form of tar. The rpm2cpio utility is probably installed on the system and does not require privileges to use; it writes to standard out, so to convert:

rpm2cpio whatever.rpm > whatever.cpio

There's a man cpio you can look at yourself, but what you now want to do is feed the archive to cpio in "copy in" mode:

cat whatever.cpio | cpio -i

Very likely the stuff is organized into a directory tree so that files go into appropriate locations (bin, etc, etc.). If those don't exist in your pwd, you'll get an error, but that will list the files in the archive (you can get the same thing with the -t/--list switch). If you want to create the directories automatically, use -d. So a quick way to unpack an rpm:

rpm2cpio whatever.rpm | cpio -i -d

You can use this to install into $HOME. The only problem will be if the program expects to find stuff in /etc, etc., since many things have their install location hard-coded in for whatever purpose when they are compiled.

Building from source is probably a better option (since you can provide the correct location), but if you can get this to work in whatever case then it's quick and simple.

Also, the midnight commander file browser (mc), and probably other file browsers besides, will allow you to navigate an rpm or cpio (or compressed tar, or zip) hierarchy and copy out individual files as if the archive were unpacked (it creates a temporary file system to browse with the archive contents in it).

| improve this answer | |

This is an alternate (not using yum) and permission will be wacky but you can chown to the target user afterward: -- also it is a hit or miss :-(

#-## Download all dependency for the RPM -- 
#sudo yum install yum-utils
#sudo yumdownloader --resolve --destdir ~/download bash

#-## Install all downloaded to an alternate root 
#sudo rpm --initdb --root <user_home_dir>
#sudo rpm --root <user_home_dir> -Uvh --nodeps ~/download/*

Then add appropriate locations to your path.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.