Phoenix basic setup error

Hi- I’m trying out a basic tutorial on Mac OS X El Capitan 10.11.5.

I’ve created a basic project repository using phoenix.new command, installed the dependencies and when I run mix phoenix.server I get the following error repeatedly(tried multiple options e.g. without echo , without brunch but get the same error):

** (Mix) Could not compile dependency :fs, "/usr/local/bin/rebar compile skip_deps=true deps_dir="/Users/xxx/elixir/sgs_notifications/_build/dev/lib"" command failed. You can recompile this dependency with "mix deps.compile fs", update it with "mix deps.update fs" or clean it with "mix deps.clean fs"

I’ve tried reinstalling elixir, erlang, phoenix multiple times, tried mix dips clean -all multiple times, no progress.

Tried searching this forum , and also other online sources, but has;t helped. Appreciate help here.

Thanks/PEshwar

Here is some more information on the error:

c_src/mac/common.h:5:10: fatal error: 'CoreServices/CoreServices.h' file not found
#include <CoreServices/CoreServices.h>
         ^
1 error generated.
ERROR: compile failed while processing /Users/xxx/elixir/sgs_notifications/deps/fs: rebar_abort
** (Mix) Could not compile dependency :fs, "/usr/local/bin/rebar compile skip_deps=true deps_dir="/Users/xxx/elixir/sgs_notifications/_build/dev/lib"" command failed. You can recompile this dependency with "mix deps.compile fs", update it with "mix deps.update fs" or clean it with "mix deps.clean fs"

How did you install Elixir and Erlang? I used the Homebrew packages and haven’t encountered such error. It looks like the build/installation is broken somehow.

For Elixir I used : brew install elixir

For Erlang & Phoenix, I used instructions at following link: http://www.phoenixframework.org/docs/installation

Peshwar

I do not use Apple things, but from that message it indicates it is trying to compile a native library, probably for file watching, used in dev mode only I’m pretty sure. Are you able to compile in prod environment?
MIX_ENV=PROD mix compile

Basically you are missing some programming headers on your Mac that you should have with XCode, you do have XCode installed yes? (Sadly XCode is near necessary for programming even in unrelated languages on the Mac because of Apple oddities…)

Yes, I have Xcode installed and have been using it for a while.I also tried MIX_ENV=PROD option and I get same error.
I have Erlang 19.2 and elixir 1.3.4. (tried reinstalling these yet again)

I don’t know why it is trying to use Apple core services , my mix.exs is reproduced below:

=============

defmodule SgsNotifications.Mixfile do
  use Mix.Project

  def project do
    [app: :sgs_notifications,
     version: "0.0.1",
     elixir: "~> 1.2",
     elixirc_paths: elixirc_paths(Mix.env),
     compilers: [:phoenix, :gettext] ++ Mix.compilers,
     build_embedded: Mix.env == :prod,
     start_permanent: Mix.env == :prod,
     deps: deps()]
  end

  # Configuration for the OTP application.
  #
  # Type `mix help compile.app` for more information.
  def application do
    [mod: {SgsNotifications, []},
     applications: [:phoenix, :phoenix_pubsub, :phoenix_html, :cowboy, :logger, :gettext]]
  end

  # Specifies which paths to compile per environment.
  defp elixirc_paths(:test), do: ["lib", "web", "test/support"]
  defp elixirc_paths(_),     do: ["lib", "web"]

  # Specifies your project dependencies.
  #
  # Type `mix help deps` for examples and options.
  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
end

==========

Once again, my complete error stack is below:

==> fs (compile)
Compiling c_src/mac/cli.c
In file included from c_src/mac/cli.c:2:
In file included from c_src/mac/cli.h:4:
c_src/mac/common.h:5:10: fatal error: 'CoreServices/CoreServices.h' file not found
#include <CoreServices/CoreServices.h>
         ^
1 error generated.
ERROR: compile failed while processing /Users/xxx/elixir/SGSNotifications/deps/fs: rebar_abort
** (Mix) Could not compile dependency :fs, "/usr/local/bin/rebar compile skip_deps=true deps_dir="/Users/xxx/elixir/SGSNotifications/_build/dev/lib"" command failed. You can recompile this dependency with "mix deps.compile fs", update it with "mix deps.update fs" or clean it with "mix deps.clean fs"

