Skip to content

Conversation

Copy link

Copilot AI commented Aug 26, 2025

Commands were failing with "too many arguments" error when the current working directory's full path contained spaces. This happened because the run method in Commands was using simple string joining instead of proper shell escaping.

The issue occurred in this line:

stdout = `#{cmd.join(" ")}`.chomp

When a path like /home/my work/repo was part of the command arguments, the shell would incorrectly parse it as multiple separate arguments instead of a single path.

Before fix:

cmd = ["/home/my work/repo/exe/litestream", "databases", "--config", "/home/my work/repo/config/litestream.yml"]
cmd.join(" ")
# => "/home/my work/repo/exe/litestream databases --config /home/my work/repo/config/litestream.yml"
# Shell sees 6 arguments: ["/home/my", "work/repo/exe/litestream", "databases", "--config", "/home/my", "work/repo/config/litestream.yml"]
# Result: ERROR failed to run error="too many arguments"

After fix:

Shellwords.shelljoin(cmd)
# => "/home/my\\ work/repo/exe/litestream databases --config /home/my\\ work/repo/config/litestream.yml"  
# Shell correctly sees 4 arguments: ["/home/my work/repo/exe/litestream", "databases", "--config", "/home/my work/repo/config/litestream.yml"]
# Result: Commands work correctly

The fix uses Shellwords.shelljoin(cmd) which properly escapes spaces and other shell metacharacters, ensuring arguments are parsed correctly regardless of their content.

Fixes #66.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copy link
Author

Copilot AI commented Aug 26, 2025

@fractaledmind 👋 This repository doesn't have Copilot instructions. With Copilot instructions, I can understand the repository better, work faster and produce higher quality PRs.

I can generate a .github/copilot-instructions.md file for you automatically. Click here to open a pre-filled issue and assign it to me. I'll write the instructions, and then tag you for review.

Co-authored-by: fractaledmind <5077225+fractaledmind@users.noreply.github.com>
Copilot AI changed the title [WIP] Commands don't run if the current directory's full path contains a space Fix commands failing when current directory path contains spaces Aug 26, 2025
Copilot AI requested a review from fractaledmind August 26, 2025 16:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Commands don't run if the current directory's full path contains a space

2 participants