benwoodward / elixir_svelte_render

MIT License
32 stars 0 forks source link

Issues getting up-and-running, module not found #1

Closed kevmodrome closed 4 years ago

kevmodrome commented 4 years ago

Hi! I've been trying to get this working but I keep getting stuck on this one issue that keeps coming up. As soon as I add SvelteRender I get this error about the module not existing.

The problem is most likely that I am a total newbie when it comes to Elixir and Phoenix and i'm way over my head and I don't know how to correctly import the module. I assume this is the important part of the error message: (UndefinedFunctionError) function SvelteRender.start_link/1 is undefined (module SvelteRender is not available)

I followed the instructions as far as I can tell. Does Add SvelteRender to your Supervisor as a child also imply that I have to import SvelteRender somehow?

Erlang/OTP 22 [erts-10.6.4] [source] [64-bit] [smp:16:16] [ds:16:16:10] [async-threads:1] [hipe] [dtrace]

Compiling 1 file (.ex)
[info] Running SvelterenderWeb.Endpoint with cowboy 2.7.0 at 0.0.0.0:4000 (http)
[info] Access SvelterenderWeb.Endpoint at http://localhost:4000
[error] Loading of /Users/kevin/Workspace/phoenix/svelterender/_build/dev/lib/svelterender/ebin/Elixir.SvelteRender.beam failed: :badfile

[error] beam/beam_load.c(1433): Error loading module 'Elixir.SvelteRender':
  BEAM file exists but it defines a module named Elixir.Svelterender

[info] Application svelterender exited: Svelterender.Application.start(:normal, []) returned an error: shutdown: failed to start child: SvelteRender
    ** (EXIT) an exception was raised:
        ** (UndefinedFunctionError) function SvelteRender.start_link/1 is undefined (module SvelteRender is not available)
            (svelte_render 0.1.0) SvelteRender.start_link([render_service_path: "/Users/kevin/Workspace/phoenix/svelterender/assets", pool_size: 4])
            (stdlib 3.11.2) supervisor.erl:379: :supervisor.do_start_child_i/3
            (stdlib 3.11.2) supervisor.erl:365: :supervisor.do_start_child/2 
            (stdlib 3.11.2) supervisor.erl:349: anonymous fn/3 in :supervisor.start_children/2
            (stdlib 3.11.2) supervisor.erl:1157: :supervisor.children_map/4
            (stdlib 3.11.2) supervisor.erl:315: :supervisor.init_children/2
            (stdlib 3.11.2) gen_server.erl:374: :gen_server.init_it/2
            (stdlib 3.11.2) gen_server.erl:342: :gen_server.init_it/6
            (stdlib 3.11.2) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
** (Mix) Could not start application svelterender: Svelterender.Application.start(:normal, []) returned an error: shutdown: failed to start child: SvelteRender
    ** (EXIT) an exception was raised:
        ** (UndefinedFunctionError) function SvelteRender.start_link/1 is undefined (module SvelteRender is not available)
            (svelte_render 0.1.0) SvelteRender.start_link([render_service_path: "/Users/kevin/Workspace/phoenix/svelterender/assets", pool_size: 4])
            (stdlib 3.11.2) supervisor.erl:379: :supervisor.do_start_child_i/3
            (stdlib 3.11.2) supervisor.erl:365: :supervisor.do_start_child/2
            (stdlib 3.11.2) supervisor.erl:349: anonymous fn/3 in :supervisor.start_children/2
            (stdlib 3.11.2) supervisor.erl:1157: :supervisor.children_map/4
            (stdlib 3.11.2) supervisor.erl:315: :supervisor.init_children/2
            (stdlib 3.11.2) gen_server.erl:374: :gen_server.init_it/2
            (stdlib 3.11.2) gen_server.erl:342: :gen_server.init_it/6
            (stdlib 3.11.2) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
benwoodward commented 4 years ago

What does your mix.exs file look like?

kevmodrome commented 4 years ago

This is my mix.exs file:

defmodule Svelterender.MixProject do
  use Mix.Project

  def project do
    [
      app: :svelterender,
      version: "0.1.0",
      elixir: "~> 1.5",
      elixirc_paths: elixirc_paths(Mix.env()),
      compilers: [:phoenix, :gettext] ++ Mix.compilers(),
      start_permanent: Mix.env() == :prod,
      aliases: aliases(),
      deps: deps()
    ]
  end

  # Configuration for the OTP application.
  #
  # Type `mix help compile.app` for more information.
  def application do
    [
      mod: {Svelterender.Application, []},
      extra_applications: [:logger, :runtime_tools]
    ]
  end

  # Specifies which paths to compile per environment.
  defp elixirc_paths(:test), do: ["lib", "test/support"]
  defp elixirc_paths(_), do: ["lib"]

  # Specifies your project dependencies.
  #
  # Type `mix help deps` for examples and options.
  defp deps do
    [
      {:phoenix, "~> 1.4.15"},
      {:phoenix_pubsub, "~> 1.1"},
      {:phoenix_ecto, "~> 4.0"},
      {:ecto_sql, "~> 3.1"},
      {:postgrex, ">= 0.0.0"},
      {:phoenix_html, "~> 2.11"},
      {:phoenix_live_reload, "~> 1.2", only: :dev},
      {:gettext, "~> 0.11"},
      {:jason, "~> 1.0"},
      {:plug_cowboy, "~> 2.0"},
      {:svelte_render, "~> 0.1.0"}
    ]
  end

  # Aliases are shortcuts or tasks specific to the current project.
  # For example, to create, migrate and run the seeds file at once:
  #
  #     $ mix ecto.setup
  #
  # See the documentation for `Mix` for more info on aliases.
  defp aliases do
    [
      "ecto.setup": ["ecto.create", "ecto.migrate", "run priv/repo/seeds.exs"],
      "ecto.reset": ["ecto.drop", "ecto.setup"],
      test: ["ecto.create --quiet", "ecto.migrate", "test"]
    ]
  end
end
benwoodward commented 4 years ago

Could you maybe give me access to your repo and I’ll take a look for you?

kevmodrome commented 4 years ago

Of course!

https://github.com/kevmodrome/svelterender

benwoodward commented 4 years ago

I got the following error on mix ecto.setup:

[error] beam/beam_load.c(1433): Error loading module 'Elixir.SvelteRender':
  BEAM file exists but it defines a module named Elixir.Svelterender

I think the issue might just be a namespace clash, because the app has the same name as the package.

kevmodrome commented 4 years ago

Yeah, this seems to have been it. Did not realize they weren't case-sensitive. Really sorry for wasting your time. Thanks a million for this though! I owe you one.

benwoodward commented 4 years ago

Not a problem at all. Just glad to see more people using Elixir and Svelte.js, I'm a really big fan of these technologies.