Skip to content

Commit 5cd7193

Browse files
authored
Merge pull request #99 from elthariel/fix_rbenv
Fix rbenv/rvm and capistrano-db-tasks
2 parents 40efd48 + 504f61a commit 5cd7193

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

lib/capistrano-db-tasks/database.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,11 +155,11 @@ class Local < Base
155155
def initialize(cap_instance)
156156
super(cap_instance)
157157
@cap.info "Loading local database config"
158-
dirty_config_content = @cap.run_locally do
159-
capture(:rails, "runner \"puts '#{DBCONFIG_BEGIN_FLAG}' + ActiveRecord::Base.connection.instance_variable_get(:@config).to_yaml + '#{DBCONFIG_END_FLAG}'\"")
160-
end
161-
# Remove all warnings, errors and artefacts produced by bunlder, rails and other useful tools
162-
config_content = dirty_config_content.match(/#{DBCONFIG_BEGIN_FLAG}(.*?)#{DBCONFIG_END_FLAG}/m)[1]
158+
command = "#{Dir.pwd}/bin/rails runner \"puts '#{DBCONFIG_BEGIN_FLAG}' + ActiveRecord::Base.connection.instance_variable_get(:@config).to_yaml + '#{DBCONFIG_END_FLAG}'\""
159+
stdout, status = Open3.capture2(command)
160+
raise "Error running command (status=#{status}): #{command}" if status != 0
161+
162+
config_content = stdout.match(/#{DBCONFIG_BEGIN_FLAG}(.*?)#{DBCONFIG_END_FLAG}/m)[1]
163163
@config = YAML.load(config_content).inject({}) { |h, (k, v)| h[k.to_s] = v; h }
164164
end
165165

0 commit comments

Comments
 (0)