-
Notifications
You must be signed in to change notification settings - Fork 24.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ccache not found #46126
Comments
|
|
Checked with the latest version (0.75.2) and the issue persists. |
Yes that works since its run from the terminal where my path is set. Ccache is installed via homebrew and the installation directory is part of my terminal path. However macOS applications do not inherit the path and therefore ccache can not be found. I think what would mitigate this problem would be to add a user defined setting like CCHACHE_BINARY go the targets from the ruby script as part of the post_install hook where the path is found and printed out. Then update the shell script to use this variable instead of calling exec ccache. I recognize that you can build the project without modifications however to build it in Xcode itself and not from the Terminal is broken for me when enabling cchache and i think this could potentially be fixed. |
@dehlen thanks for the additional information. The issue can surely be fixed. As of now, we are a bit busy with the rollout of the New Architecture which has the highest priority, so we need to wait a bit for this to happen on our side. However, if you had some spare cycle and you'd like to try and submit a PR, I can help out and make sure we merge it. |
I'll give it a shot. I won't be able to have a look at this before next week but will comment back with a PR next week. |
Sorry to comment again without having a PR ready for you. I just had a look at the problem. I think the .xcode.env (and .local) files would be the right place to input a new environment variable (CCACHE_BINARY). I can do this in scripts/cocoapods/utils.rb:create_xcode_env_if_missing. I would create a export for .xcode.env with I would choose this behaviour for the following reasons:
However I am not quite sure why I can't make it run like that. Somehow when switching the CC, CXX, LD and LDPLUSPLUS variables to something like
However this does not work as well. The environment variables are not found f.e. PODS_ROOT is not found and therefore with-environment.sh does not find the xcode env files. I am willing to investigate a bit further but I feel like I am missing the kownledge regarding environment variables in Xcode and shell scripting to find a quick solution for now. I could pass the ccache path directly to the clang scripts however I am not sure whether this would be an acceptable solution? |
Hi @dehlen, thanks for investigating the solution. The Having the error might help. |
Xcode passes parameters to ccache which is why I tried to call with-environment.sh from inside the ccache scripts. They pass all variables to ccache via $@. I will recreate my last approach and comment with the error messages. EDIT: To make it even easier to debug I did the following things:
#!/bin/sh
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
# Get the absolute path of this script
SCRIPT_DIR="$(dirname "$(readlink -f "$0")")"
REACT_NATIVE_CCACHE_CONFIGPATH=$SCRIPT_DIR/ccache.conf
# Provide our config file if none is already provided
export CCACHE_CONFIGPATH="${CCACHE_CONFIGPATH:-$REACT_NATIVE_CCACHE_CONFIGPATH}"
echo "PODS_ROOT"
# This is empty!
echo "$PODS_ROOT"
# Override the default with the global environment
ENV_PATH="$PODS_ROOT/../.xcode.env"
if [ -f "$ENV_PATH" ]; then
source "$ENV_PATH"
fi
# Override the global with the local environment
LOCAL_ENV_PATH="${ENV_PATH}.local"
if [ -f "$LOCAL_ENV_PATH" ]; then
source "$LOCAL_ENV_PATH"
fi
# This script received parameters (for the compiler) which are passed to ccache via $@.
exec "$CCACHE_BINARY" clang(++) "$@" So I basically copy and pasted the relevant parts of with-environment.sh into the clang scripts to source the environment files. However the clang scripts do not received the PODS_ROOT environment, it is empty. Therefore sourcing does not work and the script fails. The same happens when running with-environment.sh instead of copy & pasting it directly into the script. PODS_ROOT is available as a user defined setting however the script does not receive these variables and I am not quite sure why. I tried changing the bang from |
I added a printenv to the script to see what environment values are available inside the ccache script:
If I append the CCACHE_BINARY path like so for CC, LD, etc.:
this also fails with this error message:
At this point the only thing I could think of is adding this to the ccache scripts (which is obviously working for my case but most certainly will not work for everyone): |
Another option might be to echo a warning if ccache can't be found and use clang or clang++ directly in that case. While this does not solve the issue at hand at least it would not result in a build issue. The user could then write some custom post_install hook or change the CC,LD environment variables to fix the problem locally. What do you think about this? I am not 100% sure which way would be preferred. Also it might be of course totally possible to find a better solution I haven't found yet. Open for any suggestions. |
The warning can be a good alternative, but I'm afraid that people might not see it. |
Issue persists at After following the upgrade guide at |
Throwing my two cents in, i've had this issue for a while now and found that clearing the contents of my |
Description
When opening Xcode not from the command line (via xed f.e.) but directly from Finder/Dock and the ccache option is enabled the build will fail because ccache can not be found even though it is installed. The issue exists because the PATH most certainly won't include the ccache binary (f.e. when installed via homebrew, it is located at /opt/homebrew/bin/ccache but Xcodes PATH does not include it). When setting the project up for ccache, the existence of ccache is checked. However this runs as part of pod install in a terminal environment with a potentially different PATH env variable. To fix this I think the ccache path found at pod install time should be passed to the ccache-clang and ccache-clang++.sh scripts.
Steps to reproduce
An error message will be visible stating:
[root_path]/node_modules/react-native/scripts/xcode/ccache-clang.sh: line 14: exec: ccache: not found
Command CompileC failed with a nonzero exit code
React Native Version
0.74.2
Affected Platforms
Build - MacOS
Output of
npx react-native info
Stacktrace or Logs
Reproducer
https://github.com/dehlen/rn-ccache-bug
Screenshots and Videos
No response
The text was updated successfully, but these errors were encountered: