kcl-lang / lib

KCL Multiple Language Bindings including Rust, Go, Python, Java, Kotlin, .NET, Swift, Lua, Node.js, Zig, C, C++, WASM, etc.
https://www.kcl-lang.io/docs/reference/xlang-api/overview
Apache License 2.0
8 stars 10 forks source link

Unable to run `kcl` 0.10.3 on NixOS #153

Open diefans opened 22 hours ago

diefans commented 22 hours ago

Bug Report

I am using NixOS, where the directories of packages are readonly.

The kcl installer v0.10.3 seems to try to create a directory kcl under $KCL_LIB_HOME

panic: mkdir /nix/store/kyhhm0yx0h7ckrjzx28kazvp8vmx237c-kclvm-0.10.3/lib/kcl: read-only file system

goroutine 1 [running]:
kcl-lang.io/lib/go/native.initClient.func1()
    kcl-lang.io/lib@v0.10.3/go/native/client.go:41 +0x147
sync.(*Once).doSlow(0xa75e28?, 0x1ea3020?)
    sync/once.go:76 +0xb4
sync.(*Once).Do(...)
    sync/once.go:67
kcl-lang.io/lib/go/native.initClient(0x1ea2f40?)
    kcl-lang.io/lib@v0.10.3/go/native/client.go:38 +0x3a
kcl-lang.io/lib/go/native.NewNativeServiceClientWithPluginAgent(...)
    kcl-lang.io/lib@v0.10.3/go/native/client.go:62
kcl-lang.io/lib/go/native.NewNativeServiceClient()
    kcl-lang.io/lib@v0.10.3/go/native/client.go:58 +0x29
kcl-lang.io/kcl-go/pkg/kcl.Service(...)
    kcl-lang.io/kcl-go@v0.10.3/pkg/kcl/service.go:10
kcl-lang.io/kcl-go/pkg/kcl.runWithHooks({0xc000867728, 0x0, 0x0}, {0x3b47dd0, 0x1, 0x1}, {0xc0008677f8, 0x1, 0x1})
    kcl-lang.io/kcl-go@v0.10.3/pkg/kcl/api.go:436 +0x15f
kcl-lang.io/kcl-go/pkg/kcl.run(...)
    kcl-lang.io/kcl-go@v0.10.3/pkg/kcl/api.go:445
kcl-lang.io/kcl-go/pkg/kcl.RunWithOpts({0xc0008677f8?, 0xc000000fc0?, 0x0?})
    kcl-lang.io/kcl-go@v0.10.3/pkg/kcl/api.go:372 +0x45
kcl-lang.io/kpm/pkg/client.(*KpmClient).Run.func1(0xc000000fc0)
    kcl-lang.io/kpm@v0.10.0/pkg/client/run.go:599 +0x3aa
kcl-lang.io/kpm/pkg/client.(*PkgVisitor).Visit(0xc000550638, 0x0?, 0xc00086ca20)
    kcl-lang.io/kpm@v0.10.0/pkg/client/visitor.go:52 +0x62
kcl-lang.io/kpm/pkg/client.(*KpmClient).Run(0xc0008726e0, {0xc000867bc0, 0xe, 0x90?})
    kcl-lang.io/kpm@v0.10.0/pkg/client/run.go:574 +0x20d
kcl-lang.io/cli/pkg/options.(*RunOptions).Run(0xc00018b400)
    kcl-lang.io/cli/pkg/options/run.go:128 +0x6a5
kcl-lang.io/cli/cmd/kcl/commands.NewRunCmd.func1(0xc000510400?, {0xc0004f4a10?, 0x4?, 0x23d698b?})
    kcl-lang.io/cli/cmd/kcl/commands/run.go:61 +0x49
github.com/spf13/cobra.(*Command).execute(0xc00045ec08, {0xc0004f4930, 0x7, 0x7})
    github.com/spf13/cobra@v1.8.1/command.go:985 +0xaaa
github.com/spf13/cobra.(*Command).ExecuteC(0xc00045e908)
    github.com/spf13/cobra@v1.8.1/command.go:1117 +0x3ff
github.com/spf13/cobra.(*Command).Execute(...)
    github.com/spf13/cobra@v1.8.1/command.go:1041
main.main()
    kcl-lang.io/cli/cmd/kcl/main.go:14 +0x2a
make: *** [makefile:12: search.lti] Error 2

This commit was introducing it: https://github.com/kcl-lang/lib/commit/3c73ffd5173227b3fa4893f653ac450af71a6069

1. Minimal reproduce step (Required)

build kcl v0.10.3 for nix and run it, so that the internal installer is called...

IMHO for NixOS the whole installer and caching thingy should be disabled since there is not much "dynamic" expected in terms of installing/downloading/caching the kclvm library... Or there should be some pre-fetch/prepare stage for this cache, which then gets commited into the nix package.

Peefy commented 11 hours ago

Thanks for the feedback.

https://github.com/kcl-lang/lib/pull/154 Can this modification solve the problem of creating subfolders?