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

Compilation error. #9

Closed
paulewetzel opened this issue Jun 25, 2017 · 10 comments
Closed

Compilation error. #9

paulewetzel opened this issue Jun 25, 2017 · 10 comments

Comments

@paulewetzel
Copy link
Contributor

Just started playing around with elixir recently, not sure what this compile time error means. I am able to create and run phoenix apps using mix without any issues:
web mix phoenix.server
[info] Running Web.Endpoint with Cowboy using http://localhost:4000

I am running Ubuntu 16.04 with Elixir 1.4.5, please see the error info below:

➜ phoenix-react-redux-example git:(master) ✗ mix phoenix.server
warning: variable "deps" does not exist and is being expanded to "deps()", please use parentheses to remove the ambiguity or change the variable name
mix.exs:12

Compiling 11 files (.ex)

== Compilation error on file web/router.ex ==
** (CompileError) web/router.ex: internal error in core;
crash reason: badarg

in function erl_anno:anno_info/1
called as erl_anno:anno_info(-1)
in call from v3_core:record_anno/2 (v3_core.erl, line 2565)
in call from v3_core:expr/2 (v3_core.erl, line 576)
in call from v3_core:safe/2 (v3_core.erl, line 1719)
in call from v3_core:expr/2 (v3_core.erl, line 565)
in call from v3_core:safe/2 (v3_core.erl, line 1719)
in call from v3_core:'-safe_list/2-anonymous-0-'/2 (v3_core.erl, line 1734)
in call from lists:foldr/3 (lists.erl, line 1276)
in call from v3_core:expr/2 (v3_core.erl, line 575)
in call from v3_core:safe/2 (v3_core.erl, line 1719)
in call from v3_core:'-safe_list/2-anonymous-0-'/2 (v3_core.erl, line 1734)
in call from lists:foldr/3 (lists.erl, line 1276)
in call from v3_core:expr/2 (v3_core.erl, line 575)
in call from v3_core:safe/2 (v3_core.erl, line 1719)
in call from v3_core:expr/2 (v3_core.erl, line 565)
in call from v3_core:safe/2 (v3_core.erl, line 1719)
in call from v3_core:'-safe_list/2-anonymous-0-'/2 (v3_core.erl, line 1734)
in call from lists:foldr/3 (lists.erl, line 1276)
in call from v3_core:expr/2 (v3_core.erl, line 691)
in call from v3_core:exprs/2 (v3_core.erl, line 549)
(stdlib) lists.erl:1338: :lists.foreach/2
(phoenix) expanding macro: Phoenix.Router.before_compile/1
web/router.ex:1: PhoenixReactReduxExample.Router (module)
(elixir) lib/kernel/parallel_compiler.ex:117: anonymous fn/4 in Kernel.ParallelCompiler.spawn_compilers/1

@slashdotdash
Copy link
Owner

It looks like the version of Phoenix being used (1.0.3) is incompatible with Erlang 19 and newer. An upgrade to the latest version of Phoenix is required.

I don't know how much effort that would require, it might be as simple as updating the dependencies in mix.exs as below:

defp deps do
  [{:phoenix, "~> 1.2.1"},
   {:phoenix_pubsub, "~> 1.0"},
   {:phoenix_html, "~> 2.6"},
   {:phoenix_live_reload, "~> 1.0", only: :dev},
   {:gettext, "~> 0.11"},
   {:cowboy, "~> 1.0"}]
  end

Then run:

mix deps.update --all

@paulewetzel
Copy link
Contributor Author

paulewetzel commented Jun 25, 2017 via email

@paulewetzel
Copy link
Contributor Author

The web app is running but the react code is not transpiling into an App.js file. I was looking for a "script" section in the package.json but did not see any. I did not see anything about that in the README.

@slashdotdash
Copy link
Owner

slashdotdash commented Jun 26, 2017

You'll need to run manually Webpack to transpile the JavaScript code:

webpack --watch --color

Make sure you have installed the npm packages first: npm install

@slashdotdash
Copy link
Owner

@paulewetzel Feel free to send me a pull request with the changes you made to get it working. That'll help out future users!

Also, if you're interested in building CQRS/ES apps in Elixir using Phoenix then you might enjoy the book I'm authoring: Building Conduit.

@paulewetzel
Copy link
Contributor Author

Let me know when your book is 80%. I was about to start writing a distributed service bus the other day, but then came to my senses. I just finished up a sustained deep dive into redux and react. During that time I had an epiphany about functional programming and decided I would throw out the rails back end I was writing and rewrite it in Elixir. So I will be doing a lot of crash coursing on elixir and phoenix for the next month or so.

@slashdotdash
Copy link
Owner

Take a look at Elm, and the Elm architecture if you want full front-to-back functional programming. Elm provided part of the inspiration for Redux. The docs are worth a read through, even if you don't consider using the language.

@paulewetzel
Copy link
Contributor Author

Have you used elm on big projects? I played with it a bit and liked it, I have to say though, JSX is a little easier on the eyes than nested arrays. If you have used both on nontrivial projects, would love to hear some feedback about the pros and cons of both in your experience.

@slashdotdash
Copy link
Owner

slashdotdash commented Jun 27, 2017

I enjoyed writing Elm thanks to its helpful compiler, elm-format for consistency, and following The Elm Architecture. You can be confident that when it compiles, it will usually work.

I did not enjoy the integration of Elm code with JavaScript libraries and the back end, via JSON. It felt like I was forced to write lots of boring, repetitive code to act as the "border guard" between Elm and outside world. There's even an eBook dedicated to just this subject: The JSON Survival Kit by Brian Hicks. I'm also not exactly sure how best to scale up an Elm application as it grows in size. I need to invest more time reading, learning, and experimenting.

There are also issues using the official Elm Web Sockets package and Phoenix that are a concern. As is the fact that there aren't yet many Elm packages, such as date picker controls. You end up using an JavaScript library and writing more Elm/JavaScript interop code ("ports") or write your own Elm widgets.

I don't have any real feedback on React/Redux except that if I was using React then I would also use Redux. I may be one of the minority of developers who enjoy using JSX!

@paulewetzel
Copy link
Contributor Author

When I was playing with Elm, which I quite enjoyed, I also came across many comments by people who were hating dealing with JSON. It also seemed like I would be writing a lot of components from scratch that I would not have to in React. Your points somewhat confirm my own expectations as the time that pushed towards React.

When it comes to React and Redux, I find the latter to be the the more essential of the two. Redux, when combined with middleware such as Redux Saga, achieves something very close to Elm's architecture, but then there is Javascript. Since I only use React to display Redux state in properties, I could probably replace it with with another view technology without too much problem.

Last night I happened to notice that Slack was using Redux and introspected their state with Redux Tools. They format their action names to be human readable at a glace and also number them, which makes it even easier to reason about. I think this is the essence of what I like about Redux, it is so easy to break things down and reason about.
slack_is_redux

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

2 participants