Skip to content

🐞 sdk(elixir): Adding a directory fails #5412

Closed

Description

@gmile

What is the issue?

The following code fails with an error:

Mix.install([{:dagger, github: "dagger/dagger", sparse: "sdk/elixir"}])

client = Dagger.connect!()

src =
  client
  |> Dagger.Query.git("https://github.com/hexpm/hexpm")
  |> Dagger.GitRepository.branch("main")
  |> Dagger.GitRef.tree()

client
|> Dagger.Query.container()
|> Dagger.Container.from("hexpm/elixir:1.15.2-erlang-26.0.2-alpine-3.18.2")
|> Dagger.Container.with_workdir("/src")
|> Dagger.Container.with_directory("/src", src)
|> Dagger.Container.with_exec("mix deps.get")
|> Dagger.Container.stdout()

Log output

Connected to engine d7ea1f45c95e
** (Protocol.UndefinedError) protocol Jason.Encoder not implemented for {:ok, "eyJsbGIiOnsiZGVmIjpbIkdxSUJDaUZuYVhRNkx5OW5hWFJvZFdJdVkyOXRMMmhsZUhCdEwyaGxlSEJ0STIxaGFXNFNKd29VWjJsMExtRjFkR2hvWldGa1pYSnpaV055WlhRU0QwZEpWRjlCVlZSSVgwaEZRVVJGVWhJbENoTm5hWFF1WVhWMGFIUnZhMlZ1YzJWamNtVjBFZzVIU1ZSZlFWVlVTRjlVVDB0RlRoSXRDZ3RuYVhRdVpuVnNiSFZ5YkJJZWFIUjBjSE02THk5bmFYUm9kV0l1WTI5dEwyaGxlSEJ0TDJobGVIQnRXZ0E9IiwiQ2trS1IzTm9ZVEkxTmpveE5EUTBaRFppTXpZd05UaGpPVEl6TkRSa1l6RmhOMlV6TWpobE5EazVaakE0TXpGbU1qVXpOVFkyT1RCa1lqSm1aR1l4TWpsalkySTFOakl6WkdSaiJdLCJtZXRhZGF0YSI6eyJzaGEyNTY6MTQ0NGQ2YjM2MDU4YzkyMzQ0ZGMxYTdlMzI4ZTQ5OWYwODMxZjI1MzU2NjkwZGIyZmRmMTI5Y2NiNTYyM2RkYyI6eyJjYXBzIjp7InNvdXJjZS5naXQiOnRydWUsInNvdXJjZS5naXQuZnVsbHVybCI6dHJ1ZX0sInByb2dyZXNzX2dyb3VwIjp7ImlkIjoiW3tcIm5hbWVcIjpcIlwiLFwibGFiZWxzXCI6W3tcIm5hbWVcIjpcImRhZ2dlci5pby9lbmdpbmVcIixcInZhbHVlXCI6XCJkN2VhMWY0NWM5NWVcIn1dfV0ifX0sInNoYTI1NjphZjc1ZGJmNjMxMjIwNjRhMDhiNDYxYmU1ODBkNzdmNTcxZWZjOTVlZWZjMWZiOTY4MjAyMjhhZGM5NDVkNDY2Ijp7ImNhcHMiOnsiY29uc3RyYWludHMiOnRydWUsInBsYXRmb3JtIjp0cnVlfX19LCJTb3VyY2UiOnsibG9jYXRpb25zIjp7InNoYTI1NjoxNDQ0ZDZiMzYwNThjOTIzNDRkYzFhN2UzMjhlNDk5ZjA4MzFmMjUzNTY2OTBkYjJmZGYxMjljY2I1NjIzZGRjIjp7fX19fSwiZGlyIjoiIiwicGxhdGZvcm0iOnsiYXJjaGl0ZWN0dXJlIjoiYW1kNjQiLCJvcyI6ImxpbnV4In0sInBpcGVsaW5lIjpbeyJuYW1lIjoiIiwibGFiZWxzIjpbeyJuYW1lIjoiZGFnZ2VyLmlvL2VuZ2luZSIsInZhbHVlIjoiZDdlYTFmNDVjOTVlIn1dfV19"} of type Tuple, Jason.Encoder protocol must always be explicitly implemented. This protocol is implemented for the following type(s): Any, Atom, BitString, Date, DateTime, Decimal, Float, Integer, Jason.Fragment, Jason.OrderedObject, List, Map, NaiveDateTime, Time
    (jason 1.4.0) lib/jason.ex:164: Jason.encode!/2
    (dagger 0.0.0) lib/dagger/query_builder.ex:47: anonymous fn/1 in Dagger.QueryBuilder.Selection.build_args/1
    (elixir 1.15.1) lib/enum.ex:1794: anonymous fn/2 in Enum.map_join/3
    (elixir 1.15.1) lib/enum.ex:1763: anonymous fn/4 in Enum.map_intersperse/3
    (stdlib 5.0.1) maps.erl:416: :maps.fold_1/4
    (elixir 1.15.1) lib/enum.ex:2522: Enum.map_intersperse/3
    (elixir 1.15.1) lib/enum.ex:1794: Enum.map_join/3
    (dagger 0.0.0) lib/dagger/query_builder.ex:48: Dagger.QueryBuilder.Selection.build_args/1

Steps to reproduce

  1. copy the script above in a file on computer,
  2. run the script using elixir script.exs.

SDK version

Elixir SDK pre-1.0

OS version

macOS 13.3 (22E252)

Activity

  1. gmile commented on Jul 5, 2023

    @gmile
    ContributorAuthor
  2. added a commit that references this issue on Jul 6, 2023
    2b523b1
  3. wingyplus commented on Jul 6, 2023

    @wingyplus
    Contributor

    Correct the example from description:

    Mix.install([{:dagger, github: "dagger/dagger", sparse: "sdk/elixir"}])
    
    client = Dagger.connect!()
    
    src =
      client
      |> Dagger.Query.git("https://github.com/hexpm/hexpm")
      |> Dagger.GitRepository.branch("main")
      |> Dagger.GitRef.tree()
    
    client
    |> Dagger.Query.container()
    |> Dagger.Container.from("hexpm/elixir:1.15.2-erlang-26.0.2-alpine-3.18.2")
    |> Dagger.Container.with_workdir("/src")
    |> Dagger.Container.with_directory("/src", src)
    |> Dagger.Container.with_exec(["mix", "deps.get"])
    |> Dagger.Container.stdout()
  4. gmile commented on Jul 6, 2023

    @gmile
    ContributorAuthor

    @wingyplus I tried your branch, and it works now, thanks!

  5. gmile commented on Jul 6, 2023

    @gmile
    ContributorAuthor

    Another thing, somewhat related, is that Dagger.Container.exit_code/1 also returns a tuple, e.g. {:ok, 0}. However, according to documentation, the function should return just an integer.

    It doesn't seem to be covered by #5413, but I thought I will bring it up anyway.

  6. wingyplus commented on Jul 6, 2023

    @wingyplus
    Contributor

    Another thing, somewhat related, is that Dagger.Container.exit_code/1 also returns a tuple, e.g. {:ok, 0}. However, according to documentation, the function should return just an integer.

    It doesn't seem to be covered by #5413, but I thought I will bring it up anyway.

    It is the bug in the codegen that I am currently working on. It will not include in this fix, but it will fix soon. 😊

  7. added a commit that references this issue on Jul 14, 2023
    169c790
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions