Issue with boilerplate

Hey, guys!

Have some problems with boilerplate code generated with constructor.

First, in following line in endpoint.ex json_decoder: Phoenix.json_library() Compiler doesn’t understand .json_library(), says function is undefined or private. I checked boilerplate, generated with constructor, instead of .json_library() Poison is set as a json_decoder there. I switched to Poison in as well and that part compiles fine.

Then, when I’m starting the server with phx.server, seems it compiles as well, but when I’m requesting a page, it crashes. Logs say Router.Helpers.static_push/2 is undefined or private

I’m running Elixir 1.6.4 with Erlang/OTP 19 on Windows 8. Environment was set up according to instructions in book “Programming Phoenix”. Erlang/OTP was installed with a package from Erlang Solutions.

Any ideas why constructor is out of sync from the rest of development environment? Or maybe there’s some other issue I’m not aware of? Anyway, thanks in advance, guys

It would probably be better to try with Erlang 20…

Check what version of Phoenix you have installed. I’m guessing you’re using 1.4.0-dev and not 1.3.2.

The shows this for 1.4.0-dev:

[Phoenix] Add Phoenix.json_library/0 and replace Poison with Jason for JSON encoding in new projects.

You should remove the 1.4.0-dev version and then install the stable version 1.3.2:

mix archive.uninstall phx_new

mix archive.install

That is, unless you feel like playing with the development version.

4 Likes version 1.2.5, version 1.3.0

Wanted to install Erlang 20, but the most recent version in Erlang Solutions was 19 for Windows.

Ok, I have not been on Windows for a while… and I usually install Erlang/Elixir with asdf packet manager.

You can get Erlang 20.3 from the Erlang website downloads page.

1 Like version 1.2.5, version 1.3.0

Are you saying those are the versions you have installed and the generator is adding json_decoder: Phoenix.json_library() to endpoint.ex?

1 Like

The beta and RC phx_new packages do identify themselfes as 1.3.0, please remove and re-install to be sure you have the latest version.

Yes. I’ve installed Phoenix following instructions in “Programming Phoenix” book and then added generator as described in Phoenix github page. Now checking versions with mix --version and getting above numbers.

think you have followed “Generating a Phoenix project from unreleased versions”

if you do this you should get correct released version:

the github readme might need to make this more obvious or provide release install instructions… maybe create an issue/PR…

1 Like

Done. Same thing, same version. In .mix/archives I have phx_new-1.3.0 directory. Should it be something different?

@outlog, @l00ker: that’s it, was following “… from unreleased versions” instructions. Installing phx_new from archives repo solve the problem. Thanks, guys, much appreciated ))

Sorry, @l00ker, your first reply was the “problem solver”, didn’t get the difference between repos you provided and I was using.

@NobbZ: now I have raw phx_new dir in .mix/archives, w/o any version numbers.

PR created with release install instructions.

Glad I could be of help. You should mark it as the solution in case someone else has the same issue.

1 Like

Done. Marked outlog’s reply though as the solution - it extends your answer, so others can get it more easily. Thanks

1 Like