Wellington-Miguel

Wellington-Miguel

Getting warning: undefined or private

Even with all the correct imports and the mix file configured correctly, I can’t generate the executable and it gives the following error:

warning: DesafioCumbuca.main/1 is undefined or private. Did you mean:

      * main/0

└─ /home/runner/work/elixir/elixir/lib/mix/lib/mix/tasks/escript.build.ex:396: :desafio_cumbuca_escript.main/1

desafio_cumbuca.ex file:

`
defmodule DesafioCumbuca do
  alias InterfaceUsuario
  alias ObterNomes
  alias EnumerarNomes
  def main() do
    InterfaceUsuario.mostrar_boas_vindas()
    nomes = ObterNomes.obter_nomes([])
    nomes_ordenados = EnumerarNomes.enumerar(nomes)
    InterfaceUsuario.mostrar_resultado(nomes_ordenados)
  end
end`

mix file:

defmodule DesafioCumbuca.MixProject do
  use Mix.Project

  def project do
    [
      app: :desafio_cumbuca,
      version: "0.1.0",
      elixir: "~> 1.17",
      start_permanent: Mix.env() == :prod,
      deps: deps(),
      escript: escript()
    ]
  end
  def escript do
    [main_module:  DesafioCumbuca]
  end

  # Run "mix help compile.app" to learn about applications.
  def application do
    [
      extra_applications: [:logger]
    ]
  end

  # Run "mix help deps" to learn about dependencies.
  defp deps do
    [
      # {:dep_from_hexpm, "~> 0.3.0"},
      # {:dep_from_git, git: "https://github.com/elixir-lang/my_dep.git", tag: "0.1.0"}
    ]
  end
end

To generate the executable file I opened the project page and typed “mix compile” and then “mix escript.build”

Marked As Solved

harrisi

harrisi

You need to define DesafioCumbuca.main/1. Currently you’ve defined DesafioCumbuca.main/0. Changing def main() do to something like def main(_arg) do should help.

Also Liked

Wellington-Miguel

Wellington-Miguel

This instruction generated the executable op without any problems, I will still do some tests, but this solution seemed to solve everything!

dimitarvp

dimitarvp

It seems you could benefit from reading a few minutes about Elixir’s function arity.

Where Next?

Popular in Questions Top

yawaramin
In the Dialyzer docs ( http://erlang.org/doc/man/dialyzer.html#requesting-or-suppressing-warnings-in-source-files ), there is a way to tu...
New
_russellb
I want to try my hand at web scraping. What tools/libraries do I need to use. I’m hoping to turn this into something professional so don’...
New
Kagamiiiii
Student & New to elixir. Nice language. I want to convert a english character, e.g. “a”, which is stored in a variable, to it’s asci...
New
fireproofsocks
I’m working on defining a simple Ecto schema for a table (in PostGres), but I don’t see where I can define a column as NOT NULL. Conside...
New
lk-geimfari
What is most correct way to open, read and parse JSON file with poison? For example if we have example.json file in root of some projec...
New
vac
Hi, I'm quite new in Elixir and I'm trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and ...
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? https://hexdocs.pm/ecto/Ecto.Repo.h...
New
johnnyicon
Hi all, I've just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I'm trying to use Postg...
New

Other popular topics Top

Qqwy
Update: How to use the Blogs & Podcasts section You can post links to your blog posts or podcasts either in one of the Official Blog...
3268 119930 1237
New
dotdotdotPaul
Okay, I'm having a heck of a time trying to figure out how to best handle the validation of belongs_to associations in Ecto. I'm sure I'...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
sergio
I couldn’t find any guides that worked well with Phoenix 1.6.0 and esbuild. I hope this helps people test the waters and eases you into t...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? https://hexdocs.pm/ecto/Ecto.Repo.h...
New
johnnyicon
Hi all, I've just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I'm trying to use Postg...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New

We're in Beta

About us Mission Statement