Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
powder opened this issue Nov 7, 2018 · 6 comments

Comments

@powder
Copy link

powder commented Nov 7, 2018

== 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
Copy link
Member

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
Copy link

Just noting that I ran into this as well.

@YellowApple
Copy link
Member

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
Copy link

ashton commented Apr 30, 2024

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
Copy link
Member

@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 :)

@odineiramone
Copy link

odineiramone commented Aug 28, 2024

@YellowApple, I ran into this problem related by @ashton. The problem is that some sugar dependencies uses a lot of code that is deprecated on newer Elixir versions.

I correct the errors by hand and all of those was cases about to change a function call from my_function to my_function() for example.

I think the best way to handle with the errors is to compile the dependencies on the newest elixir version, correct the warnings and release a new version of the dependencies

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants