How to install linux software without root privileges

HPC cluster users rarely have root privileges for installing new software. Default location for installation is usually /usr/bin/, but our user directories are usually located somewhere else like /home/ljcohen/ or /mnt/home/ljcohen/. So, what are you supposed to do when you need to use a new software package? You can contact your cluster sysamins to have them install the package cluster-wide. In general, it’s a good idea to be in contact with them. (Usually they’re nice, helpful, and like to hear from their users to learn more about how you’re using the cluster.) But, sometimes you just want to try something out to see if it’s useful. Here is how.

I wanted to install samstat. (btw, I don’t mean to single out samstat. This is just what I happened to be trying out today. And it was a relatively easy fix!)

The first step is to download the installation file by grabbing the latest version available through the software’s website:

http://downloads.sourceforge.net/project/samstat/samstat-1.5.1.tar.gz?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fsamstat%2F&ts=1453702634&use_mirror=iweb

But, notice how this web address is longer than it needs to be. This is because sourceforge.net puts on the extra stuff at the end you don’t need.  You could first download this file to your local harddrive then transfer the file onto your cluster account. But, the easiest thing is the wget command and download the file directly into your linux cluster environment.

Right-click on the “Direct Link”, select “Copy Link Address” from the menu, then manually delete everything after the filename:

samstat_download

Create and keep a directory where you will download and install all of your local software. I keep software in .local. Navigate to that directory and download the file. Use this command:

wget http://downloads.sourceforge.net/project/samstat/samstat-1.5.1.tar.gz

If you follow the installation instructions exactly, you will get a few errors:

tar_err

make_clean

By looking at the README file, there are slightly different instructions compared to the website:

samstat

After decompressing the .tar.gz file, the next command ./configure results in “self tests run under valgrind” not passing:

configure

I decided to keep going and see what would happen. Running the next command ‘make’ appears fine:

make

Even ‘make check’ passes all the tests:

make_check

The executable file ‘samstat’ is in the appropriate directory. It appears everything is fine:

src

However, the final command ‘make install’ has a problem:

makeinstall

There is a problem creating a file in /usr/local/bin/samstat with “Permission denied”. This directory does not belong to me, and I don’t have privileges to write there.

From experience, I know that I need to tell the installation process where to install files so it does not try in the default location.

But how do I know this?

When faced with errors, knowing what to use as a Google search string can be a challenge. When I used the exact error “cannot create regular file”, the results were not very helpful. (at least for me)

This is what I used: “make install without root privileges”.

The most helpful page for me was a post on the Biostars forum.

To undo the failed installation attempt, all you have to do is delete the directory with rm -rf. But remember to keep the compressed tar file!

rm

Then start over. Finally, I managed to get it right! Here are the working commands I used:

tar -zxvf samstat-1.5.1.tar.gz
cd samstat-1.5.1/
./configure --prefix=/home/ljcohen/.local
make
make check
make install

And it works!

samstat_working

Don’t forget to add this working directory to your $PATH.

 

When you get something to work, it feels good. 🙂 While all of your commands are saved in your history. Don’t forget to keep a log of what you’ve done and how to fix it so that your future self can remember when this happens again.

future_self

Advertisements

About Lisa Cohen

PhD student at UC Davis.
This entry was posted in cluster, High Performance Computing, Linux, software. Bookmark the permalink.

2 Responses to How to install linux software without root privileges

  1. Nice walkthrough! I maintain a guide (in shorthand) for how to do this using various build systems at https://github.com/mr-c/misc/wiki/Linux-Home-Directory-Program-Installation

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s