diff --git a/pkg/dockerfile/fast_generator.go b/pkg/dockerfile/fast_generator.go index a703778ac6..476bd56ecf 100644 --- a/pkg/dockerfile/fast_generator.go +++ b/pkg/dockerfile/fast_generator.go @@ -334,7 +334,7 @@ func (g *FastGenerator) installApt(lines []string, aptTarFile string) ([]string, // Install apt packages if aptTarFile != "" { - lines = append(lines, "RUN --mount=from="+dockercontext.AptBuildContextName+",target="+buildTmpDir+" tar --no-overwrite-dir -xf \""+filepath.Join(buildTmpDir, aptTarFile)+"\" -C /") + lines = append(lines, "RUN --mount=from="+dockercontext.AptBuildContextName+",target="+buildTmpDir+" tar --keep-directory-symlink -xf \""+filepath.Join(buildTmpDir, aptTarFile)+"\" -C /") } return lines, nil } diff --git a/pkg/dockerfile/fast_generator_test.go b/pkg/dockerfile/fast_generator_test.go index 94c8637a2b..264413e5ba 100644 --- a/pkg/dockerfile/fast_generator_test.go +++ b/pkg/dockerfile/fast_generator_test.go @@ -227,7 +227,7 @@ func TestAptInstall(t *testing.T) { dockerfile, err := generator.GenerateDockerfileWithoutSeparateWeights() require.NoError(t, err) dockerfileLines := strings.Split(dockerfile, "\n") - require.Equal(t, "RUN --mount=from=apt,target=/buildtmp tar --no-overwrite-dir -xf \"/buildtmp/apt.9a881b9b9f23849475296a8cd768ea1965bc3152df7118e60c145975af6aa58a.tar.zst\" -C /", dockerfileLines[5]) + require.Equal(t, "RUN --mount=from=apt,target=/buildtmp tar --keep-directory-symlink -xf \"/buildtmp/apt.9a881b9b9f23849475296a8cd768ea1965bc3152df7118e60c145975af6aa58a.tar.zst\" -C /", dockerfileLines[5]) } func TestValidateConfigWithBuildRunItems(t *testing.T) { diff --git a/test-integration/test_integration/fixtures/zsh-package/cog.yaml b/test-integration/test_integration/fixtures/zsh-package/cog.yaml new file mode 100644 index 0000000000..8e51719c91 --- /dev/null +++ b/test-integration/test_integration/fixtures/zsh-package/cog.yaml @@ -0,0 +1,7 @@ +build: + python_version: "3.12" + fast: true + system_packages: + - "zsh" + python_requirements: requirements.txt +predict: "predict.py:Predictor" diff --git a/test-integration/test_integration/fixtures/zsh-package/predict.py b/test-integration/test_integration/fixtures/zsh-package/predict.py new file mode 100644 index 0000000000..27d335ee27 --- /dev/null +++ b/test-integration/test_integration/fixtures/zsh-package/predict.py @@ -0,0 +1,8 @@ +from cog import BasePredictor + +import os + + +class Predictor(BasePredictor): + def predict(self) -> str: + return "hello " + ",".join(os.listdir("/bin")) diff --git a/test-integration/test_integration/fixtures/zsh-package/requirements.txt b/test-integration/test_integration/fixtures/zsh-package/requirements.txt new file mode 100644 index 0000000000..7e820f150e --- /dev/null +++ b/test-integration/test_integration/fixtures/zsh-package/requirements.txt @@ -0,0 +1 @@ +torch==2.5.0 diff --git a/test-integration/test_integration/test_predict.py b/test-integration/test_integration/test_predict.py index 960622bd47..2e26b4753f 100644 --- a/test-integration/test_integration/test_predict.py +++ b/test-integration/test_integration/test_predict.py @@ -432,3 +432,26 @@ def test_predict_optional_project(tmpdir_factory): # stdout should be clean without any log messages so it can be piped to other commands assert result.returncode == 0 assert result.stdout == "hello No One\n" + + +def test_predict_zsh_package(docker_image): + project_dir = Path(__file__).parent / "fixtures/zsh-package" + build_process = subprocess.run( + ["cog", "build", "-t", docker_image], + cwd=project_dir, + capture_output=True, + ) + assert build_process.returncode == 0 + + result = subprocess.run( + ["cog", "predict", "--debug", docker_image], + cwd=project_dir, + check=True, + capture_output=True, + text=True, + timeout=DEFAULT_TIMEOUT, + ) + # stdout should be clean without any log messages so it can be piped to other commands + assert result.returncode == 0 + assert ",sh," in result.stdout + assert ",zsh," in result.stdout