I have created a gem that provides an executable. Now I’d like the users of my gem to being able to use the executable independently from their setup especially regarding RVM and Bundler. Some users install the gem globally:
gem install foobar
Some users install it inside projects using Bundler:
echo "gem 'foobar'" > Gemfile && bundle
Some users have a Gemset per projects, others do not.
My Problem now is, that my gem creates a git hook that looks actually like that:
#!/bin/sh
bundle exec foobar -dostuff
That approach does not work for users, who did not install my gem using Bundler. If I changed that to:
#!/bin/sh
foobar -dostuff
some users have trouble, because the executable can not be found, or the “wrong” executable is executed.
Is there any way to clean up this “bundle exec” mess and provide a behavior of the executable that works for all users?
Regards
Felix
This script should help – https://github.com/gma/bundler-exec/blob/master/bundler-exec.sh
Read more on it here – http://effectif.com/ruby/automating-bundle-exec