mudler / LocalAI

:robot: The free, Open Source alternative to OpenAI, Claude and others. Self-hosted and local-first. Drop-in replacement for OpenAI, running on consumer-grade hardware. No GPU required. Runs gguf, transformers, diffusers and many more models architectures. Features: Generate Text, Audio, Video, Images, Voice Cloning, Distributed inference
https://localai.io
MIT License
23.12k stars 1.75k forks source link

MacOS macports compile fails #1804

Open rlippmann opened 6 months ago

rlippmann commented 6 months ago

LocalAI version:

commit e022b59

Environment, CPU architecture, OS, and Version:

Darwin pebbles.local 23.3.0 Darwin Kernel Version 23.3.0: Wed Dec 20 21:31:00 PST 2023; root:xnu-10002.81.5~7/RELEASE_ARM64_T6020 arm64

Describe the bug

when using macports to compile, compilation fails

To Reproduce

do make build with dependencies installed via macports instead of homebrew

Expected behavior

compilation should succeed

Logs

[ 94%] Building CXX object examples/grpc-server/CMakeFiles/hw_grpc_proto.dir/backend.grpc.pb.cc.o In file included from /Users/rlippmann/Source/LocalAI/backend/cpp/llama/llama.cpp/build/examples/grpc-server/backend.grpc.pb.cc:5: /Users/rlippmann/Source/LocalAI/backend/cpp/llama/llama.cpp/build/examples/grpc-server/backend.pb.h:10:10: fatal error: 'google/protobuf/port_def.inc' file not found

include <google/protobuf/port_def.inc>

     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

1 error generated. make[4]: [examples/grpc-server/CMakeFiles/hw_grpc_proto.dir/backend.grpc.pb.cc.o] Error 1 make[3]: [examples/grpc-server/CMakeFiles/hw_grpc_proto.dir/all] Error 2 make[2]: [all] Error 2 make[1]: [grpc-server] Error 2 make: *** [backend/cpp/llama/grpc-server] Error 2

Additional context

It looks like the makefiles aren't looking in /opt/local/include, where macports stores its includes.

dave-gray101 commented 6 months ago

I've never used macports personally but one thing that I have to do in order to get my directories to work properly with homebrew is to set up the following two variables:

export C_INCLUDE_PATH=/usr/local/include
export CPLUS_INCLUDE_PATH=/usr/local/include

Therefore... can you clean your build, then try running the following command in your terminal before rebuilding?

export C_INCLUDE_PATH=/opt/local/include
export CPLUS_INCLUDE_PATH=/opt/local/include

I am really glad you posted this issue - I was about to hardcode the /usr/local/include stuff by default on OSX builds as so far, this seemed like a pointlessly painful step... Guess I'll need to revisit that idea and try to come up with some way to tell the difference between homebrew and macports!

dave-gray101 commented 6 months ago

Side note: Can you post a list of the "macports" dependencies you've installed to get up to this point? It would probably be great to document that as an alternative to homebrew for other users if we can work through this!

rlippmann commented 6 months ago

Maybe just search for /opt/local? That might not necessarily work because you might be able to have both macports and homebrew installed.

I already had cmake and gcc/g++ installed, so there was that. go pulled in protobuf, and (I think) abseil as dependencies. and grpc and wget. gcc/g++ looks like it's from the xcode command line tools.

so probably sudo port install cmake go grpc wget

rlippmann commented 6 months ago

Oh, and the C_INCLUDE_PATH and CPLUS_INCLUDE_PATH worked :)