sugar-framework / sugar

Modular web framework for Elixir
https://sugar-framework.github.io/
MIT License
430 stars 29 forks source link

Getting started instructions appear out of date, results in compilation error. #97

Open powder opened 5 years ago

powder commented 5 years ago
== Compilation error in file lib/simple/router.ex ==
** (ArgumentError) JSON parser expects a :json_decoder option
    lib/plug/parsers/json.ex:38: Plug.Parsers.JSON.validate_decoder!/1
    lib/plug/parsers/json.ex:32: Plug.Parsers.JSON.init/1
    lib/plug/parsers.ex:245: anonymous fn/3 in Plug.Parsers.convert_parsers/2
    (elixir) lib/enum.ex:1925: Enum."-reduce/3-lists^foldl/2-0-"/3
    lib/plug/parsers.ex:228: Plug.Parsers.convert_parsers/2
    lib/plug/parsers.ex:224: Plug.Parsers.init/1
    lib/plug/builder.ex:302: Plug.Builder.init_module_plug/4
    lib/plug/builder.ex:286: anonymous fn/5 in Plug.Builder.compile/3

Likely this indicates that the simple repo hasn't been touched in a long while. Haven't dived into it further than following the instructions as listed and seeing it fail.

The following is my elixir/erlang version string if that's useful in understanding where this error is coming from.

[powder:simple-example] elixir --version                                                                                                                                                                                                          
Erlang/OTP 21 [erts-10.1.1] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [hipe]

Elixir 1.7.4 (compiled with Erlang/OTP 21)
YellowApple commented 5 years ago

Yeah, the simple-example repo is almost certainly out of date. I'll see about updating it.

That said, if you're following the instructions at http://sugar-framework.github.io/getting-started/, then that suggests Sugar itself is running into some kind of trouble there. I'll look into that as well.

polynomialherder commented 5 years ago

Just noting that I ran into this as well.

YellowApple commented 5 years ago

Sorry for the delayed response here.

So I was able to get through the Getting Started instructions on the latest versions of Erlang and Elixir, with the caveat that I had to blow away the pregenerated EEx template (else mix server would fail with symptoms identical to #79 ). I wasn't able to reproduce this JSON-related error specifically, weirdly enough, but it's clear that Sugar can use some TLC across the board.

There's been talk previously of just scrapping Sugar's template compiler, given that it's buggy and overdue for eventual replacement, and Sugar's strength is more in the router/controller layer(s) anyway. Better to enforce a separation of concerns here and - like we did already by trimming out the Ecto dependency - just delegate view handling to some other system separate from Sugar to give users the freedom to use whatever best fits their applications (my dream goal here has been to create separate applications called Spice and EverythingNice for the model and view layers, respectively, but let's focus on Sugar first :) ).

My 2018 New Year's Resolution was to get OTPCL to the point where it could actually evaluate scripts. My 2019 New Year's Resolution is to resume polishing up Sugar to be the proper contender to Phoenix that the Elixir ecosystem needs. Hopefully I'll be able to keep up this resolution streak.

ashton commented 3 months ago

Hey just mentioning that trying to use elixir 1.16 with OTP 26 gives me the following compilation error:

~/dev/pessoal/play_with_me is  v0.1.0 via  took 5s
❯ mix sugar.init
    error: undefined variable "deps"
    │
  8 │       deps: deps,
    │             ^^^^
    │
    └─ /Users/matheus.ashton/dev/pessoal/play_with_me/deps/http_router/mix.exs:8:13: HttpRouter.Mixfile.project/0

    error: undefined variable "package"
    │
 10 │       package: package,
    │                ^^^^^^^
    │
    └─ /Users/matheus.ashton/dev/pessoal/play_with_me/deps/http_router/mix.exs:10:16: HttpRouter.Mixfile.project/0

    error: undefined variable "description"
    │
 11 │       description: description,
    │                    ^^^^^^^^^^^
    │
    └─ /Users/matheus.ashton/dev/pessoal/play_with_me/deps/http_router/mix.exs:11:20: HttpRouter.Mixfile.project/0

    warning: function deps/0 is unused
    │
 21 │   defp deps do
    │        ~
    │
    └─ /Users/matheus.ashton/dev/pessoal/play_with_me/deps/http_router/mix.exs:21:8: HttpRouter.Mixfile (module)

    warning: function description/0 is unused
    │
 32 │   defp description do
    │        ~
    │
    └─ /Users/matheus.ashton/dev/pessoal/play_with_me/deps/http_router/mix.exs:32:8: HttpRouter.Mixfile (module)

    warning: function package/0 is unused
    │
 40 │   defp package do
    │        ~
    │
    └─ /Users/matheus.ashton/dev/pessoal/play_with_me/deps/http_router/mix.exs:40:8: HttpRouter.Mixfile (module)

Error while loading project :http_router at /Users/matheus.ashton/dev/pessoal/play_with_me/deps/http_router
** (CompileError) deps/http_router/mix.exs: cannot compile module HttpRouter.Mixfile (errors have been logged)
YellowApple commented 3 months ago

@ashton Try adding {:http_router, git: "https://github.com/sugar-framework/elixir-http-router", branch: "master"} to the deps in your project's mix.exs. If that works, then I just need to cut a new release :)