Created
July 2, 2010 20:51
-
-
Save benders/461890 to your computer and use it in GitHub Desktop.
How to use Bundler for a script run via symlink
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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