I'm using rbenv and have installed the gem Photocopier, which provides a simple way to copy a file from a server to the local environment. This gem has a dependency on the gem net-ssh version 6.1. For reasons unknown to me (version of Ruby? version of macos Ventura?) I need to use a more recent version of net-ssh, for example 7.2.1, which I have installed.
Problem is that I don't know how to change the dependency. I have tried to modify the original gemspec file for Photocopier from
spec.add_dependency 'net-ftp', '~> 0.1.3'
spec.add_dependency 'net-scp', '~> 3.0'
spec.add_dependency 'net-sftp', '~> 3.0'
spec.add_dependency 'net-ssh', '~> 6.1'
to:
spec.add_dependency 'net-ftp'
spec.add_dependency 'net-scp'
spec.add_dependency 'net-sftp'
spec.add_dependency 'net-ssh', '~> 7.2.1'
and invoked bundle install, which results in a Gemfile.lock which looks OK:
PATH
remote: .
specs:
photocopier (1.4.1)
activesupport (~> 6.1)
net-ftp
net-scp
net-sftp
net-ssh (~> 7.2.1)
net-ssh-gateway (~> 2.0)
GEM
remote: https://rubygems.org/
specs:
activesupport (6.1.7.7)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
tzinfo (~> 2.0)
zeitwerk (~> 2.3)
ast (2.4.2)
byebug (11.1.3)
coderay (1.1.3)
concurrent-ruby (1.2.3)
date (3.3.4)
diff-lcs (1.5.1)
docile (1.4.0)
i18n (1.14.4)
concurrent-ruby (~> 1.0)
json (2.7.1)
language_server-protocol (3.17.0.3)
method_source (1.0.0)
minitest (5.22.3)
net-ftp (0.3.4)
net-protocol
time
net-protocol (0.2.2)
timeout
net-scp (4.0.0)
net-ssh (>= 2.6.5, < 8.0.0)
net-sftp (4.0.0)
net-ssh (>= 5.0.0, < 8.0.0)
net-ssh (7.2.1)
net-ssh-gateway (2.0.0)
net-ssh (>= 4.0.0)
parallel (1.24.0)
parser (3.3.0.5)
ast (~> 2.4.1)
racc
pry (0.14.2)
coderay (~> 1.1)
method_source (~> 1.0)
pry-byebug (3.10.1)
byebug (~> 11.0)
pry (>= 0.13, < 0.15)
racc (1.7.3)
rainbow (3.1.1)
rake (13.1.0)
regexp_parser (2.9.0)
rexml (3.2.6)
rspec (3.13.0)
rspec-core (~> 3.13.0)
rspec-expectations (~> 3.13.0)
rspec-mocks (~> 3.13.0)
rspec-core (3.13.0)
rspec-support (~> 3.13.0)
rspec-expectations (3.13.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-mocks (3.13.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-support (3.13.1)
rubocop (1.62.1)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.31.1, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.31.2)
parser (>= 3.3.0.4)
rubocop-capybara (2.20.0)
rubocop (~> 1.41)
rubocop-factory_bot (2.25.1)
rubocop (~> 1.41)
rubocop-rake (0.6.0)
rubocop (~> 1.0)
rubocop-rspec (2.27.1)
rubocop (~> 1.40)
rubocop-capybara (~> 2.17)
rubocop-factory_bot (~> 2.22)
ruby-progressbar (1.13.0)
simplecov (0.22.0)
docile (~> 1.1)
simplecov-html (~> 0.11)
simplecov_json_formatter (~> 0.1)
simplecov-html (0.12.3)
simplecov_json_formatter (0.1.4)
time (0.3.0)
date
timeout (0.4.1)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (2.5.0)
zeitwerk (2.6.13)
PLATFORMS
ruby
x86_64-darwin-22
DEPENDENCIES
bundler (~> 2.2)
photocopier!
pry-byebug (~> 3.9)
rake (~> 13.0)
rspec (~> 3.10)
rubocop (~> 1.6)
rubocop-rake (~> 0.5)
rubocop-rspec (~> 2.0)
simplecov (~> 0.20)
BUNDLED WITH
2.5.6
I use this simple Ruby script to test:
require 'photocopier'
ssh = Photocopier::SSH.new(
host: 'xxx.com',
user: 'yyy'
)
# downloads a file and returns the content
puts ssh.get('testfile.txt')
It crashes and the error log shows that the wrong version of net-ssh is loaded:
from /X/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/net-ssh-6.1.0/lib/net/ssh.rb:251:in `new'
from /X/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/net-ssh-6.1.0/lib/net/ssh.rb:251:in `start'
from /X/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/photocopier-1.4.1/lib/photocopier/ssh.rb:71:in `session'
from /X/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/photocopier-1.4.1/lib/photocopier/ssh.rb:18:in `get'
The question is where the dependency on the version 6.1.0 of net-ssh comes from and how I can change it to load the version 7.2.1 instead.