Development Environment

If you’re compiling a software package because you need a particular version (e.g. the latest), then it requires a little bit more maintenance than using a package manager like dpkg. Software that you compile yourself should *not* go into /usr, it should go into your home directory. This is part of being a software developer.

One way of doing this is to install everything into $HOME/local/$PACKAGE. Here is how I install node on my machine:

./configure --prefix=$HOME/local/node-v0.4.5 && make install

To have my paths automatically set I put this inside my $HOME/.zshrc:

PATH="$HOME/local/bin:/opt/local/bin:/usr/bin:/sbin:/bin"
LD_LIBRARY_PATH="/opt/local/lib:/usr/local/lib:/usr/lib"
for i in $HOME/local/*; do
  [ -d $i/bin ] && PATH="${i}/bin:${PATH}"
  [ -d $i/sbin ] && PATH="${i}/sbin:${PATH}"
  [ -d $i/include ] && CPATH="${i}/include:${CPATH}"
  [ -d $i/lib ] && LD_LIBRARY_PATH="${i}/lib:${LD_LIBRARY_PATH}"
  [ -d $i/lib/pkgconfig ] && PKG_CONFIG_PATH="${i}/lib/pkgconfig:${PKG_CONFIG_PATH}"
  [ -d $i/share/man ] && MANPATH="${i}/share/man:${MANPATH}"
done

Node is under sufficiently rapid development that everyone should be compiling it themselves. A corollary of this is that npm (which should be installed alongside Node) does not require root to install packages.

CPAN and RubyGems have blurred the lines between development tools and system package managers. With npm we wish to draw a clear line: it is not a system package manager. It is not for installing firefox or ffmpeg or OpenSSL; it is for rapidly downloading, building, and setting up Node packages. npm is a development tool. When a program written in Node becomes sufficiently mature it should be distributed as a tarball, .deb, .rpm, or other package system. It should not be distributed to end users with npm.

This entry was posted in Uncategorized. Bookmark the permalink.

6 Responses to Development Environment

  1. Matt McManus says:

    Thanks Ryan. Posts like this are really helpful to people like me who are getting into serious development for the first time. It’s just hard to come by good practices like this.

    Do all of you node guys use zsh or is it just a personal preference?

  2. Elvis says:

    I’m confused. Which one of these is true:

    1. npm is a development tool. npm is not to be used as a package manager. But some other tool can be used (in addition to distributing it via .deb, .rpm)

    2. npm is a development tool. No other tool that functions in a similar manner must be used for package management. i.e. CPAN/RubyGems equivalents are discouraged. Packages must be distributed via .tgz/.deb/.rpm

  3. Brandon says:

    You say “Software that you compile yourself should *not* go into /usr, it should go into your home directory. This is part of being a software developer.”

    Dan Benjamin made a similar assertion a few years ago, but he asserted (if I recall correctly) that you should put everything in /usr/local/bin/.

    Neither of you give the rationale for your assertion, but I’d like to hear it. Would you indulge me and explain why you say this?

    Also, why “~/local”? I’ve used ~/usr (since I wasn’t aware of any convention for software installed in ones home directory)

    Please understand that I’m not necessarily disagreeing: I’m just saying “why?” and “why *there*!?”.

    • Troy Kruthoff says:

      I use the home dir, as I tend to upgrade to a faster newer notebook every 12-18 months and I’ve had good success with simply syncing the home directories between the old and new.

Leave a reply to Elvis Cancel reply