Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Issue: SSHKit::Backend::Netssh binding change in run method breaks lookup in 'normal' block scope

Open
#149 10 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
ruby
Domain
devops

Research direction

Start at SSHKit::Backend::Netssh#run and inspect how instance_exec changes the block binding. Reproduce the cap-task example with Nginx#upload_files and tmp_config_file, then determine the expected scope behavior and add coverage for service-object method lookup. Done means the encapsulated action can resolve tmp_config_file while the existing block behavior remains intact.

Written by the indexing model from the issue text.

Description

discuss!

Hi,

in SSHKit::Backend::Netssh#run instance_exec is used to change the binding of the given block. With this binding change it is difficult to encapsulate an action in a service object for instance you have a cap-task:

  desc 'Setup nginx configuration'
  task :setup do
    Nginx.new(self).setup
  end
  class Nginx < SimpleDelegator
   ...
   def upload_files
        on roles nginx_roles do |host|
          set :host_server_name, host.properties.fetch(:host_server_name)
          template 'assets.host.site', tmp_config_file
       end
  end

  def tmp_config_file
    'remote_file_name'
  end
   ...
 end

This does not work because the block is executed in the context of the SSHKit::Backend::Netssh object context and does not know the method tmp_config_file.

Why do I want to do such things? Testing! Rake and Cap tasks are difficult to test.
When I encapsulate the actions I can test the a little.

regards
dieter

Dominant language
Ruby
Stars
1.2k
Forks
257
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from capistrano/sshkit

All issues in capistrano/sshkit

Similar issues

More Ruby issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.