fix: handle spaces in paths when running shell commands#377
Merged
HenryNdubuaku merged 2 commits intocactus-compute:mainfrom Feb 23, 2026
Merged
Conversation
Added shlex.quote() to properly escape paths with spaces in run_command(). This fixes build failures when the cactus repo is cloned into a directory path containing spaces (e.g., 'Programming Projects'). Signed-off-by: Adithya Narayanan <[email protected]>
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes cactus build failures when the repository path contains spaces by adjusting how shell commands are constructed/executed in the CLI.
Changes:
- Added
shleximport. - Updated
run_command()toshlex.quote()string commands before executing them viasubprocess.run(..., shell=True).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Improved fix based on code review feedback: - Removed shlex.quote() approach which has Windows compatibility issues - Use subprocess.run with shell=False by converting string paths to lists - This is more robust, secure, and cross-platform The shell=False approach: - Handles paths with spaces correctly without quoting - Works on both Unix and Windows - Avoids shell injection risks - Respects script shebangs when execute bit is set Signed-off-by: Adithya Narayanan <[email protected]>
Collaborator
|
Thanks so much for this @adithya-n05 |
ncylich
pushed a commit
that referenced
this pull request
Feb 24, 2026
* fix: handle spaces in paths when running shell commands Added shlex.quote() to properly escape paths with spaces in run_command(). This fixes build failures when the cactus repo is cloned into a directory path containing spaces (e.g., 'Programming Projects'). Signed-off-by: Adithya Narayanan <[email protected]> * fix: use shell=False to handle spaces in paths safely Improved fix based on code review feedback: - Removed shlex.quote() approach which has Windows compatibility issues - Use subprocess.run with shell=False by converting string paths to lists - This is more robust, secure, and cross-platform The shell=False approach: - Handles paths with spaces correctly without quoting - Works on both Unix and Windows - Avoids shell injection risks - Respects script shebangs when execute bit is set Signed-off-by: Adithya Narayanan <[email protected]> --------- Signed-off-by: Adithya Narayanan <[email protected]>
cattermelon1234
pushed a commit
to cattermelon1234/cactus
that referenced
this pull request
Feb 28, 2026
…te#377) * fix: handle spaces in paths when running shell commands Added shlex.quote() to properly escape paths with spaces in run_command(). This fixes build failures when the cactus repo is cloned into a directory path containing spaces (e.g., 'Programming Projects'). Signed-off-by: Adithya Narayanan <[email protected]> * fix: use shell=False to handle spaces in paths safely Improved fix based on code review feedback: - Removed shlex.quote() approach which has Windows compatibility issues - Use subprocess.run with shell=False by converting string paths to lists - This is more robust, secure, and cross-platform The shell=False approach: - Handles paths with spaces correctly without quoting - Works on both Unix and Windows - Avoids shell injection risks - Respects script shebangs when execute bit is set Signed-off-by: Adithya Narayanan <[email protected]> --------- Signed-off-by: Adithya Narayanan <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #379
Problem
The
cactus buildcommand fails when the repo is cloned into a directory path containing spaces (e.g.,/Users/name/Programming Projects/cactus).Error:
The issue is in
run_command()which passes string paths tosubprocess.run()withshell=True, causing the shell to interpret spaces as argument separators.Solution
Changed
run_command()to useshell=False(the default) by converting string paths to a list. This avoids shell interpretation entirely and handles paths with spaces correctly.Before:
After:
Why this approach?
shlex.quote()which uses single quotes that break on Windows)shell=True#!/bin/bashare executed with the correct interpreterTesting
Tested with a repo cloned to a path containing spaces:
cactus build --pythonnow completes successfully.