Skip to content

Instantly share code, notes, and snippets.

@benders
Created July 2, 2010 20:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benders/461890 to your computer and use it in GitHub Desktop.
Save benders/461890 to your computer and use it in GitHub Desktop.
How to use Bundler for a script run via symlink
#!/usr/bin/env ruby
# Bundler needs to find the Gemfile in the current directory, so we
# need to dereference symlinks, then chdir to where this script lives
this_file = __FILE__
while( File.symlink?(this_file) )
this_file = File.readlink(this_file)
end
Dir.chdir(File.dirname(this_file))
require "rubygems"
require "bundler"
Bundler.setup
# Now we can start doing whatever it was we were going to do
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment