Skip to content

Instantly share code, notes, and snippets.

@colby-swandale
Created September 16, 2018 10:45
Show Gist options
  • Save colby-swandale/003d7274067613db360b6ead9de84322 to your computer and use it in GitHub Desktop.
Save colby-swandale/003d7274067613db360b6ead9de84322 to your computer and use it in GitHub Desktop.
redefine_method(gem_class, :activate_bin_path) do |name, *args|
exec_name = args.first
return ENV["BUNDLE_BIN_PATH"] if exec_name == "bundle"
# Copy of Rubygems activate_bin_path impl
requirement = args.last
spec = find_spec_for_exe name, exec_name, [requirement]
gem_bin = File.join(spec.full_gem_path, spec.bindir, exec_name)
gem_from_path_bin = File.join(File.dirname(spec.loaded_from), spec.bindir, exec_name)
File.exist?(gem_bin) ? gem_bin : gem_from_path_bin
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment