으니의 개발로그

[React Native] /bin/bash: ./configure: /bin/sh^M: bad interpreter: No such file or directory 에러 해결하기 본문

Front-end/React Native

[React Native] /bin/bash: ./configure: /bin/sh^M: bad interpreter: No such file or directory 에러 해결하기

아잉으니야 2020. 12. 29. 23:18

MAC OS 환경에서 React Native 개발 환경 구축 중 발생하는 에러 해결하기

 

React Native CLI 를 이용해서 개발을 시작하고 싶은데 중간에 에러가 발생했다.

 

error Error: Failed to install CocoaPods dependencies for iOS project, which is required by this template.
Please try again manually: "cd ./AwesomeProject/ios && pod install".
CocoaPods documentation: https://cocoapods.org/

 

 

그래서 메뉴얼대로 terminal 창에서 cd ./AwesomeProject/ios && pod install 를 쳤더니

 

Analyzing dependencies
Fetching podspec for `DoubleConversion` from `../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec`
Fetching podspec for `Folly` from `../node_modules/react-native/third-party-podspecs/Folly.podspec`
Fetching podspec for `glog` from `../node_modules/react-native/third-party-podspecs/glog.podspec`
Downloading dependencies
Installing CocoaAsyncSocket (7.6.4)
Installing CocoaLibEvent (1.0.0)
Installing DoubleConversion (1.1.6)
Installing FBLazyVector (0.63.4)
Installing FBReactNativeSpec (0.63.4)
Installing Flipper (0.54.0)
Installing Flipper-DoubleConversion (1.1.7)
Installing Flipper-Folly (2.3.0)
Installing Flipper-Glog (0.3.6)
[!] /bin/bash -c 
set -e
\#!/bin/bash
\# Copyright (c) Facebook, Inc. and its affiliates.
\#
\# This source code is licensed under the MIT license found in the
\# LICENSE file in the root directory of this source tree.

set -e

PLATFORM_NAME="${PLATFORM_NAME:-iphoneos}"
CURRENT_ARCH="${CURRENT_ARCH}"

if [ -z "$CURRENT_ARCH" ] || [ "$CURRENT_ARCH" == "undefined_arch" ]; then
  \# Xcode 10 beta sets CURRENT_ARCH to "undefined_arch", this leads to incorrect linker arg.
  \# it's better to rely on platform name as fallback because architecture differs between simulator and device

  if [[ "$PLATFORM_NAME" == *"simulator"* ]]; then
​    CURRENT_ARCH="x86_64"
  else
​    CURRENT_ARCH="armv7"
  fi
fi

export CC="$(xcrun -find -sdk $PLATFORM_NAME cc) -arch $CURRENT_ARCH -isysroot $(xcrun -sdk $PLATFORM_NAME --show-sdk-path)"
export CXX="$CC"

\# Remove automake symlink if it exists
if [ -h "test-driver" ]; then
  rm test-driver
fi

./configure --host arm-apple-darwin

\# Fix build for tvOS
cat << EOF >> src/config.h
/* Add in so we have Apple Target Conditionals */
\#ifdef __APPLE__
\#include <TargetConditionals.h>
\#include <Availability.h>
\#endif
/* Special configuration for AppleTVOS */
\#if TARGET_OS_TV
\#undef HAVE_SYSCALL_H
\#undef HAVE_SYS_SYSCALL_H
\#undef OS_MACOSX
\#endif
/* Special configuration for ucontext */
\#undef HAVE_UCONTEXT_H
\#undef PC_FROM_UCONTEXT
\#if defined(__x86_64__)
\#define PC_FROM_UCONTEXT uc_mcontext->__ss.__rip
\#elif defined(__i386__)
\#define PC_FROM_UCONTEXT uc_mcontext->__ss.__eip
\#endif
EOF

\# Prepare exported header include
EXPORTED_INCLUDE_DIR="exported/glog"
mkdir -p exported/glog
cp -f src/glog/log_severity.h "$EXPORTED_INCLUDE_DIR/"
cp -f src/glog/logging.h "$EXPORTED_INCLUDE_DIR/"
cp -f src/glog/raw_logging.h "$EXPORTED_INCLUDE_DIR/"
cp -f src/glog/stl_logging.h "$EXPORTED_INCLUDE_DIR/"
cp -f src/glog/vlog_is_on.h "$EXPORTED_INCLUDE_DIR/"

/bin/bash: ./configure: /bin/sh^M: bad interpreter: No such file or directory

 

또 에러가 발생했다.

 

 

에러의 원인은 다음과 같다.

 

키보드에서 enter 버튼을 누를 때마다 line ending에 보이지 않는 문자를 삽입하는데 각 운영 체제에 따라 line ending이 다르게 처리된다. Flipper-Glog를 설치할 때 Git에서 받아오는데 Windows 컴퓨터에서 작업 된 프로젝트를 Mac OS에서 사용 할 경우 Git에서 예기치 않은 결과가 발생할 수 있다. 그래서 line ending을 자동으로 처리하도록 Git을 구성해야한다.

 

 

Global settings for line endings

 

기존에 만들었던 프로젝트를 삭제 한 뒤에 terminal 창에서 다음 명령을 실행한다.

 

git config --global core.autocrlf input

 

그러고 다시 프로젝트를 생성하면 아주 잘 된다. 문제해결 완료!