Developing as non root

Many examples tell you to do things like

sudo python setup.py install

or

sudo gem install foo

or

./configure --prefix=/
make install

While this is o.k. if you know what you're doing and you give a crap about package management risking to break other scripts and tools by introducint new library versions it is often much better to not install the libraries into a location where other tools can setp on it (e.g. /usr/lib, /usr/bin or /usr/local/*).

Ruby

Use bundler to pull Gems from rubygems.org. The Gemfile describes what you want to pull in:

source 'https://rubygems.org'

group :development, :test do
  gem 'puppetlabs_spec_helper',  :require => false
  gem 'puppet-lint',             :require => false
  gem 'puppet',                  puppetversion, :require => false
  gem 'rake', '~> 10.1.0',       :require => false
  gem 'rspec-puppet',            :require => false
  gem 'simplecov',               :require => false
end

With that in place you can run

sudo apt-get install bundler
bundle install --path=vendor

and it will fetch the gems and put them into vendor/. No cluttering of any directories outside your project. You can run commands from that via

bundle exec <cmd>

e.g.

bundle exec rake spec

NodeJS

npm

GNOME

jhbuild

Generic C/C++ project

For a limited set of libs you can do:

PREFIX=$PWD/../installed
./configure --prefix=$PREFIX
make install
export LD_LIBRARY_PATH=$PREFIX

see e.g. libplanfahr's ./run

Python

For Python there's virtualenv

virtualenv newtestenv
source newtestenv/bin/activate

From there on you can use the new environment already, e.g. install a module into it:

cd mymodule
python setup.py install

This would install the module (along with it's dependenies) into you new testenv.