home..

Install Software without Root Access in a Roaming Home Directory

A common setup in the research labs I have seen is to give a roaming home directory to every user. Each user may have access to hundreds of individual machines, but their home directory follows them everywhere. In many ways this is convenient, but there is one aspect that always frustrates me. Installing the software that I need for each individual machine.

I just recently finished writing a bit of code in python for a research idea that I had. It worked great on my machine with a small dataset. Due to memory constraints, I needed to run the code on a larger server with the data I really wanted to use. The first error was that the numpy and scipy packages were not installed. Since I did not have root access, I attempted to install the packages to my home directory. Next error was that they required special mathematical libraries. When I tried to install these libraries, I realized the system did not have a FORTRAN compiler. At this point, I gave up out of frustration and realized I needed a new approach.

What follows is my current solution to this problem. I am not claiming it is the best approach, but it works for me. These instructions correspond specifically to an installation on a 64bit machine running OpenSUSE 12.1, but should generalize to other machines. I am also assuming a bash environment.

The first step is to setup a directory to work as our local root folder within the home directory. I chose ~/local_root. The goal is to have this setup work for any environment, so we will create a directory in local_root for each machine/environment we come across. Create a directory for the first environment, ~/local_root/env1 (or some better descriptive name). To save on typing, we can set up an environment variable.

export LOCAL_ROOT=~/local_root/env1

We also need to create two new directories within the local_root directory.

mkdir $LOCAL_ROOT/local
mkdir $LOCAL_ROOT/src

The first thing we will do is setup our .bashrc file. Some of the paths we are adding may not exist yet, but they will once we install gcc.

if [[ `hostname` == "machine_env1" ]]; then
    export LOCAL_ROOT=~/local_root/env1
    export LD_LIBRARY_PATH=$LOCAL_ROOT/local/lib64:$LD_LIBRARY_PATH
    export CPLUS_INCLUDE_PATH=$LOCAL_ROOT/local/include:$CPLUS_INCLUDE_PATH
    export PATH=$LOCAL_ROOT/local/bin:$PATH
fi

The if statement makes sure that the code only runs on a specific machine. This could also be modified for a specific set of machines. If there are multiple machines, a separate set of commands can exist for each machine.

Now that the .bashrc file is properly setup, we can begin installing software specific to the environment, without requiring root access. For this post, I will focus only on installing gcc—once we have gcc, we should be able to compile and install almost anything else we require.

You might be thinking, “Why should I go through the trouble of installing gcc, the one program nearly all systems already have installed?” If the machines you work with already have an up-to-date version of gcc (including gfortran), you can probably stop reading now. However, if you work at a place that has not updated their version of gcc since the previous millennium, then it will probably be worth the trouble.

Before installing gcc, we need to install any dependencies. My system needed MPFR and MPC. You may also need to download and install GMP. We will install each one individually using nearly the exact same setup.

Download and unpack MPFR into the $LOCAL_ROOT/src directory (I used version 3.1.2). Run the following commands to build and install MPFR.

./configure —prefix=$LOCAL_ROOT/local
make
make check
make install

Download and unpack MPC into the $LOCAL_ROOT/src directory (I used version 1.02). Run the following commands to build and install MPC.

./configure --prefix=$LOCAL_ROOT/local --with-mpfr-lib=$LOCAL_ROOT/local/lib64 --with-mpfr-include=$LOCAL_ROOT/local/include
make
make check
make install

The dependencies for gcc should now be installed. Get the most recent stable version of gcc ( I used version 4.8.0 ). As with the dependencies, unpack gcc in the $LOCAL_ROOT/src directory and run the following commands.

./configure --prefix=$LOCAL_ROOT/local --with-mpfr-lib=$LOCAL_ROOT/local/lib64 --with-mpfr-include=$LOCAL_ROOT/local/include --with-mpc-lib=$LOCAL_ROOT/local/lib64 --with-gmp-lib=$LOCAL_ROOT/local/lib64 --disable-multilib
make
make check
make install

Now we should have a working installation of gcc for a specific environment. The steps can be repeated for every environment that is needed. While compiling and installing other software may still require significant effort, you are no longer chained to the preexisting dependencies on any particular system.

If anyone else has a better solution for this problem, I would love to hear it.

Comments? Send me an email.
© 2023 William Hartmann   •  Theme  Moonwalk