PEshwar

Sorry PEshwar I don’t know the exact cause here, though I’m confident @OvermindDL1 is correct in his assessment of this being related to file system alerting.

I would post an issue here:

and see if they can point you in the right direction.

That said, it seems clear from the error that the problem has to do with something that it can’t find about your XCode installation.

Perhaps this will be a useful pointer:
https://developer.apple.com/reference/coreservices

Thanks jeffdeville, I will investigate.

@Peshwar I just updated my deps and received the same errors for :fs. Did you ever find resolution? It updated to 2.12.0, not sure what it was before that :confused:

@wfgilman I just got a fatal same error creating a throwaway Phoenix project on OSX due to :fs that has set me back an hour or so.

Troubleshooting with DEBUG=1 mix deps.compile I see:

===> Compiling fs
===> run_hooks("/Users/someone/dev/Phoenix Projects/my_api/deps/fs", pre_hooks, {pc,
compile}) -> no hooks defined
===> sh info:
cwd: “/Users/someone/dev/Phoenix Projects/my_api/deps/fs”
cmd: clang -c -Wno-deprecated-declarations -g -Wall -fPIC -MMD -I"/usr/local/Cellar/erlang/19.2/lib/erlang/lib/erl_interface-3.9.2/include" -I"/usr/local/Cellar/erlang/19.2/lib/erlang/erts-8.2/include" /Users/someone/dev/Phoenix Projects/my_api/deps/fs/c_src/mac/cli.c -o /Users/someone/dev/Phoenix Projects/my_api/deps/fs/c_src/mac/cli.o

===> Compiling /Users/someone/dev/Phoenix Projects/my_api/deps/fs/c_src/mac/cli.c
===> clang: error: no such file or directory: ‘/Users/someone/dev/Phoenix’
clang: error: no such file or directory: ‘Projects/my_api/deps/fs/c_src/mac/cli.c’
clang: error: no such file or directory: ‘Projects/my_api/deps/fs/c_src/mac/cli.o’
clang: error: no input files

It appears to me that :fs is having an OSX parsing error in the folder path, since I have a space in Phoenix Projects folder - If I move my project to another folder without a space /Users/someone/dev/my_api/ - I do not get the :fs compile issue

===> Compiling fs
===> run_hooks("/Users/someone/dev/my_api/deps/fs", pre_hooks, {pc,compile}) -> no hooks defined
===> run_hooks("/Users/someone/dev/my_api/deps/fs", post_hooks, {pc,compile}) -> no hooks defined
===> run_hooks("/Users/someone/dev/my_api/deps/fs", pre_hooks, compile) -> no hooks defined
===> run_hooks("/Users/someone/dev/my_api/deps/fs", pre_hooks, erlc_compile) -> no hooks defined
===> erlopts [debug_info]
===> files to compile ["/Users/someone/dev/my_api/deps/fs/src/sys/kqueue.erl",
“/Users/someone/dev/my_api/deps/fs/src/sys/inotifywait_win32.erl”,
“/Users/someone/dev/my_api/deps/fs/src/sys/inotifywait.erl”,
“/Users/someone/dev/my_api/deps/fs/src/sys/fsevents.erl”,
“/Users/someone/dev/my_api/deps/fs/src/fs_sup.erl”,
“/Users/someone/dev/my_api/deps/fs/src/fs_server.erl”,
“/Users/someone/dev/my_api/deps/fs/src/fs_event_bridge.erl”,
“/Users/someone/dev/my_api/deps/fs/src/fs_app.erl”,
“/Users/someone/dev/my_api/deps/fs/src/fs.erl”]
===> run_hooks("/Users/someone/dev/my_api/deps/fs", post_hooks, erlc_compile) -> no hooks defined
===> run_hooks("/Users/someone/dev/my_api/deps/fs", pre_hooks, app_compile) -> no hooks defined
===> run_hooks("/Users/someone/dev/my_api/deps/fs", post_hooks, app_compile) -> no hooks defined
===> run_hooks("/Users/someone/dev/my_api/deps/fs", post_hooks, compile) -> no hooks defined

Mine is slightly different. I’m getting an uncaught error in rebar_core. The stacktrace is enormous.

