1

I have this linux box without root access with a quite old emacs, so I downloaded the latest version and built as follows:

  • download to $HOME/SRC
  • configure and build in $HOME/BLD with --prefix=$HOME
  • make and make install

So this creates a bin folder in my home directory which is what I expected.

Now when I type emacs directly from terminal, it still opens the old one (as expected). So, I have to do ~/bin/emacs. I added this alias emacs=$HOME/bin/emacs to my .bash_profile which works. But I could have also added ~/bin to $PATH. However, not quite sure which one is recommended. And would the 2 versions of emacs work without any conflict e.g. both sharing and overwriting ~/.emacs each time a different version is opened.

Which is the best way to install new applications without root access where an older version is already present, and if the steps I followed are right.

2
  • emacs is quite large. You should discuss either upgrading the existing emacs that's installed, or supporting multiple versions of emacs with your sysadmin. Commented Mar 3, 2012 at 16:30
  • possible duplicate of How to run my own program without specifying its path Commented Mar 3, 2012 at 23:44

1 Answer 1

4

Adjust your PATH. It simplifies execution, works as expected, and once you install more applications with your $HOME as prefix, they'll all work as expected. I'd do something like this in my RC file:

PATH=$HOME/bin:$PATH LD_RUN_PATH=$HOME/lib:$LD_RUN_PATH export PATH LD_RUN_PATH 

Setting LD_RUN_PATH should allow locally-install DSOs to work too.

What you've done to install emacs so far is pretty much the way it's done in multi-user environments.

Clarification: paths in Unix (and other software that use them, from DOS to TeX) work like lists of places, searched left to right. On Unix, we use colons (:) to separate the entries. If you have a PATH like /usr/local/bin:/bin:/usr/bin, and you're looking for a program called foo, these paths will be searched for, in order:

  1. /usr/local/bin/foo
  2. /bin/foo
  3. /usr/bin/foo

The first of these found is used. So, depending on where exactly you insert a directory, you can make your installed binaries ‘override’ others. Conceptually, the order of PATH is traditionally specific-to-generic or local-to-global. (of course, we often add weird paths to support self-contained third-party applications and this can break this analogy)

3
  • just to confirm, if I add $HOME/bin to my PATH, all programs installed there will take precedence over those (existing older versions) installed as root in /usr/bin and other locations in PATH? Basically does it matter to append or prepend $HOME/bin to PATH? e.g. PATH=$PATH:$HOME/bin instead of the above. And one more question, what if I want to install a newer version of the same program in $HOME/bin? I am guessing it would append the version number to the new files? Commented Mar 3, 2012 at 14:04
  • 3
    @vis: the directories in $PATH are tested from left to right, so PATH=$HOME/bin:$PATH makes versions in $HOME/bin override the others, with PATH=$PATH:$HOME/bin, your version will only be used if no other is present. Re the new versions: usually, no version number is appended automatically. It's probably a good idea to rename the executables/directories and put symlinks in (so ~/bin/emacs is a symlink to ~/bin/emacs-26.3.1 which is the executable that make install called emacs). Commented Mar 3, 2012 at 14:56
  • 2
    Some info for completeness: /usr/bin is for binaries included with the distro / package manager. Place your own binaries in /opt or /usr/local/bin. That way a system upgrade won't risk wiping your manual binaries. Commented Mar 3, 2012 at 18:49

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.