Issue with phx.new boilerplate

phoenix
troubleshooting

#1

Hey, guys!

Have some problems with boilerplate code generated with phx.new 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 phoenix.new constructor, instead of .json_library() Poison is set as a json_decoder there. I switched to Poison in phx.new 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 phx.new 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


#2

It would probably be better to try with Erlang 20…


#3

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

The CHANGELOG.md 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 https://github.com/phoenixframework/archives/raw/master/phx_new.ez

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


#4

Phoenix.new version 1.2.5, phx.new version 1.3.0


#5

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


#6

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


#7

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


#8

Phoenix.new version 1.2.5, phx.new version 1.3.0

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


#9

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.


#10

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


#11

think you have followed “Generating a Phoenix project from unreleased versions” https://github.com/phoenixframework/phoenix#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…


#12

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


#13

@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.


#14

PR created with release install instructions.


#15

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


#16

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