Repository: tensorchord/envd (language: python)

Issue:
bug(conda): Fail to use conda channel when the env.yaml is given
## Description

Seems that `config.conda_channel` does not work with `install.conda_packages(env=xx)`

https://github.com/tensorchord/envd/blob/main/pkg/lang/ir/conda.go#L99

/cc @kemingy @VoVAllen 

## Reproduction

## Additional Info

<!-- It will be very helpful if you can provide the version info by running the command `envd version`. -->

---
<!-- Issue Author: Don't delete this message to encourage other users to support your issue! -->
**Message from the maintainers**:

Impacted by this bug? Give it a 👍. We prioritise the issues with the most 👍.



Discussion / hints:
I will have a look at this issue.

/assign
@kemingy @VoVAllen  Do you know if `conda env update` uses the channel mirror defined in .condarc?
/assign @VoVAllen 
`.condarc` search path: https://conda.io/projects/conda/en/latest/user-guide/configuration/use-condarc.html#searching-for-condarc

I think it's because the user is root when we run `conda env update`. But the `.condarc` is on `/home/envd/.condarc`.

Gotcha, similar issue with pypi cache.
We need an extra test on this.

Fix patch:
diff --git a/pkg/lang/ir/conda.go b/pkg/lang/ir/conda.go
index c675bd9bb..458d77cc7 100644
--- a/pkg/lang/ir/conda.go
+++ b/pkg/lang/ir/conda.go
@@ -39,7 +39,7 @@ const (
 var (
 	// this file can be used by both conda and mamba
 	// https://mamba.readthedocs.io/en/latest/user_guide/configuration.html#multiple-rc-files
-	condarc = fileutil.EnvdHomeDir(".condarc")
+	condarc = "/opt/conda/.condarc"
 	//go:embed install-conda.sh
 	installCondaBash string
 	//go:embed install-mamba.sh


Test patch:
diff --git a/e2e/language/python_test.go b/e2e/language/python_test.go
index a701051a1..2caf87e4e 100644
--- a/e2e/language/python_test.go
+++ b/e2e/language/python_test.go
@@ -54,4 +54,13 @@ var _ = Describe("python", Ordered, func() {
 		e.RunContainer()()
 		e.DestroyContainer()()
 	})
+
+	It("Should build conda with separate channel setting successfully", func() {
+		exampleName := "python/conda_channel"
+		testcase := "e2e"
+		e := e2e.NewExample(e2e.BuildContextDirWithName(exampleName), testcase)
+		e.BuildImage(true)()
+		e.RunContainer()()
+		e.DestroyContainer()()
+	})
 })
diff --git a/e2e/language/testdata/python/conda_channel/build.envd b/e2e/language/testdata/python/conda_channel/build.envd
new file mode 100644
index 000000000..46853559a
--- /dev/null
+++ b/e2e/language/testdata/python/conda_channel/build.envd
@@ -0,0 +1,10 @@
+def build():
+    config.conda_channel(
+        channel="""
+channels:
+  - defaults
+  - dglteam # dgllife in env.yaml only works if specify channels here
+    """
+    )
+    install.conda_packages(env_file="env.yaml")
+    base(os="ubuntu20.04", language="python3.8")
diff --git a/e2e/language/testdata/python/conda_channel/env.yaml b/e2e/language/testdata/python/conda_channel/env.yaml
new file mode 100644
index 000000000..849610dea
--- /dev/null
+++ b/e2e/language/testdata/python/conda_channel/env.yaml
@@ -0,0 +1,3 @@
+name: imarobot # should ignore this name
+dependencies:
+  - dgl
\ No newline at end of file