$mix deps.compile fs
===> Compiling fs
===> Uncaught error in rebar_core. Run with DEBUG=1 to see stacktrace
===> When submitting a bug report, please include the output of `rebar3 report "your command"`
** (Mix) Could not compile dependency :fs, "/Users/Me/.mix/rebar3 bare compile --paths "/Users/Me/development/myapp/_build/dev/lib/*/ebin"" command failed. You can recompile this dependency with "mix deps.compile fs", update it with "mix deps.update fs" or clean it with "mix deps.clean fs"

Yeah that was the same error I got - what is your output running $DEBUG=1 mix deps.compile fs ?

It doesnt appear your project is in a directory that has a space, so still might be something different.

The output is 66 pages long.

Prior to this error, I was using {:fs, "~> 0.9.2"}, specified in :phoenix_live_reload.

My {:phoenix_live_reload, "~> 1.0"} was just updated from 1.0.6 to 1.0.7 by @chrismccord a couple of hours ago as I was updating my deps. That commit updated :fs to 2.12.0 which is when I started having trouble. Apparently that commit was associated with trouble someone else was having with 0.9.x.

Anyone else seeing issues with this?

For what it’s worth, I just created a new phoenix project and received the same error when I compiled it.

mix phoenix.new hello_world

…installed all dependencies…

Me$ ~/development/elixir/hello_phoenix
$iex -S mix
Erlang/OTP 19 [erts-8.2] [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false] [dtrace]

===> Compiling fs
===> Uncaught error in rebar_core. Run with DEBUG=1 to see stacktrace
===> When submitting a bug report, please include the output of `rebar3 report "your command"`
** (Mix) Could not compile dependency :fs, "/Users/Me/.mix/rebar3 bare compile --paths "/Users/Me/development/elixir/hello_phoenix/_build/dev/lib/*/ebin"" command failed. You can recompile this dependency with "mix deps.compile fs", update it with "mix deps.update fs" or clean it with "mix deps.clean fs"

I just force fs to be 0.9.1 before this issue is fixed:

https://github.com/synrc/fs/issues/37

@wfgilman can you try to update rebar, rm -rf _build and retry?

$ mix local.rebar
$ rm -rf _build
$ mix phoenix.server

An report back. I can roll :fs back to the prev version but I need to know how widespread this issue is and the exact cause.Thanks!

2 Likes

That fixed it!

I’m at {:phoenix_live_reload, "~> 1.0.7"} and {:fs, "~> 2.12.0"}. My application compiles in the :dev and :test environments.

Hi Chris,

I got past the initial issue, but now get the following, as part of the default app creation steps below

  1. mix phoenix.new
  2. mix echo.create
  3. mix phoenix.server
15:59:27.108 [error] GenServer #PID<0.3185.0> terminating
** (DBConnection.ConnectionError) tcp connect (localhost:5432): connection refused - :econnrefused
    (db_connection) lib/db_connection/connection.ex:148: DBConnection.Connection.connect/2
    (connection) lib/connection.ex:622: Connection.enter_connect/5
    (stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3
Last message: nil
State: Postgrex.Protocol
** (Mix) The database for ApiExample.Repo couldn't be created: an exception was raised:
    ** (DBConnection.ConnectionError) tcp connect (localhost:5432): connection refused - :econnrefused
        (db_connection) lib/db_connection/connection.ex:148: DBConnection.Connection.connect/2
        (connection) lib/connection.ex:622: Connection.enter_connect/5
        (stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3

Kindly assist.

Thanks,
Prabhu

Your database server is not running, or not listening on the specified socket or a firewall refuses your connection.

Please make sure the following things in order:

  • Your DB server is running
  • Your DB server is bound to 0.0.0.0, 127.0.0.1, or ::1 (if not 0‌.0.0.0 it should be the same address that localhost resolves to)
  • Your DB server does listen on port 5432 (or reconfigure your application to use the correct port)
  • You do not have a firewall in the way, but I’ve not heard of a firewall blocking anything on the loopback device

Sorry, but I’m unable to figure out what the issue is. I’ve looked through the available official documentation. I’m running pretty much out-of -the-box setup commands as advised in guides. Is there any specific step I’m missing? I’ve also reinstalled psql just to be sure after removing old version, and tried connecting to psql on command line (it works). I see a few other people have posted similar issues on github and elixir form chats, but no clear answer has been provided to resolve.

Prabhu