-
Notifications
You must be signed in to change notification settings - Fork 474
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
SSHKit does not escape command arguments, resulting in failure to clone a path with spaces #1036
Comments
I just found this 8-year-old issue: Issue: Trusted strings, shell escaping and backwards compatibility. |
I ran into the same issue! Glad I'm not the only one using iCloud back-ups. I've noticed that this isn't a problem when Kamal is installed using a bash alias, but that method does not support 1Password integration. |
@MiroslavCsonka It's good to know that I'm not alone! gem "kamal", ">= 2.1.0", require: false, github: "davidstosik/kamal", branch: "v2.1.1/path-space-fix" |
Hi @davidstosik - your change looks like a good idea, so if you could open a PR, I'll get that merged |
Will do! 👍🏻 Update: done! #1066 |
Worked like a charm! 🥳
No more! |
@MiroslavCsonka Thanks for the report. |
I understand this might be unconventional and frowned upon in some circles, but I store my whole source code folder in iCloud and use a symlink for convenience. I don't really have to justify, but that helps me with instant backups and when working with multiple computers. (I expect "use Git" comments, and that's okay. 😬 )
So far, I have had very little issues with this quirk in my setup.
Enters Kamal. Since the announcements and talks at RailsWorld 2024, I've been very excited about trying it out on some pet projects.
I've ignored the issue at first and managed to deploy a pet project to DigitalOcean when my project's path didn't include spaces, but I thought it's now time to report this issue.
When running
kamal deploy
in a project which path includes spaces, Kamal fails to clone the repository:I dug a little bit and it seems related to how SSHKit sometimes constructs commands:
SSHKit::Backend::Local#execute_command
callsOpen3.popen3(cmd.to_command)
hereSSHKit::Command.to_command
eventually calls#to_s
and joins all items in the command array without escaping to produce a string hereInstead,
Open3.popen3
could be passed an array and it would automatically escape spaces where needed:Unfortunately, one of SSHKit's maintainers stated years ago that he was not willing to address that issue by fixing the escaping:
(No such change has been made to SSHKit's docs in the last five years.)
Here's a simple script to illustrate this:
If this can't get fixed in SSHKit, I wonder if that's something that needs to get fixed in Kamal. 🤔
I tried "fixing" this problem in Kamal like this:
It looks like I managed to deploy my app, but I'm sure this is not the right level to do this and there would be more locations where a path needs to be escaped, so I'm not opening a PR yet, as I would rather discuss with people who know more about the project first.
The text was updated successfully, but these errors were encountered: