livebook-dev / livebook

Automate code & data workflows with interactive Elixir notebooks
https://livebook.dev
Apache License 2.0
4.96k stars 427 forks source link

Mac Desktop version; error with make #1290

Closed Hermanverschooten closed 2 years ago

Hermanverschooten commented 2 years ago

Environment

Current behavior

Evaluating the livebook found at vix gibhub, I get this error:

==> vix
cc -O3 -std=c11 -finline-functions -Wall -Werror -Wmissing-prototypes -D_POSIX_C_SOURCE=200809L -fPIC -I /Applications/Livebook.app/Contents/Resources/rel/erts-13.0.2/include -I /Applications/Livebook.app/Contents/Resources/rel/usr/include `pkg-config vips --cflags`  -c -o /Users/herman/Library/Caches/mix/installs/elixir-1.13.4-erts-13.0.2/70ef28b7cf5fcd83faf30ab0985d93df/deps/vix/c_src/pipe.o /Users/herman/Library/Caches/mix/installs/elixir-1.13.4-erts-13.0.2/70ef28b7cf5fcd83faf30ab0985d93df/deps/vix/c_src/pipe.c
/bin/sh: pkg-config: command not found
/Users/herman/Library/Caches/mix/installs/elixir-1.13.4-erts-13.0.2/70ef28b7cf5fcd83faf30ab0985d93df/deps/vix/c_src/pipe.c:3:10: fatal error: 'glib-object.h' file not found
#include <glib-object.h>
         ^~~~~~~~~~~~~~~
1 error generated.
make[1]: *** [/Users/herman/Library/Caches/mix/installs/elixir-1.13.4-erts-13.0.2/70ef28b7cf5fcd83faf30ab0985d93df/deps/vix/c_src/pipe.o] Error 1
make: *** [all] Error 2
could not compile dependency :vix, "mix compile" failed. Errors may have been logged above. You can recompile this dependency with "mix deps.compile vix", update it with "mix deps.update vix" or clean it with "mix deps.clean vix"

** (Mix.Error) Could not compile with "make" (exit status: 2).
You need to have gcc and make installed. Try running the
commands "gcc --version" and / or "make --version". If these programs
are not installed, you will be prompted to install them.

    (mix 1.13.4) lib/mix.ex:515: Mix.raise/2
    (elixir_make 0.6.3) lib/mix/tasks/compile.make.ex:154: Mix.Tasks.Compile.ElixirMake.run/1
    (mix 1.13.4) lib/mix/task.ex:397: anonymous fn/3 in Mix.Task.run_task/3
    (mix 1.13.4) lib/mix/tasks/compile.all.ex:92: Mix.Tasks.Compile.All.run_compiler/2
    (mix 1.13.4) lib/mix/tasks/compile.all.ex:72: Mix.Tasks.Compile.All.compile/4
    (mix 1.13.4) lib/mix/tasks/compile.all.ex:59: Mix.Tasks.Compile.All.with_logger_app/2
    (mix 1.13.4) lib/mix/tasks/compile.all.ex:36: Mix.Tasks.Compile.All.run/1
    (mix 1.13.4) lib/mix/task.ex:397: anonymous fn/3 in Mix.Task.run_task/3

I thought I missed libvips (a prerequisite), but it is installed.

Expected behavior

I expected it to install/build :vix

When I use the same Livebook using livebook server, it does not have the same issue.

josevalim commented 2 years ago

What do which make and which gcc return for you? How have you installed them? Do you do something special to add them to your path?

Hermanverschooten commented 2 years ago
Air-van-Herman➜  ~  which gcc
/usr/bin/gcc
Air-van-Herman➜  ~  which make
/usr/bin/make

There is a gcc in my brew list, so I probably installed it that way.

Hermanverschooten commented 2 years ago
Air-van-Herman➜  ~  which pkg-config
/opt/homebrew/bin/pkg-config

Will this be the cause? I mean /usr/bin is probably in the PATH by default, but the homebrew path is not, that is set in .zshrc.

josevalim commented 2 years ago

Yeah, that’s it. I guess we will need a new setting for additional paths?

wojtekmach commented 2 years ago

Yup. The app runs in a very limited environment:

# MyApp.app/Contents/MacOS/MyApp
#!/bin/sh
osascript -e "tell app \"System Events\" to display dialog \"$(env)\""
image
wojtekmach commented 2 years ago

So yeah, we basically need to manipulate $PATH somehow but worth noting that such notebook is not reproducible, in order to run it we need to run in a specific and implicit build environment. So it's a no-no for sharing but obviously it is an important scenario for just exploring things. For that I think it'd be best to manually adjust $PATH by calling System.put_env("PATH", ...) before Mix.install call. Would that work?

We're also hoping to see packages not needing build environment thanks to projects like:

Hermanverschooten commented 2 years ago

That would probable also solve the issue @wojtekmach closed for nmake on windows #1248 .

Hermanverschooten commented 2 years ago

@wojtekmach I added

path = System.get_env("PATH")
System.put_env("PATH", path <> ":/opt/homebrew/bin")

That got me further but now it complains it cannot find "erl_nif.h".

wojtekmach commented 2 years ago

Ok lack of erl_nif is a bug, will look into it.

wojtekmach commented 2 years ago

The missing erl_nif.h fix is out in updated release artifacts, thanks again for the report! https://github.com/livebook-dev/livebook/releases/tag/v0.6.3

Hermanverschooten commented 2 years ago

@wojtekmach Just to confirm that it now does work, thanks!