When running production things we're pretty much inevitably dealing with the environment. It is pretty straightforward but has some quirks. Here are some of the lessons I have learned.
It’s all about your $PATH • Search paths separated by colons (/Users/ba/.rbenv/shims:/usr/ local/bin:/usr/bin:/bin) • Whatever is fi rst (left to right) in your path gets picked
└── .rben v │ └── shim s │ └── rub y ├── bi n │ └── emac s └── us r ├── bi n │ └── n c └── loca l └── bi n ├── rub y └── vim ->/bin/emacs export PATH=/bin:/usr/bin:/usr/local/bin:/Users/ba/.rbenv/shims
└── .rben v │ └── shim s │ └── rub y ├── bi n │ └── emac s └── us r ├── bi n │ └── n c └── loca l └── bi n ├── rub y └── vim ->/bin/emacs export PATH=/bin:/usr/bin:/usr/local/bin:/Users/ba/.rbenv/shims
└── .rben v │ └── shim s │ └── rub y ├── bi n │ └── emac s └── us r ├── bi n │ └── n c └── loca l └── bi n ├── rub y └── vim ->/bin/emacs export PATH=/bin:/usr/bin:/usr/local/bin:/Users/ba/.rbenv/shims
default path (/bin:/sbin) • some programs don’t inherit environment even if it’s there for security (nginx) • lots of wrapper scripts to set the environment (/etc/defaults or /etc/ syscon fi g scripts)
upgrade to Ruby 2.1.3 • picked up system ruby which was 2.0.0 (/usr/bin/ruby) • set a $PATH in nginx (env PATH=/Users/ba/.rbenv/shims:/usr/…;) • after that whtmltopdf picked up a .ruby-version fi le from $HOME/.ruby-version, pointing to 2.0.0 as well 😓
upgrade to Ruby 2.1.3 • picked up system ruby which was 2.0.0 (/usr/bin/ruby) • set a $PATH in nginx (env PATH=/Users/ba/.rbenv/shims:/usr/…;) • after that whtmltopdf picked up a .ruby-version f i
/Users/ba/.rbenv/shims/ruby doesn’t have ruby • echo $PATH shows “/usr/local/opt/rbenv/shims:…” • ~/.rbenv/ is basically empty, removed it and it worked
where you’re going • env, because a snapshot lasts • $LANG, $LC_*, $TZ, $PATH, and others can affect you various weird and interesting ways • your basic unix skills pay off. learn the basics of how your computer work and your life will be easier