Skip to content
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

kcl mod pull fails across filesystem boundaries #1775

Closed
mproffitt opened this issue Dec 8, 2024 · 1 comment
Closed

kcl mod pull fails across filesystem boundaries #1775

mproffitt opened this issue Dec 8, 2024 · 1 comment
Assignees
Labels
bug Something isn't working tool Issues or PRs related to kcl tools inlucding format, lint, validation, document tools, etc.

Comments

@mproffitt
Copy link

mproffitt commented Dec 8, 2024

Bug Report

When trying to run kcl mod pull where /tmp is on a different filesystem to the module being built, the pull command fails with invalid cross-device link

I believe that this comes from

if let Err(e) = fs::rename(&src_path, &dest_path) {

however fs::rename does not work across filesystem boundaries as it only performs a simple rename, leaving the data in place on disk rather than completely moving it to the new location.

1. Minimal reproduce step (Required)

The simplest way to test this is to run KCL in a docker container using a bind mount to the local directory

mkdir kcltest && cd kcltest
docker run -it \
    --mount type=bind,source="$(pwd)",target=/test \
    --name kcltest kcllang/kcl:latest sh -c 'cd test; kcl mod pull k8s'

2. What did you expect to see? (Required)

The k8s module should be added at oci/ghcr.io/kcl-lang/k8s

3. What did you see instead (Required)

The pull command fails with invalid cross-device link

start to pull oci://ghcr.io/kcl-lang/k8s
the lastest version '1.31.2' will be downloaded
downloading 'kcl-lang/k8s:1.31.2' from 'ghcr.io/kcl-lang/k8s:1.31.2'
rename /tmp/1154039051/git oci/ghcr.io/kcl-lang/k8s: invalid cross-device link

4. What is your KCL components version? (Required)

N/A

EDIT:

Note

Whilst this can be mitigated by setting the value of TMPDIR to a location on the same filesystem as the current module, this feels more like a workaround than a viable long term solution.

For example, the following works:

mkdir -p kcltest/tmp && cd kcltest
docker run -it \
   --mount type=bind,source="$(pwd)",target=/test \
   --name kcltest kcllang/kcl:latest sh -c 'cd test; TMPDIR=/test/tmp kcl mod pull k8s'
start to pull oci://ghcr.io/kcl-lang/k8s
the lastest version '1.31.2' will be downloaded
downloading 'kcl-lang/k8s:1.31.2' from 'ghcr.io/kcl-lang/k8s:1.31.2'
pulled k8s 1.31.2 successfully
@Peefy Peefy added bug Something isn't working tool Issues or PRs related to kcl tools inlucding format, lint, validation, document tools, etc. labels Dec 9, 2024
@Peefy Peefy added this to the v0.11.0 Release milestone Dec 9, 2024
@zong-zhe
Copy link
Contributor

Hi @mproffitt 😄

I failed to reproduce this problem in v0.11.0-alpha.1,

This is a screenshot of my execution:

Screenshot 2024-12-16 at 16 46 04

The code responsible for pulling the KCL tripartite library is not in this repository. In this PR kcl-lang/kpm#567, I will try to replace the os.Rename method with the utils.MoveOrCopy method and use a rollback. If rename fails, It will use copy.

And this is my debug version:

Screenshot 2024-12-16 at 16 47 18

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working tool Issues or PRs related to kcl tools inlucding format, lint, validation, document tools, etc.
Projects
None yet
Development

No branches or pull requests

3 participants