Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Raise a better error in the case that a git repo is not cloned yet.

  • Loading branch information...
commit 248ca3489de22f889a7243f571d8341c733cd52e 1 parent b9f29ad
Carl Lerche authored
View
1  lib/bundler.rb
@@ -36,6 +36,7 @@ class GemfileNotFound < BundlerError; status_code(10) ; end
class GemNotFound < BundlerError; status_code(7) ; end
class VersionConflict < BundlerError; status_code(6) ; end
class GemfileError < BundlerError; status_code(4) ; end
+ class PathError < BundlerError; status_code(13) ; end
class GitError < BundlerError; status_code(11) ; end
class DeprecatedMethod < BundlerError; status_code(12) ; end
class DeprecatedOption < BundlerError; status_code(12) ; end
View
3  lib/bundler/installer.rb
@@ -71,9 +71,8 @@ def resolve_locally
# Simple logic for now. Can improve later.
specs.length == actual_dependencies.length && specs
- rescue Bundler::GemNotFound => e
+ rescue GemNotFound, PathError => e
nil
- raise if ENV["OMG"]
end
def resolve_remotely
View
8 lib/bundler/source.rb
@@ -176,6 +176,8 @@ def load_spec_files
end
index << default_spec if default_spec && index.empty?
+ else
+ raise PathError, "The path `#{path}` does not exist."
end
index.freeze
@@ -271,6 +273,12 @@ def lock
checkout
end
+ def load_spec_files
+ super
+ rescue PathError
+ raise PathError, "#{to_s} is not checked out. Please run `bundle install`"
+ end
+
private
def git(command)
View
13 spec/runtime/setup_spec.rb
@@ -88,6 +88,19 @@
end
end
+ describe "with git" do
+ it "provides a useful exception when the git repo is not checked out yet" do
+ build_git "rack", "1.0.0"
+
+ gemfile <<-G
+ gem "foo", :git => "#{lib_path('rack-1.0.0')}"
+ G
+
+ run "1"
+ err.should include("#{lib_path('rack-1.0.0')} (at master) is not checked out. Please run `bundle install`")
+ end
+ end
+
describe "when locked" do
it "regenerates .bundle/environment.rb if it does not exist" do
system_gems "rack-1.0.0"
View
23 spec/support/helpers.rb
@@ -39,25 +39,28 @@ def lib
end
def bundle(cmd, options = {})
- require "open3"
env = (options.delete(:env) || {}).map{|k,v| "#{k}='#{v}' "}.join
args = options.map { |k,v| " --#{k} #{v}"}.join
gemfile = File.expand_path('../../../bin/bundle', __FILE__)
- input, out, err, waitthread = Open3.popen3("#{env}#{Gem.ruby} -I#{lib} #{gemfile} #{cmd}#{args}")
- @err = err.read.strip
- puts @err if $show_err && !@err.empty?
- @out = out.read.strip
- @exitstatus = nil
- @exitstatus = waitthread.value.to_i if waitthread
+ sys_exec("#{env}#{Gem.ruby} -I#{lib} #{gemfile} #{cmd}#{args}")
end
def ruby(opts, ruby = nil)
ruby, opts = opts, nil unless ruby
ruby.gsub!(/(?=")/, "\\")
ruby.gsub!('$', '\\$')
- out = %x{#{Gem.ruby} -I#{lib} #{opts} -e "#{ruby}"}.strip
- @exitstatus = $?.exitstatus
- out
+ sys_exec(%'#{Gem.ruby} -I#{lib} #{opts} -e "#{ruby}"')
+ end
+
+ def sys_exec(cmd)
+ require "open3"
+ input, out, err, waitthread = Open3.popen3(cmd)
+ @err = err.read.strip
+ puts @err if $show_err && !@err.empty?
+ @out = out.read.strip
+ @exitstatus = nil
+ @exitstatus = waitthread.value.to_i if waitthread
+ @out
end
def config(config = nil)
Please sign in to comment.
Something went wrong with that request. Please try again.