langflow-ai / langflow

Langflow is a low-code app builder for RAG and multi-agent AI applications. It’s Python-based and agnostic to any model, API, or database.
http://www.langflow.org
MIT License
25.77k stars 3.46k forks source link

objc[31704]: +[__NSCFConstantString initialize] #2721

Closed davidtkeane closed 1 month ago

davidtkeane commented 1 month ago

Describe the bug

When i use the command langflow run, I get the error below.

Apple Macbook Pro m3. VSCode Python 3.11.9

To Reproduce Steps to reproduce the behavior:

  1. Go to command prompt.
  2. langflow run
  3. See error bellow.

$ langflow run

Error: objc[31704]: +[__NSCFConstantString initialize] may have been in progress in another thread when fork() was called. We cannot safely call it or ignore it in the fork() child process. Crashing instead. Set a breakpoint on objc_initializeAfterForkError to debug.

Answer: ChatGPT This error message you're encountering is related to issues with the Objective-C runtime on macOS, particularly when using forked processes. It is common in applications that use Python's multiprocessing or other similar functionality in a macOS environment.

To address this issue, you can try the following steps:

  1. Update Python and Packages Ensure you are using the latest version of Python and that all your packages are up to date. Some issues might be resolved with the latest updates.

$ brew update $ pip install --upgrade pip setuptools

  1. Set Environment Variable Setting the OBJC_DISABLE_INITIALIZE_FORK_SAFETY environment variable to YES can sometimes help to bypass this issue. You can set this variable in your .zshrc file or directly in your terminal session.

In your .zshrc file: add export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES Or in your current terminal session: export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES (Then Click enter)

After adding it to your .zshrc, don't forget to reload the file: source ~/.zshrc

Here’s an example of your .zshrc file with the environment variable set:

Environment variable to fix the Objective-C fork issue

export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES

  1. Restart Your Terminal After making these changes, restart your terminal or source your .zshrc file: source ~/.zshrc

  2. Test the Application Try running your application again to see if the issue is resolved:

$ langflow run

These steps should help mitigate the Objective-C runtime issues on macOS when forking processes. If the problem persists, consider looking into specific issues related to the libraries or frameworks you are using.

This worked for me by adding the export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES into my .zshrc file and running the $ langflow run command.

davidtkeane commented 1 month ago

This is solved on my machine.

carlosrcoelho commented 1 month ago

Thank you for your contribution! This issue will be closed. If you have any questions or encounter another problem, please open a new issue and we will be ready to assist you.