Skip to content

Commit

Permalink
fix(lang): Fix user-defined packages (#168)
Browse files Browse the repository at this point in the history
* fix: Use sudo

Signed-off-by: Ce Gao <cegao@tensorchord.ai>

* fix: Add test

Signed-off-by: Ce Gao <cegao@tensorchord.ai>
  • Loading branch information
gaocegege committed May 18, 2022
1 parent 74c8e20 commit d600431
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
1 change: 1 addition & 0 deletions cmd/envd/testdata/build.envd
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ base(os="ubuntu20.04", language="python3")
pip_package(name = [
"ormb",
])
install_package(name = ["screenfetch"])
3 changes: 1 addition & 2 deletions cmd/envd/up.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,8 @@ var CommandUp = &cli.Command{
Flags: []cli.Flag{
&cli.StringFlag{
Name: "tag",
Usage: "Name and optionally a tag in the 'name:tag' format",
Usage: "Name and optionally a tag in the 'name:tag' format (default: PROJECT:dev)",
Aliases: []string{"t"},
Value: "envd:dev",
},
&cli.PathFlag{
Name: "path",
Expand Down
6 changes: 3 additions & 3 deletions pkg/lang/ir/graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ func (g Graph) compilePyPIPackages(root llb.State) llb.State {
}

cacheDir := "/home/envd/.cache/pip"

run := root.Run(llb.Shlex(sb.String()), llb.WithCustomNamef("pip install %s",
cmd := sb.String()
run := root.Run(llb.Shlex(cmd), llb.WithCustomNamef("pip install %s",
strings.Join(g.PyPIPackages, " ")))
run.AddMount(cacheDir, llb.Scratch(),
llb.AsPersistentCacheDir("/"+cacheDir, llb.CacheMountShared))
Expand Down Expand Up @@ -214,7 +214,7 @@ func (g Graph) compileSystemPackages(root llb.State) llb.State {

// Compose the package install command.
var sb strings.Builder
sb.WriteString("apt-get install -y --no-install-recommends")
sb.WriteString("sudo apt-get install -y --no-install-recommends")

for _, pkg := range g.SystemPackages {
sb.WriteString(fmt.Sprintf(" %s", pkg))
Expand Down

0 comments on commit d600431

Please sign in to comment.