kcl-lang / kcl

KCL Programming Language (CNCF Sandbox Project). https://kcl-lang.io
https://kcl-lang.io
Apache License 2.0
1.61k stars 113 forks source link

failed to compile the kcl package: edge already exists #1387

Closed SjuulJanssen closed 4 months ago

SjuulJanssen commented 4 months ago

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

kcl mod init a
cd a
kcl mod add k8s
cd ../
kcl mod init b
cd b
kcl mod add ../a
cd ../
kcl mod init c
cd c
kcl mod add ../b
kcl run

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

No errors

3. What did you see instead (Required)

An error:

failed to compile the kcl package
edge already exists

Full log:

kcl mod init a
cd a
kcl mod add k8s
cd ../
kcl mod init b
cd b
kcl mod add ../a
cd ../
kcl mod init c
cd c
kcl mod add ../b
kcl run
creating new :/home/coder/projects/tmp/a/kcl.mod
creating new :/home/coder/projects/tmp/a/kcl.mod.lock
creating new :/home/coder/projects/tmp/a/main.k
package 'a' init finished
adding dependency 'k8s'
the lastest version '1.29' will be added
downloading 'kcl-lang/k8s:1.29' from 'ghcr.io/kcl-lang/k8s:1.29'
add dependency 'k8s' successfully
creating new :/home/coder/projects/tmp/b/kcl.mod
creating new :/home/coder/projects/tmp/b/kcl.mod.lock
creating new :/home/coder/projects/tmp/b/main.k
package 'b' init finished
adding dependency 'a'
downloading 'kcl-lang/k8s:1.29' from 'ghcr.io/kcl-lang/k8s:1.29'
add dependency 'a:0.0.1' successfully
creating new :/home/coder/projects/tmp/c/kcl.mod
creating new :/home/coder/projects/tmp/c/kcl.mod.lock
creating new :/home/coder/projects/tmp/c/main.k
package 'c' init finished
adding dependency 'b'
downloading 'kcl-lang/k8s:1.29' from 'ghcr.io/kcl-lang/k8s:1.29'
add dependency 'b:0.0.1' successfully
downloading 'kcl-lang/k8s:1.29' from 'ghcr.io/kcl-lang/k8s:1.29'
failed to compile the kcl package
edge already exists

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

kcl --version
kcl version 0.8.9

5. Example use case

In my use case I was building a "shared" module (a) and that shared module would then be used in my application (b) this application would be then used in stage (c) test, acceptance and prod

SjuulJanssen commented 4 months ago

How I interpret the error: The k8s mod is a requirement of a and thus also for b. But when c tries to install it, kcl is unable to determine that it can re-use the module that a is referring to.

Peefy commented 4 months ago

Hello @SjuulJanssen Thank you very much for your detailed feedback. I did not reproduce the issue in kcl v0.9.0-beta.1 Perhaps you can upgrade to KCL version. The full log of my KCL is

kcl mod init a
cd a
kcl mod add k8s
cd ../
kcl mod init b
cd b
kcl mod add ../a
cd ../
kcl mod init c
cd c
kcl mod add ../b
kcl run
creating new :./a/kcl.mod
creating new :./a/kcl.mod.lock
creating new :./a/main.k
package 'a' init finished
adding dependency 'k8s'
add dependency 'k8s' successfully
creating new :./b/kcl.mod
creating new :./b/kcl.mod.lock
creating new :./b/main.k
package 'b' init finished
adding dependency 'a'
add dependency 'a:0.0.1' successfully
creating new :./c/kcl.mod
creating new :./c/kcl.mod.lock
creating new :./c/main.k
package 'c' init finished
adding dependency 'b'
add dependency 'b:0.0.1' successfully
The_first_kcl_program: Hello World!
SjuulJanssen commented 4 months ago

You're answering fast! Kudo's

I was able to test it with 0.9.0-beta.1 and indeed the problem is gone.