Can't upload a file - no case clause matching error
Environment
- SSHKit.ex version (
mix deps): 0.3.0 / - Elixir & Erlang/OTP version (
elixir -v): Elixir 1.10.4 / Erlang/OTP 23 - Operating system (local): OSX
- Operating system (remote): Debian Buster
- SSH version (remote,
ssh -V): OpenSSH_8.1p1, LibreSSL 2.7.3/
Expected Behavior
File should be uploaded
Actual Behavior
File is not uploaded
Include code samples, errors and stacktraces if appropriate.
Code:
UI.info("scp #{build_release_path} #{user}@#{host_name}:#{app_release_path}")
{:ok, conn} = SSHKit.SSH.connect(host_name, user: user)
:ok = SSHKit.SCP.upload(conn, build_release_path, app_release_path, verbose: true)
:ok = SSHKit.SSH.close(conn)
Backtrace:
scp /Users/lessless/Code/myapp/releases/0.1.0.tar.gz [email protected]:/opt/releases
** (CaseClauseError) no case clause matching: {:data, %SSHKit.SSH.Channel{connection: %SSHKit.SSH.Connection{host: '51.79.167.119', impl: :ssh, options: [user_interaction: false, user: 'deploy'], port: 22, ref: #PID<0.358.0>}, id: 0, impl: :ssh_connection, type: :session}, 1, "Sink: C0644 29421069 0.1.0.tar.gz\n"}
(sshkit 0.3.0) lib/sshkit/scp/upload.ex:95: anonymous fn/3 in SSHKit.SCP.Upload.connection_handler/1
(sshkit 0.3.0) lib/sshkit/ssh/channel.ex:255: SSHKit.SSH.Channel.loop/4
(sshkit 0.3.0) lib/sshkit/ssh.ex:135: SSHKit.SSH.run/3
config/deploy.exs:31: anonymous fn/5 in Bootleg.DynamicCallbacks.BeforeDeploy4.execute/0
(elixir 1.10.4) lib/enum.ex:783: Enum."-each/2-lists^foreach/1-0-"/2
lib/bootleg/dsl.ex:365: Bootleg.DSL.invoke/1
(mix 1.10.4) lib/mix/task.ex:330: Mix.Task.run_task/3
(mix 1.10.4) lib/mix/cli.ex:82: Mix.CLI.run_task/2
Hey @lessless we will have a look today and see what we can do.
Hello again @lessless,
we looked into this issue today for a while and we think that sshkit receives a new message that we do not handle yet correctly. The message is sent on stderr (this is indicated by the 1 in the error above ..., 1, "Sink: C0644 29421069 0.1.0.tar.gz\n...). sshkit currently can't handle messages on stderr, but most likely even if it would, your file would not be uploaded.
We can only guess the cause of the error from this cryptic message Sink: C0644 to be something like:
- directory
/opt/releasesdoes not exist - no permissions to write to the directory
- somehow invalid filename (but that seems unlikely considering the name above
0.1.0.tar.gz) - another unknown reason why the openssh server on the other side does return a error
Maybe you can get more insight about the error if you try to run the command by hand (maybe with a added verbose flag -v):
scp -v /Users/lessless/Code/myapp/releases/0.1.0.tar.gz [email protected]:/opt/releases
In the meantime we are already working on better error handling.
Cheers Andi 👋
Better error handling is now merged. Feel free to reopen it in case it reappears.