Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use Bundler.with_unbundled_env instead of Bundler.with_clean_env #16

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,10 @@ Require in `Capfile`:
server 'localhost', roles: %w{app web} # no need to set SSH configs.

### Options
**`:run_locally_with_clean_env`** (default: `true`)
**`:run_locally_with_unbundled_env`** (default: `true`)

When using bundler, commands are executed in `Bundler.with_clean_env` by default so as not to affect the executable ruby scripts. To explicitly inherit environment variables, set this `false`.
Previous name is **`run_locally_with_clean_env`**.
When using bundler, commands are executed in `Bundler.with_unbundled_env` by default so as not to affect the executable ruby scripts. To explicitly inherit environment variables, set this `false`.

## Development

Expand Down
25 changes: 23 additions & 2 deletions lib/capistrano/locally.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ def on(hosts, options={}, &block)
else
SSHKit::Backend::Local
end
if (defined? Bundler) && fetch(:run_locally_with_clean_env, true)
Bundler.with_clean_env do

if (defined? Bundler) && fetch_setting_related_bundler_with_unbundled_env
Bundler.with_unbundled_env do
klass.new(localhost, &block).run
end
else
Expand All @@ -39,5 +40,25 @@ def on(hosts, options={}, &block)
def dry_run?
fetch(:sshkit_backend) == SSHKit::Backend::Printer
end

def fetch_setting_related_bundler_with_unbundled_env
value = fetch(:run_locally_with_unbundled_env)
value = fetch_run_locally_with_clean_env if use.nil?
value = true if use.nil?

value
end

def fetch_run_locally_with_clean_env
value = fetch(:run_locally_with_clean_env)

unless value.nil?
$stderr.puts(<<-MESSAGE)
[Deprecation Notice] `set :run_locally_with_clean_env` has been deprecated in favor of `set :run_locally_with_unbundled_env`.
MESSAGE
end

value
end
end
end