-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Fail to run build.jobs
with single quotes ('
) in commands
#9397
Comments
build.jobs
with spaces in commandsbuild.jobs
with spaces in commands
Hi @XuehaiPan! By using double quotes (
I did a quick test in https://readthedocs.org/projects/test-builds/builds/17348985/ and |
We could use
Even with double quotes (
That said, I'm not convinced that |
build.jobs
with spaces in commandsbuild.jobs
with spaces in commands
As a workaround, I created a single Bash script #!/usr/bin/env bash
# shellcheck disable=SC2312
exec sed -i -E 's/^ process identity for every yielded instance$/ \0/' "$(python3 -c "print(__import__('psutil').__file__)")" Then put: build:
os: ubuntu-22.04
tools:
python: "3.8"
jobs:
post_install:
- bash docs/source/fix-psutil-docstring.sh in |
The readthedocs.org/readthedocs/doc_builder/environments.py Lines 39 to 62 in 6bf0bed
It seems unnecessary to word splitting. We split the command in readthedocs.org/readthedocs/doc_builder/director.py Lines 334 to 336 in 6bf0bed
Then join them again before executing: readthedocs.org/readthedocs/doc_builder/environments.py Lines 218 to 222 in 6bf0bed
|
EDIT to #9397 (comment): Only run readthedocs.org/readthedocs/doc_builder/environments.py Lines 148 to 151 in 6bf0bed
We can change: commands = getattr(self.data.config.build.jobs, job, [])
for command in commands:
- environment.run(*command.split(), escape_command=False, cwd=cwd)
+ environment.run(['bash', '-c', command], escape_command=False, cwd=cwd) Note that |
build.jobs
with spaces in commandsbuild.jobs
with spaces in commands
I'm not 100% sure about the potential issues of using @ericholscher I saw you put this in my sprint, but I think I marked it as low priority since it involves some research about potential security issues by breaking out the Docker container and also because there is a workaround already (put the command inside a |
I thought it was a somewhat simple bug fix when I saw it, related to the builders. I definitely don't want to run things with |
This is related to #10103 and it may be fixed by the PR associated as well. |
This error happens because we wrap the command as
readthedocs.org/readthedocs/doc_builder/environments.py Lines 386 to 401 in bc4bced
So, using |
build.jobs
with spaces in commandsbuild.jobs
with single quotes ('
) in commands
This is not a great solution for the user. We should find a better way to do this. Seems like there should be a proper way to handle this? Worst case, we can write the command to a file and run it |
@ericholscher yeah, I know it's not the best solution 😄 . I commented here since I found the exact reason of the problem now. From there, we can figure it out how to solve it and how to provide better workarounds. |
Should be documented with a Here's the gem I had to write to circumvent it: - find $READTHEDOCS_OUTPUT/html -type f -iname "*.html" -exec sh -c "echo ln -s \$(basename \"\$1\") \$(dirname \"\$1\")/\$(basename \"\$1\" .html)" sh {} \; |
It'd be great if this could be fixed. Depending on the command you run, having to rely only on double quotes makes things much uglier. |
@ThiefMaster you can put your command/script into a file and run it from Read the Docs as mentioned in #9397 (comment) as a workaround. |
would be overkill for this, but good to know it's possible pre_install:
# RTD python versions are usually behind a bit...
- sed -i -E "/^python_requires = /d" setup.cfg |
Details
Expected Result
A description of what you wanted to happen
Run
build.jobs
command successfullyMy
.readthedocs.yaml
:I want to run command:
after installing the dependencies.
Actual Result
A description of what actually happened
Got errors in raw output:
In:
readthedocs.org/readthedocs/doc_builder/director.py
Lines 339 to 341 in 62effc7
we split the command with whitespace into a list of command-line options. In my use case, I have:
Expected split:
The text was updated successfully, but these errors were encountered: