Skip to content

Commit e7f4b09

Browse files
authored
Merge pull request #329 from Peefy/faq-kcl-docker-start
faq: add kcl start in docker containers
2 parents d020766 + 02aa393 commit e7f4b09

File tree

7 files changed

+96
-2
lines changed

7 files changed

+96
-2
lines changed

docs/user_docs/support/faq-install.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,12 @@ Please ensure that the following dependencies are in your PATH:
3131
## Encountering exit status 0xc0000135 error on Windows platform
3232

3333
Please ensure that `.NET Framework` and `MSVC` are installed on your Windows. If not installed, you can install them and try again.
34+
35+
## Errors on Starting/Running KCL inside a Container for "Permission Denied" or "File Not Found"
36+
37+
The issue is due to KCL requiring write permissions for its default global configuration and global package cache at compile time. One solution is to set the global configuration and package directory to the `/tmp` folder. For detailed Dockerfile configuration, please see [here](https://github.com/kcl-lang/cli/blob/main/Dockerfile).
38+
39+
```dockerfile
40+
ENV KCL_PKG_PATH=/tmp
41+
ENV KCL_CACHE_PATH=/tmp
42+
```

i18n/zh-CN/docusaurus-plugin-content-docs/current/user_docs/support/faq-install.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,12 @@ xattr -rd com.apple.quarantine /path/to/kcl
3131
## 在 Windows 平台上遇到 exit status 0xc0000135 错误
3232

3333
请确保您的 Windows 上安装了 `.NET Framework``MSVC`,如没有安装,可以安装并重试。
34+
35+
## 在容器中启动/运行 KCL 报没有权限或者找不到文件的错误
36+
37+
这是因为 KCL 在编译时的默认全局配置和全局包缓存需要写入权限,一种解决方式是将全局配置和包目录设置到 `/tmp` 文件夹,详见[这里](https://github.com/kcl-lang/cli/blob/main/Dockerfile) 的 Dockerfile 配置
38+
39+
```dockerfile
40+
ENV KCL_PKG_PATH=/tmp
41+
ENV KCL_CACHE_PATH=/tmp
42+
```

i18n/zh-CN/docusaurus-plugin-content-docs/version-0.8/reference/model/file.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ weight: 100
88

99
## read
1010

11-
`read(filepath: string) -> str`
11+
`read(filepath: str) -> str`
1212

1313
读取文件 `filepath` 中的内容,并返回一个字符串实例。
1414

@@ -29,3 +29,15 @@ weight: 100
2929
`workdir() -> str`
3030

3131
返回当前工作目录的路径。
32+
33+
## exists
34+
35+
`exists(filepath: str) -> bool`
36+
37+
判断文件路径是否存在。如果路径指向一个存在的实体,则返回 True。此函数会遍历符号链接以查询目标文件的信息。
38+
39+
## abs
40+
41+
`abs(filepath: str) -> str`
42+
43+
返回路径的规范化绝对形式,其中所有中间路径均已规范化并解析为符号链接。

i18n/zh-CN/docusaurus-plugin-content-docs/version-0.8/user_docs/support/faq-install.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,12 @@ xattr -rd com.apple.quarantine /path/to/kcl
3131
## 在 Windows 平台上遇到 exit status 0xc0000135 错误
3232

3333
请确保您的 Windows 上安装了 `.NET Framework``MSVC`,如没有安装,可以安装并重试。
34+
35+
## 在容器中启动/运行 KCL 报没有权限或者找不到文件的错误
36+
37+
这是因为 KCL 在编译时的默认全局配置和全局包缓存需要写入权限,一种解决方式是将全局配置和包目录设置到 `/tmp` 文件夹,详见[这里](https://github.com/kcl-lang/cli/blob/main/Dockerfile) 的 Dockerfile 配置
38+
39+
```dockerfile
40+
ENV KCL_PKG_PATH=/tmp
41+
ENV KCL_CACHE_PATH=/tmp
42+
```

versioned_docs/version-0.8/reference/model/file.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ weight: 100
88

99
## read
1010

11-
`read(filepath: string) -> str`
11+
`read(filepath: str) -> str`
1212

1313
Read the contents of the file `filepath` and return a string instance.
1414

@@ -29,3 +29,15 @@ Return the root path of the current KCL module (kcl.mod file path or single \*.k
2929
`workdir() -> str`
3030

3131
Return the path of the current working directory.
32+
33+
## exists
34+
35+
`exists(filepath: str) -> bool`
36+
37+
Whether this file path exists. Returns true if the path points at an existing entity. This function will traverse symbolic links to query information about the destination file.
38+
39+
## abs
40+
41+
`abs(filepath: str) -> str`
42+
43+
Returns the canonical, absolute form of the path with all intermediate components normalized and symbolic links resolved.

versioned_docs/version-0.8/user_docs/support/faq-install.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,12 @@ Please ensure that the following dependencies are in your PATH:
3131
## Encountering exit status 0xc0000135 error on Windows platform
3232

3333
Please ensure that `.NET Framework` and `MSVC` are installed on your Windows. If not installed, you can install them and try again.
34+
35+
## Errors on Starting/Running KCL inside a Container for "Permission Denied" or "File Not Found"
36+
37+
The issue is due to KCL requiring write permissions for its default global configuration and global package cache at compile time. One solution is to set the global configuration and package directory to the `/tmp` folder. For detailed Dockerfile configuration, please see [here](https://github.com/kcl-lang/cli/blob/main/Dockerfile).
38+
39+
```dockerfile
40+
ENV KCL_PKG_PATH=/tmp
41+
ENV KCL_CACHE_PATH=/tmp
42+
```

versioned_docs/version-0.8/user_docs/support/faq-kcl.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2512,3 +2512,37 @@ worldString: world
25122512
s: Hello world
25132513
raw_s: Hello ${worldString}
25142514
```
2515+
2516+
## 59. How does KCL infer return types in lambdas?
2517+
2518+
For lambda(s),KCL automatically infers the return value type in the function body, although we can explicitly specify it. An example KCL code over here is:
2519+
2520+
```KCL
2521+
f1 = lambda t: Type1 {
2522+
Type2 {}
2523+
} # The type of f1 is (Type1) -> Type2
2524+
2525+
f2 = lambda t: Type1 -> Type2 {
2526+
Type2 {}
2527+
} # The type of f2 is (Type1) -> Type2
2528+
```
2529+
2530+
## 60. How to convert a list of lists to a single list in KCL?
2531+
2532+
To convert a list of lists into a single list, we use the `sum()` function. For example if we have a number of lists such as `[[1,2],[3,4]], [5,6]`, we use the KCL code given below to convert these three lists into a single list:
2533+
2534+
```KCL
2535+
final_list = sum([[1,2],[3,4]],[5,6])
2536+
```
2537+
2538+
The above KCL code gives the output:
2539+
2540+
```yaml
2541+
final_list:
2542+
- 5
2543+
- 6
2544+
- 1
2545+
- 2
2546+
- 3
2547+
- 4
2548+
```

0 commit comments

Comments
 (0)