Is it possible to install ctags without root privs?

7

9

I have user access to a Ubuntu instance and I'd like to use CTags. The error says:

The program 'ctags' can be found in the following packages:
 * exuberant-ctags
 * emacs22-bin-common
 * emacs21-bin-common
 * elvis-tools
 * emacs-snapshot-bin-common
Ask your administrator to install one of them
-bash: ctags: command not found

This and all the instructions online indicate that I need to be root. Is there a way to install it as a user?

mcgyver5

Posted 2009-11-05T20:19:07.437

Reputation: 1 031

Answers

16

Yes.

You will need to compile it yourself and install it in your home directory.

Download ctags source: http://prdownloads.sourceforge.net/ctags/ctags-5.8.tar.gz

In hour shell:

$ tar zxf ctags-5.8.tar.gz
$ cd ctags-5.8
$ ./configure --prefix=$HOME
$ make && make install

This will compile and install ctags in your home directory. The resulting binary will be: $HOME/bin/ctags

You will now have to modify your PATH environment variable prior to launching vim.

$ vim $HOME/.bashrc (or whichever shell you're using)

put this line in your .bashrc

export PATH="$HOME/bin:$PATH"

You will now need to resource your .bashrc (remember that .bashrc is normally only loaded from non-interactive shells. Make sure that you source .bashrc from .bash_profile)

If you need to, modify your .bash_profile and make sure it has a line like:

. $HOME/.bashrc

or

source $HOME/.bashrc

To continue without closing your shell, simply type:

$ . $HOME/.bashrc

You can now launch vim and ctags will be working.

user16952

Posted 2009-11-05T20:19:07.437

Reputation:

For me it looks like .bash_profile already gets loaded even with just a terminal login (setup by the admin sometime ago). So adding that line made a circular reference, and locked up bash! Using scp, I got rid of .bash_profile and fixed it. Your post is helpful in general. Just wanted to point out the possible problem with pointing to bashrc from bash_profile. – phyatt – 2015-10-22T14:08:37.533

Nevermind. I had another portion of my bashrc that was sensitive to being loaded twice. Not related to your answer. Sorry for the misinformation on my part. – phyatt – 2015-10-29T15:08:10.427

No --- the point of Ubuntu and Debian is that you have more than 20,000 sanely built and configured packages available. – None – 2009-11-05T20:33:37.920

4Yes, sometimes you don't have permission to run apt-get install, like when you have an account with a hosting provider where you share the machine with many other users. I find sometimes I need to install a source tarball this way, and these instructions are solid. – Harold L – 2009-11-05T20:40:31.167

debian packages are wonderful and all, but any unix user should know how to install packages from source into a local directory. It's useful for testing packages before installing globally, compiling a personal version that's different from the local version (I always compile a custom mutt for myself), and it works on every unix-like operating system. – None – 2009-11-05T21:44:50.047

6

You don't have to compile anything. Ctags is just a single binary program, so you can download the appropriate package, unpack it and put the binary in your path. Like that:

cd
mkdir tmp
cd tmp 
wget http://mirrors.kernel.org/ubuntu/pool/main/e/exuberant-ctags/exuberant-ctags_5.5.4-1_i386.deb
dpkg -x exuberant-ctags_5.5.4-1_i386.deb .
mkdir ~/bin
cp usr/bin/ctags-exuberant ~/bin
cd ~/bin
ln -sf ctags-exuberant ctags
export PATH=$PATH:$HOME/bin

user16960

Posted 2009-11-05T20:19:07.437

Reputation:

+1 good idea. May not always work for software that has loads of dependencies (then compiling from source will be easier), but if it works it's simpler than compiling. – sleske – 2009-12-27T14:32:31.313

1

You should be able to do it yourself if you compile and install your own copy of the editor. You're not going to be able to install a system-wide package like the ones it's asking for without being root.

Paul McMillan

Posted 2009-11-05T20:19:07.437

Reputation: 826

1

If you are the one who installed this Ubuntu machine, then you are the user with uid 1000 meaning that you can run commands requiring root via the sudo command, e.g.

sudo app-get install exuberant-ctags

You may need to precede this with

sudo apt-get update

to get fresh package information.

Dirk Eddelbuettel

Posted 2009-11-05T20:19:07.437

Reputation: 1 191

You fail at reading the question. He said he doesn't have root access. – Paul McMillan – 2009-11-05T20:39:19.453

1

Certainly, just install it in your home directory from source.

Go to http://ctags.sourceforge.net/ and download the latest version. Expand it, open a terminal and go to the directory where you expanded it, then do this:

./configure --prefix=`( cd ~ ; pwd ~ )`
make all
make install

Now, edit your PATH with this (assuming bash, which is probably what you are using if you don't know how to do this without help):

export PATH=$PATH:`( cd ~ ; pwd ~ )`/bin

You might want to add that last line into your .bashrc or .bash_profile file as well for that matter.

Joshua D. Boyd

Posted 2009-11-05T20:19:07.437

Reputation: 111

How does pwd ~ differ from just pwd? Why not just $HOME? – Harold L – 2009-11-05T20:41:51.603

0

You can always install it localy, say under your home directory. After that add the directory where ctags resides to yout shell PATH environment variable.

dimba

Posted 2009-11-05T20:19:07.437

Reputation: 713