lib/bundler/cli.rb in bundler-1.0.0.rc.1 vs lib/bundler/cli.rb in bundler-1.0.0.rc.2

- old
+ new

@@ -84,11 +84,11 @@ If the bundle has already been installed, bundler will tell you so and then exit. D method_option "without", :type => :array, :banner => "Exclude gems that are part of the specified named group." method_option "disable-shared-gems", :type => :boolean, :banner => - "Do not use any shared gems, such as the system gem repository." + "This option is deprecated. Please do not use it." method_option "gemfile", :type => :string, :banner => "Use the specified gemfile instead of Gemfile" method_option "no-prune", :type => :boolean, :banner => "Don't remove stale gems from the cache." method_option "no-cache", :type => :boolean, :banner => @@ -97,27 +97,79 @@ "Only output warnings and errors." method_option "local", :type => :boolean, :banner => "Do not attempt to fetch gems remotely and use the gem cache instead" method_option "binstubs", :type => :string, :lazy_default => "bin", :banner => "Generate bin stubs for bundled gems to ./bin" + method_option "path", :type => :string, :banner => + "Specify a different path than the system default ($BUNDLE_PATH or $GEM_HOME). Bundler will remember this value for future installs on this machine" + method_option "system", :type => :boolean, :banner => + "Install to the system location ($BUNDLE_PATH or $GEM_HOME) even if the bundle was previously installed somewhere else for this application" + method_option "production", :type => :boolean, :banner => + "Install using defaults tuned for deployment environments" def install(path = nil) opts = options.dup opts[:without] ||= [] opts[:without].map! { |g| g.to_sym } + if (path || options[:path] || options[:production]) && options[:system] + Bundler.ui.error "You have specified both a path to install your gems to, \n" \ + "as well as --system. Please choose." + exit 1 + end + + if path && options[:path] + Bundler.ui.error "You have specified a path via `bundle install #{path}` as well as\n" \ + "by `bundle install --path #{options[:path]}`. These options are\n" \ + "equivalent, so please use one or the other." + exit 1 + end + + if opts["disable-shared-gems"] + Bundler.ui.error "The disable-shared-gem option is no longer available.\n\n" \ + "Instead, use `bundle install` to install to your system,\n" \ + "or `bundle install --path path/to/gems` to install to an isolated\n" \ + "location. Bundler will resolve relative paths relative to\n" \ + "your `Gemfile`." + exit 1 + end + + if opts[:production] + Bundler.production = true + + unless Bundler.root.join("Gemfile.lock").exist? + raise ProductionError, "The --production flag requires a Gemfile.lock. Please\n" \ + "make sure you have checked your Gemfile.lock into version\n" \ + "control before deploying." + end + + if Bundler.root.join("vendor/cache").exist? + opts["local"] = true + end + end + # Can't use Bundler.settings for this because settings needs gemfile.dirname ENV['BUNDLE_GEMFILE'] = opts[:gemfile] if opts[:gemfile] + Bundler.settings[:path] = nil if options[:system] + Bundler.settings[:path] = "vendor/bundle" if options[:production] Bundler.settings[:path] = path if path + Bundler.settings[:path] = options[:path] if options[:path] Bundler.settings[:bin] = opts["binstubs"] if opts[:binstubs] - Bundler.settings[:disable_shared_gems] = '1' if options["disable-shared-gems"] || path + Bundler.settings[:disable_shared_gems] = '1' if Bundler.settings[:path] Bundler.settings.without = opts[:without] Bundler.ui.be_quiet! if opts[:quiet] Installer.install(Bundler.root, Bundler.definition, opts) Bundler.load.cache if Bundler.root.join("vendor/cache").exist? Bundler.ui.confirm "Your bundle is complete! " + "Use `bundle show [gemname]` to see where a bundled gem is installed." + + Bundler.ui.confirm "\nYour bundle was installed to `#{Bundler.settings[:path]}`" if Bundler.settings[:path] + + if path + Bundler.ui.warn "\nIf you meant to install it to your system, please remove the\n" \ + "`#{path}` directory and run `bundle install --system`" + end rescue GemNotFound => e if Bundler.definition.no_sources? Bundler.ui.warn "Your Gemfile doesn't have any sources. You can add one with a line like 'source :gemcutter'" end raise e @@ -229,11 +281,10 @@ long_desc <<-D Retrieves or sets a configuration value. If only parameter is provided, retrieve the value. If two parameters are provided, replace the existing value with the newly provided one. By default, setting a configuration value sets it for all projects - on the machine. If you want to set the configuration for a specific - project, use the --local flag. + on the machine. If a global setting is superceded by local configuration, this command will show the current value, as well as any superceded values and where they were specified. D