Skip to content

Instantly share code, notes, and snippets.

@christianchristensen
Last active December 16, 2015 19:39
Show Gist options
  • Save christianchristensen/5486463 to your computer and use it in GitHub Desktop.
Save christianchristensen/5486463 to your computer and use it in GitHub Desktop.
Vendorize all the things; dependable dependency management.

Vendorize

Vendoring dependencies can provide quite a bit of freedom: from properly specified versions to clearly defined isolation. There's also some interesting interplay with OS level (or external to the language) dependencies which can be handled with proper package management; see Dependency management for grown ups. This serves as a guide for similar usage across languages.

Go

$GOPATH

Research:

Perl

local::lib + $PERL5LIB (see: Perl CPAN Modules without sudo, virtualenv for Perl, perl-virtualenv)

Example usage:

# Install local::lib to a subdirectory, then install any CPAN module(s).
curl -L -o local-lib.tar.gz http://search.cpan.org/CPAN/authors/id/A/AP/APEIRON/local-lib-1.008009.tar.gz
tar -xzf local-lib.tar.gz
LIBSPWD=`pwd`
cd local-lib-1.008009
perl Makefile.PL --bootstrap=$LIBSPWD
make test
make install
eval $(perl -I$LIBSPWD/lib/perl5 -Mlocal::lib=$LIBSPWD)
echo "eval \$(perl -I$LIBSPWD/lib/perl5 -Mlocal::lib=$LIBSPWD)"
echo "Install CPAN modules with:"
echo "perl -I$LIBSPWD/lib/perl5 -MCPAN -Mlocal::lib=$LIBSPWD -e 'CPAN::install(LWP)'"
echo "Run an app with the installed deps:"
echo "perl -I$LIBSPWD/lib/perl5 -Mlocal::lib=$LIBSPWD appname.pl"

# Alternatively (to CPAN::install) use App::cpanminus
curl -LO http://xrl.us/cpanm
chmod +x cpanm
echo "perl -I$LIBSPWD/lib/perl5 -Mlocal::lib=$LIBSPWD ./cpanm RTSP::Lite"

PHP

Composer (see also: Pear and Pecl)

Example usage:

# Get a project
git clone git@github.com:igorw/fab-symfony-console.git; cd fab-symfony-console
# Get composer
curl -sS https://getcomposer.org/installer | php
# Install dependencies locally in ./vendor
# (Note: You may need to set `php -d suhosin.executor.include.whitelist=phar ...`; http://cweiske.de/tagebuch/suhosin-phar.htm)
php composer.phar install
# Run commands in context
php example.php

Python

setuptools + $PYTHONPATH (see also: virtualenv (Install virtualenv without root))

pex (docs)

Ruby

Bundler (also: RubyGems)

Example usage:

Caveat emptor: One time setup: gem install bundler #sudo?

# Get a project
git clone git@github.com:arangamani/jenkins_launcher.git; cd jenkins_launcher
# Install dependencies locally in ./vendor
bundle install --path vendor
# Run commands in the project vendor context
bundle exec ruby bin/jlaunch help
bundle exec jenkinscli help

Node.js

~/.nvm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment