Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

Commit

Permalink
Always generate bin files no matter what.
Browse files Browse the repository at this point in the history
  • Loading branch information
Carl Lerche committed Oct 7, 2009
1 parent 6f37ddf commit 58169d2
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 15 deletions.
38 changes: 23 additions & 15 deletions lib/bundler/repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ def install(dependencies, sources, options = {})
do_install(bundle, options)
valid = bundle
end
cleanup(valid)

generate_bins(valid, options)
cleanup(valid, options)
configure(valid, options)
end

Expand Down Expand Up @@ -96,6 +98,25 @@ def do_install(bundle, options)
end
end

def generate_bins(bundle, options)
bundle.each do |spec|
# HAX -- Generate the bin
bin_dir = @bindir
path = @path
installer = Gem::Installer.allocate
installer.instance_eval do
@spec = spec
@bin_dir = bin_dir
@gem_dir = path.join("gems", "#{spec.full_name}")
@gem_home = path
@wrappers = true
@format_executable = false
@env_shebang = false
end
installer.generate_bin
end
end

def expand_gemfile(spec, options)
Bundler.logger.info "Installing #{spec.name} (#{spec.version})"

Expand All @@ -115,19 +136,6 @@ def expand_vendored_gem(spec, options)
add_spec(spec)
FileUtils.mkdir_p(@path.join("gems"))
File.symlink(spec.location, @path.join("gems", spec.full_name))

# HAX -- Generate the bin
bin_dir = @bindir
path = @path
installer = Gem::Installer.allocate
installer.instance_eval do
@spec = spec
@bin_dir = bin_dir
@gem_dir = path.join("gems", "#{spec.full_name}")
@gem_home = path
@wrappers = true
end
installer.generate_bin
end

def add_spec(spec)
Expand All @@ -139,7 +147,7 @@ def add_spec(spec)
end
end

def cleanup(valid)
def cleanup(valid, options)
to_delete = gems
to_delete.delete_if do |spec|
valid.any? { |other| spec.name == other.name && spec.version == other.version }
Expand Down
12 changes: 12 additions & 0 deletions spec/bundler/manifest_file_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,18 @@
File.read("#{bundled_app}/bin/rackup").should_not == "omg"
end

it "recreates the bin files if they are missing" do
install_manifest <<-Gemfile
clear_sources
source "file://#{gem_repo1}"
gem "rack"
Gemfile

bundled_app('bin/rackup').delete
Dir.chdir(bundled_app) { gem_command :bundle }
bundled_app('bin/rackup').should exist
end

it "ensures the source sources contains no duplicate" do
build_manifest_file <<-Gemfile
source "http://gems.rubyforge.org"
Expand Down

0 comments on commit 58169d2

Please sign in to comment.