Ruby Bundler Setup

Managing server passwords became a big headache. So, I developed a password recall gem that automatically copies the password for a given server and an account to the clipboard. This way I never have to email or save the passwords in any documents. I also don't have to remember the password. It generates a strong password based on a key that is memorized. Inside the bin folder, I created a Ruby script:

#!/usr/bin/env ruby

require 'albania/runner'

runner = Albania::Runner.new
runner.recall_password

As you can see, this will not work if you use rvm or rbenv, where the Ruby is installed in a path like: /Users/zepho/.rvm/rubies/ruby-2.2.2/bin/ruby. You can create a symlink to fix this issue. But it is easier to let the Bundler do the work. To fix this issue, add the bundler/setup before any other require statement.

#!/usr/bin/env ruby

require "bundler/setup"
require "albania"

runner = Albania::Runner.new
runner.recall_password

Now, you can run your custom script from terminal:

bin/albania

It will work.

References


Related Articles


Ace the Technical Interview

  • Easily find the gaps in your knowledge
  • Get customized lessons based on where you are
  • Take consistent action everyday
  • Builtin accountability to keep you on track
  • You will solve bigger problems over time
  • Get the job of your dreams

Take the 30 Day Coding Skills Challenge

Gain confidence to attend the interview

No spam ever. Unsubscribe anytime.