Skip to content

Commit 331e474

Browse files
authored
Build: hardcode the Docker username for now (#10172)
* Build: hardcode the Docker username for now This is a quick fix for a hotfix. `RTD_DOCKER_USER` is `docs:docs` so we can't use it inside the path. * Build: deal with PATH on old Docker images (stable, latest, testing) These old images are using `pyenv` instead of `asdf`, so we need to use some different paths to find the binaries. * Lint
1 parent 8dd6732 commit 331e474

File tree

1 file changed

+26
-8
lines changed

1 file changed

+26
-8
lines changed

readthedocs/doc_builder/environments.py

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -312,15 +312,33 @@ def run(self):
312312
# /home/docs/.asdf/shims:/home/docs/.asdf/bin
313313
# :/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
314314
# docs@bfe702e31cdd:~$
315-
asdf_paths = (
316-
f"/home/{settings.RTD_DOCKER_USER}/.asdf/shims"
317-
f":/home/{settings.RTD_DOCKER_USER}/.asdf/bin"
318-
)
319-
if settings.RTD_DOCKER_COMPOSE:
320-
asdf_paths += ":/root/.asdf/shims:/root/.asdf/bin"
321-
315+
#
316+
# On old Docker images we have different PATH:
317+
#
318+
# $ sudo docker run -it readthedocs/build:latest /bin/bash
319+
# docs@656e38a30fa4:/$ echo $PATH
320+
# /home/docs/.pyenv/shims:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/docs/.conda/bin:/home/docs/.pyenv/bin
321+
# docs@656e38a30fa4:/$
322322
default_paths = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
323-
environment["PATH"] = f"{asdf_paths}:{default_paths}"
323+
if self.build_env.container_image in (
324+
"readthedocs/build:ubuntu-22.04",
325+
"readthedocs/build:ubuntu-20.04",
326+
):
327+
# Use ASDF path for newer images
328+
python_paths = "/home/docs/.asdf/shims:/home/docs/.asdf/bin"
329+
paths = f"{python_paths}:{default_paths}"
330+
331+
# On local development, we are using root user
332+
if settings.RTD_DOCKER_COMPOSE:
333+
paths = paths.replace("/home/docs/", "/root/")
334+
else:
335+
# Use PYENV for older images
336+
paths = (
337+
"/home/docs/.pyenv/shims:/home/docs/.cargo/bin"
338+
f":{default_paths}:"
339+
"/home/docs/.conda/bin:/home/docs/.pyenv/bin"
340+
)
341+
environment["PATH"] = paths
324342

325343
# Prepend the BIN_PATH if it's defined
326344
if self.bin_path:

0 commit comments

Comments
 (0)