dwyl / learn-phoenix-framework

:fire: Phoenix is the web framework without compromise on speed, reliability or maintainability! Don't settle for less. :rocket:
646 stars 45 forks source link

Could not find "rebar3", which is needed to build dependency :ranch #121

Closed nelsonic closed 5 years ago

nelsonic commented 5 years ago

When following the Programming Phoenix 1.4 Book "Create a Throwaway Project" (page 19), (_which is the same as the "hello world" app in the "Up and Running": https://hexdocs.pm/phoenix/up_and_running.html#content that everyone should follow_)

mix ecto.create

But saw the following output:

17:45:43.249 [info]  Compiling file system watcher for Mac...
mix
17:45:44.671 [info]  Done.
==> file_system
Compiling 7 files (.ex)
Generated file_system app
==> connection
Compiling 1 file (.ex)
Generated connection app
==> gettext
Compiling 1 file (.yrl)
Compiling 1 file (.erl)
Compiling 20 files (.ex)
Generated gettext app
==> hello
Could not find "rebar3", which is needed to build dependency :ranch
I can install a local copy which is just used by Mix
Shall I install rebar3? (if running non-interactively, use "mix local.rebar --force") [Yn] y
** (Mix) Could not find "rebar3" to compile dependency :ranch, please ensure "rebar3" is available

image

Note: I'm following the "Hello World" example on a "New" Mac 💻 and seeing where the "gaps" are in my stack ahead of writing a new tutorial for the new year. Just wanted to capture this error message and the corresponding solution (see below) in case anyone else faces the same issue.

nelsonic commented 5 years ago

Ok ... it was PEBKAC ... I skipped a step! When the installer asks:

Fetch and install dependencies? [Yn] y

I hastily hit the [Enter] key instead of the y key ... so the dependencies were not installed correctly.

Run the following in order:

cd hello
mix deps.get
cd assets && npm install && node node_modules/webpack/bin/webpack.js --mode development
cd ..

Then when you run mix ecto.create it will work. image

mix phx.server

image

Works: http://localhost:4000 image

This thread: https://github.com/phoenixframework/phoenix/issues/842 included the error message but not the solution ... If you face this issue, just re-trace your steps and it will work. If not, comment in this thread and we will help you!

jupmorenor commented 5 years ago

I had the same issue while CI GitLab runner execution. It is solved using the suggestion given: Add mix local.rebar --force before running mix ecto.create