kcl-lang / kcl

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

kcl command requires sudo on MacOS #1688

Closed expz closed 1 month ago

expz commented 1 month ago

Bug Report

If you do not use sudo to run the kcl command on MacOS, then you get an error.

1. Minimal reproduce step (Required)

brew install kcl-lang/tap/kcl
echo 'test = 123' > test.k
kcl test.k

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

The YAML output

test: 123

3. What did you see instead (Required)

2024/10/12 00:09:24 kclvm.go:47: [WARN] install kclvm failed: open /Users/user/Library/Preferences/init.lock: permission denied
2024/10/12 00:09:24 kclvm.go:52: [WARN] install kclvm failed: open /Users/user/Library/Preferences/bin/kclvm_cli~0: permission denied
panic: exec: "kclvm_cli": executable file not found in $PATH

goroutine 1 [running]:
kcl-lang.io/kcl-go/pkg/runtime.(*Runtime).Start(0x1400024ca10)
    /home/runner/go/pkg/mod/kcl-lang.io/kcl-go@v0.10.1/pkg/runtime/runtime.go:54 +0x1b4
kcl-lang.io/kcl-go/pkg/runtime.initRuntime(0x0?)
    /home/runner/go/pkg/mod/kcl-lang.io/kcl-go@v0.10.1/pkg/runtime/init.go:43 +0x14c
kcl-lang.io/kcl-go/pkg/runtime.GetRuntime.func1()
    /home/runner/go/pkg/mod/kcl-lang.io/kcl-go@v0.10.1/pkg/runtime/init.go:26 +0x20
sync.(*Once).doSlow(0x1?, 0x140006232c0?)
    /opt/hostedtoolcache/go/1.23.1/x64/src/sync/once.go:76 +0xf8
sync.(*Once).Do(...)
    /opt/hostedtoolcache/go/1.23.1/x64/src/sync/once.go:67
kcl-lang.io/kcl-go/pkg/runtime.GetRuntime()
    /home/runner/go/pkg/mod/kcl-lang.io/kcl-go@v0.10.1/pkg/runtime/init.go:26 +0x40
kcl-lang.io/kcl-go/pkg/service.NewKclvmServiceClient(...)
    /home/runner/go/pkg/mod/kcl-lang.io/kcl-go@v0.10.1/pkg/service/client_kclvm_service.go:22
kcl-lang.io/kcl-go/pkg/kcl.Service(...)
    /home/runner/go/pkg/mod/kcl-lang.io/kcl-go@v0.10.1/pkg/kcl/rpc_service.go:12
kcl-lang.io/kcl-go/pkg/kcl.runWithHooks({0x140005af3c8, 0x0, 0x0}, {0x108cb9930, 0x1, 0x1}, {0x140005af498, 0x1, 0x1})
    /home/runner/go/pkg/mod/kcl-lang.io/kcl-go@v0.10.1/pkg/kcl/api.go:436 +0xfc
kcl-lang.io/kcl-go/pkg/kcl.run(...)
    /home/runner/go/pkg/mod/kcl-lang.io/kcl-go@v0.10.1/pkg/kcl/api.go:445
kcl-lang.io/kcl-go/pkg/kcl.RunWithOpts({0x140005af498?, 0x140001d6180?, 0x0?})
    /home/runner/go/pkg/mod/kcl-lang.io/kcl-go@v0.10.1/pkg/kcl/api.go:372 +0x50
kcl-lang.io/kpm/pkg/client.(*KpmClient).Run.func1(0x140001d6180)
    /home/runner/go/pkg/mod/kcl-lang.io/kpm@v0.10.0/pkg/client/run.go:599 +0x2c4
kcl-lang.io/kpm/pkg/client.(*VirtualPkgVisitor).Visit(0x0?, 0x0?, 0x140006f7aa0)
    /home/runner/go/pkg/mod/kcl-lang.io/kpm@v0.10.0/pkg/client/visitor.go:87 +0x2b4
kcl-lang.io/kpm/pkg/client.(*KpmClient).Run(0x140007eb4a0, {0x140005afa78, 0xe, 0x140006f7f80?})
    /home/runner/go/pkg/mod/kcl-lang.io/kpm@v0.10.0/pkg/client/run.go:574 +0x214
kcl-lang.io/cli/pkg/options.(*RunOptions).Run(0x1400019f180)
    /home/runner/work/cli/cli/pkg/options/run.go:128 +0x498
kcl-lang.io/cli/cmd/kcl/commands.NewRunCmd.func1(0x140006f5900?, {0x140004ed140?, 0x4?, 0x1063966ec?})
    /home/runner/work/cli/cli/cmd/kcl/commands/run.go:61 +0x4c
github.com/spf13/cobra.(*Command).execute(0x140007ec008, {0x140001da0d0, 0x1, 0x1})
    /home/runner/go/pkg/mod/github.com/spf13/cobra@v1.8.1/command.go:985 +0x834
github.com/spf13/cobra.(*Command).ExecuteC(0x140007ec008)
    /home/runner/go/pkg/mod/github.com/spf13/cobra@v1.8.1/command.go:1117 +0x344
github.com/spf13/cobra.(*Command).Execute(...)
    /home/runner/go/pkg/mod/github.com/spf13/cobra@v1.8.1/command.go:1041
kcl-lang.io/cli/cmd/kcl/commands.executeRunCmd({0x140001da0d0, 0x1, 0x1})
    /home/runner/work/cli/cli/cmd/kcl/commands/plugin.go:17 +0x6c
kcl-lang.io/cli/cmd/kcl/commands.bootstrapCmdPlugin(0x140004d2008?, {0x106ecc4d0, 0x1400061e660})
    /home/runner/work/cli/cli/cmd/kcl/commands/plugin.go:67 +0x41c
kcl-lang.io/cli/cmd/kcl/commands.NewWithName({0x106395c00, 0x3})
    /home/runner/work/cli/cli/cmd/kcl/commands/root.go:130 +0x338
kcl-lang.io/cli/cmd/kcl/commands.New(...)
    /home/runner/work/cli/cli/cmd/kcl/commands/root.go:99
main.main()
    /home/runner/work/cli/cli/cmd/kcl/main.go:14 +0x28

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

kcl version 0.10.0

Peefy commented 1 month ago

Hello @expz Thanks for the feedback. We have released kcl v0.10.4, you can try it again.

expz commented 1 month ago

Thank you @Peefy ! It works now.