summaryrefslogtreecommitdiff
path: root/lib/bundler
diff options
context:
space:
mode:
authorHomu <homu@barosl.com>2015-11-22 04:27:33 +0900
committerHomu <homu@barosl.com>2015-11-22 04:27:33 +0900
commit3720418f362aac4f5da9c0a510fdb838c37708bd (patch)
tree6650861ca9e0794bb6df3ae5136466db4ba66021 /lib/bundler
parent771714745965c4a8d1a9c52266919862b5e4ce3e (diff)
parentb00e4daa160e2ea74d741bb60511bae07f4b8aad (diff)
downloadbundler-3720418f362aac4f5da9c0a510fdb838c37708bd.tar.gz
Auto merge of #4113 - blackxored:silence-root-warning, r=segiddins
Check silence_root_warning option to skip warning on root install cmds Adds a new setting `silence_root_warning` (environment variable: `BUNDLE_SILENCE_ROOT_WARNING`) that skips the default warning when `install` is run as root. The warning is useful but I think it should be able to be disabled if the user knows what he's doing, it's handy when run inside Docker containers (which by default run as root), or other environments where root is used. Also adds a new `preserve_env` option to `bundle` helper in tests which allows running commands under sudo with the `-E` flag (preserve environment) as opposed to the default env_reset. Without this, the command would be run without our flag which makes it impossible to test. There might be cleaner ways to achieve this, though.
Diffstat (limited to 'lib/bundler')
-rw-r--r--lib/bundler/cli/install.rb2
-rw-r--r--lib/bundler/settings.rb2
2 files changed, 2 insertions, 2 deletions
diff --git a/lib/bundler/cli/install.rb b/lib/bundler/cli/install.rb
index 1f5337d46e..256ae0a7d2 100644
--- a/lib/bundler/cli/install.rb
+++ b/lib/bundler/cli/install.rb
@@ -157,7 +157,7 @@ module Bundler
private
def warn_if_root
- return if Bundler::WINDOWS || !Process.uid.zero?
+ return if Bundler.settings[:silence_root_warning] || Bundler::WINDOWS || !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
diff --git a/lib/bundler/settings.rb b/lib/bundler/settings.rb
index f5286c9a22..c859a7677b 100644
--- a/lib/bundler/settings.rb
+++ b/lib/bundler/settings.rb
@@ -2,7 +2,7 @@ require "uri"
module Bundler
class Settings
- BOOL_KEYS = %w(frozen cache_all no_prune disable_local_branch_check ignore_messages gem.mit gem.coc).freeze
+ BOOL_KEYS = %w(frozen cache_all no_prune disable_local_branch_check ignore_messages gem.mit gem.coc silence_root_warning).freeze
NUMBER_KEYS = %w(retry timeout redirect ssl_verify_mode).freeze
DEFAULT_CONFIG = { :retry => 3, :timeout => 10, :redirect => 5 }