Search code examples
ruby-on-railsdeploymentyamlcapistranopsych

Capistrano deployment throws psych error: wrong number of arguments (given 4, expected 1) :`safe_load'


On my local machine the project works perfectly fine. Bundle install works fine and I can run the project locally. Till now, all my deployments were also working fine. But starting this deployment (no changes to any of the gems or even the code), even without changing existing code in any way, the deployment started breaking on bundle install with below error ->

Rails -> '5.0.7.2'
Ruby -> 2.5.3
Bundler             1.16.6
Deployment Tool -> Capistrano '3.11.0'

#<Thread:0x00007f9f6013bd00@/home/myusername/.rvm/gems/ruby-2.5.3/gems/sshkit-1.21.2/lib/sshkit/runners/parallel.rb:10 run> terminated with exception (report_on_exception is true): Traceback (most recent call last): 1: from /home/myusername/.rvm/gems/ruby-2.5.3/gems/sshkit-1.21.2/lib/sshkit/runners/parallel.rb:11:in block (2 levels) in execute' /home/myusername/.rvm/gems/ruby-2.5.3/gems/sshkit-1.21.2/lib/sshkit/runners/parallel.rb:15:in rescue in block (2 levels) in execute': Exception while executing as [email protected]: cd /var/www/portal.myapplication.com/releases/20220119150641; /usr/local/rvm/gems/ruby-2.5.3/wrappers/bundle install exit status: 1 (SSHKit::Runner::ExecuteError) cd /var/www/portal.myapplication.com/releases/20220119150641; /usr/local/rvm/gems/ruby-2.5.3/wrappers/bundle install stdout: Fetching gem metadata from https://rubygems.org/........

ArgumentError: wrong number of arguments (given 4, expected 1)

/usr/local/rvm/gems/ruby-2.5.3/gems/psych-4.0.3/lib/psych.rb:323:in safe_load' /usr/local/rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/rubygems/safe_yaml.rb:31:in safe_load' /usr/local/rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/rubygems/package.rb:486:in block (2 levels) in read_checksums' /usr/local/rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/rubygems/package.rb:485:in wrap' /usr/local/rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/rubygems/package.rb:485:in block in read_checksums' /usr/local/rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/rubygems/package/tar_reader.rb:116:in seek' /usr/local/rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/rubygems/package.rb:484:in read_checksums' /usr/local/rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/rubygems/package.rb:537:in block (2 levels) in verify' /usr/local/rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/rubygems/package/tar_reader.rb:29:in new' /usr/local/rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/rubygems/package.rb:536:in block in verify' /usr/local/rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/rubygems/package/file_source.rb:30:in open' /usr/local/rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/rubygems/package/file_source.rb:30:in with_read_io' /usr/local/rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/rubygems/package.rb:535:in verify' /usr/local/rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/rubygems/package.rb:516:in spec' /usr/local/rvm/gems/ruby-2.5.3/gems/bundler-1.16.6/lib/bundler/rubygems_integration.rb:307:in spec_from_gem' /usr/local/rvm/gems/ruby-2.5.3/gems/bundler-1.16.6/lib/bundler/source/rubygems.rb:368:in block in cached_specs' /usr/local/rvm/gems/ruby-2.5.3/gems/bundler-1.16.6/lib/bundler/source/rubygems.rb:366:in each' /usr/local/rvm/gems/ruby-2.5.3/gems/bundler-1.16.6/lib/bundler/source/rubygems.rb:366:in cached_specs' /usr/local/rvm/gems/ruby-2.5.3/gems/bundler-1.16.6/lib/bundler/source/rubygems.rb:90:in specs' /usr/local/rvm/gems/ruby-2.5.3/gems/bundler-1.16.6/lib/bundler/definition.rb:274:in block (2 levels) in index' /usr/local/rvm/gems/ruby-2.5.3/gems/bundler-1.16.6/lib/bundler/definition.rb:272:in each' /usr/local/rvm/gems/ruby-2.5.3/gems/bundler-1.16.6/lib/bundler/definition.rb:272:in block in index' /usr/local/rvm/gems/ruby-2.5.3/gems/bundler-1.16.6/lib/bundler/index.rb:11:in build' /usr/local/rvm/gems/ruby-2.5.3/gems/bundler-1.16.6/lib/bundler/definition.rb:269:in index' /usr/local/rvm/gems/ruby-2.5.3/gems/bundler-1.16.6/lib/bundler/definition.rb:259:in resolve' /usr/local/rvm/gems/ruby-2.5.3/gems/bundler-1.16.6/lib/bundler/definition.rb:171:in specs' /usr/local/rvm/gems/ruby-2.5.3/gems/bundler-1.16.6/lib/bundler/definition.rb:159:in resolve_remotely!' /usr/local/rvm/gems/ruby-2.5.3/gems/bundler-1.16.6/lib/bundler/installer.rb:287:in resolve_if_needed' /usr/local/rvm/gems/ruby-2.5.3/gems/bundler-1.16.6/lib/bundler/installer.rb:83:in block in run' /usr/local/rvm/gems/ruby-2.5.3/gems/bundler-1.16.6/lib/bundler/process_lock.rb:12:in block in lock' /usr/local/rvm/gems/ruby-2.5.3/gems/bundler-1.16.6/lib/bundler/process_lock.rb:9:in open' /usr/local/rvm/gems/ruby-2.5.3/gems/bundler-1.16.6/lib/bundler/process_lock.rb:9:in lock' /usr/local/rvm/gems/ruby-2.5.3/gems/bundler-1.16.6/lib/bundler/installer.rb:72:in run' /usr/local/rvm/gems/ruby-2.5.3/gems/bun DEBUG [93166736] dler-1.16.6/lib/bundler/installer.rb:25:in install' /usr/local/rvm/gems/ruby-2.5.3/gems/bundler-1.16.6/lib/bundler/cli/install.rb:65:in run' /usr/local/rvm/gems/ruby-2.5.3/gems/bundler-1.16.6/lib/bundler/cli.rb:224:in block in install' /usr/local/rvm/gems/ruby-2.5.3/gems/bundler-1.16.6/lib/bundler/settings.rb:136:in temporary' /usr/local/rvm/gems/ruby-2.5.3/gems/bundler-1.16.6/lib/bundler/cli.rb:223:in install' /usr/local/rvm/gems/ruby-2.5.3/gems/bundler-1.16.6/lib/bundler/vendor/thor/lib/thor/command.rb:27:in run' /usr/local/rvm/gems/ruby-2.5.3/gems/bundler-1.16.6/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in invoke_command' /usr/local/rvm/gems/ruby-2.5.3/gems/bundler-1.16.6/lib/bundler/vendor/thor/lib/thor.rb:387:in dispatch' /usr/local/rvm/gems/ruby-2.5.3/gems/bundler-1.16.6/lib/bundler/cli.rb:27:in dispatch' /usr/local/rvm/gems/ruby-2.5.3/gems/bundler-1.16.6/lib/bundler/vendor/thor/lib/thor/base.rb:466:in start' /usr/local/rvm/gems/ruby-2.5.3/gems/bundler-1.16.6/lib/bundler/cli.rb:18:in start' /usr/local/rvm/gems/ruby-2.5.3/gems/bundler-1.16.6/exe/bundle:30:in block in <top (required)>' /usr/local/rvm/gems/ruby-2.5.3/gems/bundler-1.16.6/lib/bundler/friendly_errors.rb:124:in with_friendly_errors' /usr/local/rvm/gems/ruby-2.5.3/gems/bundler-1.16.6/exe/bundle:22:in <top (required)>' /usr/local/rvm/gems/ruby-2.5.3/bin/bundle:23:in load' /usr/local/rvm/gems/ruby-2.5.3/bin/bundle:23:in <main>' /usr/local/rvm/gems/ruby-2.5.3/bin/ruby_executable_hooks:24:in eval' /usr/local/rvm/gems/ruby-2.5.3/bin/ruby_executable_hooks:24:in `'


Solution

  • Solution: I looked for the Gem that is adding Psych Gem (it is not listed in Gemfile directly). Then I restricted that parent Gem's version to previous version that does not download Psych. Then I ran gem uninstall psych on the server where I was deploying the code. Removed all versions of Psych from that server. Then the deployment worked fine.