summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndre Arko <andre@arko.net>2014-04-07 15:39:49 +0900
committerAndre Arko <andre@arko.net>2014-04-07 15:39:49 +0900
commit5dcdeb0c4ffe384922abe5136f103522197d8343 (patch)
tree0cf125f67c055553ea745c4cb2959652a7d32413
parentc1b3fd165b2ec97fb254a76eaa3900bc4857a357 (diff)
downloadbundler-5dcdeb0c4ffe384922abe5136f103522197d8343.tar.gz
move install warning into Install, add word-wrap
-rw-r--r--lib/bundler/cli.rb18
-rw-r--r--lib/bundler/cli/install.rb9
2 files changed, 9 insertions, 18 deletions
diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb
index bf3af6460a..df54c47f96 100644
--- a/lib/bundler/cli.rb
+++ b/lib/bundler/cli.rb
@@ -143,27 +143,9 @@ module Bundler
def install
require 'bundler/cli/install'
- warn_if_root
Install.new(options.dup).run
end
- no_commands {
- def warn_if_root
- warning = <<-W
-
-WARNING ****************************************************************
-Running bundler with sudo will likely have unintended consequences.
-If bundler requires you to run a command with sudo it will let you know.
-************************************************************************
-
- W
-
- if Process.uid == 0
- puts warning
- end
- end
- }
-
desc "update [OPTIONS]", "update the current environment"
long_desc <<-D
Update will install the newest versions of the gems listed in the Gemfile. Use
diff --git a/lib/bundler/cli/install.rb b/lib/bundler/cli/install.rb
index 03790056cb..93f1deb02d 100644
--- a/lib/bundler/cli/install.rb
+++ b/lib/bundler/cli/install.rb
@@ -6,6 +6,8 @@ module Bundler
end
def run
+ warn_if_root
+
if options[:without]
options[:without] = options[:without].map{|g| g.tr(' ', ':') }
end
@@ -113,6 +115,13 @@ module Bundler
private
+ def warn_if_root
+ return unless Process.uid.zero?
+ Bundler.ui.warn "Don't run Bundler as root. Bundler can ask for sudo " \
+ "if it is needed, and installing your bundle as root will break this " \
+ "application for all non-root users on this machine.", :wrap => true
+ end
+
def without_groups_messages
if Bundler.settings.without.any?
require "bundler/cli/common"