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

Fix error if local template exists: "no implicit conversion of StringIO into String" #59

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jesperronn
Copy link
Contributor

@jesperronn jesperronn commented Sep 11, 2022

I ran into this problem, when I had a template in my project config/deploy/templates/postgresql.yml.erb.

The code further up the call stack, will run StringIO.new() which results in a failure:

upload!(
StringIO.new(pg_template),
archetype_database_yml_file

So in the case where pg_template() method returns a StringIO we see this error:

~/.rvm/gems/ruby-3.1.2/gems/sshkit-1.21.3/lib/sshkit/runners/parallel.rb:15:in `rescue in block (2 levels) in execute': 
    Exception while executing on host xxxx: no implicit conversion of StringIO into String (SSHKit::Runner::ExecuteError)
	from ~/.rvm/gems/ruby-3.1.2/gems/sshkit-1.21.3/lib/sshkit/runners/parallel.rb:11:in `block (2 levels) in execute'
~/.rvm/gems/ruby-3.1.2/gems/capistrano-postgresql-6.2.0/lib/capistrano/tasks/postgresql.rake:127:in `initialize': no implicit conversion of StringIO into String (TypeError)
	from ~/.rvm/gems/ruby-3.1.2/gems/capistrano-postgresql-6.2.0/lib/capistrano/tasks/postgresql.rake:127:in `new'
	from ~/.rvm/gems/ruby-3.1.2/gems/capistrano-postgresql-6.2.0/lib/capistrano/tasks/postgresql.rake:127:in `block (3 levels) in <top (required)>'
	from ~/.rvm/gems/ruby-3.1.2/gems/sshkit-1.21.3/lib/sshkit/backends/abstract.rb:31:in `instance_exec'
	from ~/.rvm/gems/ruby-3.1.2/gems/sshkit-1.21.3/lib/sshkit/backends/abstract.rb:31:in `run'
	from ~/.rvm/gems/ruby-3.1.2/gems/sshkit-1.21.3/lib/sshkit/runners/parallel.rb:12:in `block (2 levels) in execute'
(Backtrace restricted to imported tasks)
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing on host xxxx: no implicit conversion of StringIO into String


Caused by:
TypeError: no implicit conversion of StringIO into String

Tasks: TOP => postgresql:generate_database_yml_archetype

The PR here fixes the bug. I saw no tests in the library, and also my rubocop noted a lot of issues in the file already.

With the lack of tests and lack of linting, please review carefully.

@jesperronn
Copy link
Contributor Author

If others run into this issue, my workaround was to remove the file config/deploy/templates/postgresql.yml.erb.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant