programing

Gem 설치 오류:먼저 개발 도구를 설치해야 합니다(Windows).

showcode 2023. 4. 10. 22:27
반응형

Gem 설치 오류:먼저 개발 도구를 설치해야 합니다(Windows).

이 질문은 Windows에 대한 것입니다.

보석 'sinatra-websocket'을 설치하려고 했는데 실행했을 때gem install sinatra-websocket가 났어요

ERROR: Failed to build gem native extension

...와 함께...

C:/Ruby193/bin/ruby.exe extconf.rb
checking for main() in -lc... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

Provided configuration options:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=C:/Ruby193/bin/ruby
    --with-thin_parser-dir
    --without-thin_parser-dir
    --with-thin_parser-include
    --without-thin_parser-include=${thin_parser-dir}/include
    --with-thin_parser-lib
    --without-thin_parser-lib=${thin_parser-dir}/lib
    --with-clib
    --without-clib
C:/Ruby193/lib/ruby/1.9.1/mkmf.rb:381:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
    from C:/Ruby193/lib/ruby/1.9.1/mkmf.rb:461:in `try_link0'
    from C:/Ruby193/lib/ruby/1.9.1/mkmf.rb:476:in `try_link'
    from C:/Ruby193/lib/ruby/1.9.1/mkmf.rb:619:in `try_func'
    from C:/Ruby193/lib/ruby/1.9.1/mkmf.rb:845:in `block in have_library'
    from C:/Ruby193/lib/ruby/1.9.1/mkmf.rb:790:in `block in checking_for'
    from C:/Ruby193/lib/ruby/1.9.1/mkmf.rb:284:in `block (2 levels) in postpone'
    from C:/Ruby193/lib/ruby/1.9.1/mkmf.rb:254:in `open'
    from C:/Ruby193/lib/ruby/1.9.1/mkmf.rb:284:in `block in postpone'
    from C:/Ruby193/lib/ruby/1.9.1/mkmf.rb:254:in `open'
    from C:/Ruby193/lib/ruby/1.9.1/mkmf.rb:280:in `postpone'
    from C:/Ruby193/lib/ruby/1.9.1/mkmf.rb:789:in `checking_for'
    from C:/Ruby193/lib/ruby/1.9.1/mkmf.rb:840:in `have_library'
    from extconf.rb:4:in `<main>'

이게 뭐냐면mkmfC:\Ruby193\lib\ruby\gems\1.9.1\gems\thin-1.6.3\ext\thin_parser★★★★

"gcc -o conftest -IC:/Ruby193/include/ruby-1.9.1/i386-mingw32 -IC:/Ruby193/include/ruby-1.9.1/ruby/backward -IC:/Ruby193/include/ruby-1.9.1 -I. -DFD_SETSIZE=2048  -DFD_SETSIZE=2048  -O3 -fno-omit-frame-pointer -g -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration conftest.c  -L. -LC:/Ruby193/lib -L.   -march=i486   -lmsvcrt-ruby191  -lshell32 -lws2_32 -limagehlp -lshlwapi  "
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: #include <winsock2.h>
4: #include <windows.h>
5: int main(int argc, char **argv)
6: {
7:   return 0;
8: }
/* end */

Windows 7을 사용하고 있습니다.

에러가 발생하는 이유는 무엇입니까?"Makefile을 작성할 수 없습니다..."라는 행이 있습니다만, 그것이 관련이 있습니까?

Mac의 경우:

이 아직 않은 또는 Xcode를 이 있음), "xcode"를 합니다.xcode-select --install

않은 경우,은 ""를 Directory를 입니다.--switch

sudo xcode-select --switch /

xcode-select 매뉴얼을 참조하십시오.

  -s <path>, --switch <path>
          Sets the active developer directory to the given path, for example
          /Applications/Xcode-beta.app. This command must be run with
          superuser permissions (see sudo(8)), and will affect all users on
          the system. To set the path without superuser permissions or only
          for the current shell session, use the DEVELOPER_DIR environment
          variable instead (see ENVIRONMENT).

Xcode가 이미 설치되어 있는 경우 다른 문제가 발생할 수 있습니다.이 경우 다음 Puma 5.6.2의 네이티브 확장 버전 Gem:을 사용하여 설치를 참조하십시오.Ext::BuildError:ERROR:구축에 실패했습니다.

Mac의 경우:

실행한 적이 있습니까?

xcode-select --install

Xcode Developer 도구를 설치하려면?

MacOS 모하비(10.14.1)에서 이 문제가 발생했습니다.Homebrew를 통해 최신 루비를 설치하고 몇 가지 env 변수를 설정하여 해결했습니다.

: (발신처)brew info ruby□□□□□□□□★

export PATH="/usr/local/opt/ruby/bin:$PATH"
export LDFLAGS="-L/usr/local/opt/ruby/lib"
export CPPFLAGS="-I/usr/local/opt/ruby/include"
export PKG_CONFIG_PATH="/usr/local/opt/ruby/lib/pkgconfig"

우분투 18.04일은 Ubuntu를 하는 이었습니다.ubuntu-dev-tools★★★★★★★★★★★★★★★★★★:

$ sudo apt-get install ubuntu-dev-tools

edit: ruby installer는 이제 devkit을 포함한 설치를 제공합니다.다운로드 페이지에 라벨이 붙어 있습니다.

루비용 개발 도구를 놓쳤나 보네

여기서 입수할 수 있습니다.http://rubyinstaller.org/downloads/ 에서 「개발 키트」까지 스크롤 하면 됩니다.

원하는 곳에 다운로드하여 압축을 풀 수 있습니다. 을 실행합니다.ruby dk.rb init그러면 루비 설치를 자세히 설명하는 구성 파일이 생성됩니다.루비 설치 경로가 올바른지 확인하기 전에 이 구성 파일을 확인하십시오.

" " " 를 실행합니다.ruby dk.rb install그러면 개발 키트가 설치됩니다.

명령 프롬프트를 재시작하고 Gem 설치를 다시 시도합니다.

지금까지의 회답은 모두 시험했지만, 아무것도 효과가 없었다.

대신 다음을 수행:

brew install cocoapods

Mac에서 Xcode 도구를 최근에 업그레이드한 경우 다음 명령을 실행합니다.

sudo xcode-select --install
sudo xcodebuild -license

문제는 macOS Big Sur로 업데이트했는데 왠지 명령줄 툴이 구식이라는 것이었습니다.

가 이것을 된 것은 내가 가가를 실행하려고 때.brew install rbenv에러가 발생했습니다.

Error: Your Command Line Tools (CLT) does not support macOS 11.
It is either outdated or was modified.
Please update your Command Line Tools (CLT) or delete it if no updates are available.
Update them from Software Update in System Preferences or run:
  softwareupdate --all --install --force

If that doesn't show you any updates, run:
  sudo rm -rf /Library/Developer/CommandLineTools
  sudo xcode-select --install

Alternatively, manually download them from:
  https://developer.apple.com/download/more/.

그래서 뛰었어

sudo rm -rf /Library/Developer/CommandLineTools
sudo xcode-select --install

그리고 그것이 끝난 후, 보석은 성공적으로 설치되었다.

Mac OS 10.14(Mojave)를 사용하는 경우

cd  /Library/Developer/CommandLineTools/Packages/;
open macOS_SDK_headers_for_macOS_10.14.pkg

크레딧 투 로이 황 레퍼런스: https://stackoverflow.com/a/55732339/1598551

이 솔루션을 통해 다음과 같은 이점을 얻을 수 있었습니다.

  1. homebrew단말기를 경유합니다.

  2. 홈브루가 성공적으로 설치되면 터미널을 입력합니다.

    $ brew install cocoapods

드디어 완성!

설치 가능: 설치 .homebrew하다

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

여기서부터

다음은 mac OSX용 솔루션입니다.

터미널 앱:

순서 1: 다음 스크립트로 Xcode 개발자 도구가 설치되어 있는지 확인합니다.

xcode-select --install

2단계: 스크립트에 따라 루비를 업그레이드합니다.

brew install ruby

3단계: 다시 시도합니다.

즉, 컴파일러 도구가 설치되어 있지 않습니다.xcode-select --install를 인스톨 합니다. 또는 경우 를 사용할 수 를 들어, 패키지 매니저를 사용할 수 있습니다.apt install cmake님은 적절한 패키지 매니저를 탑재한 시스템에 필요한 빌드 툴을 설치해야 합니다.

사실 진짜 문제는 macOS의 메이저버전에서 다른 버전으로 업그레이드하여 새로운 X코드를 설치하는 것입니다.

cd /Library/Developer/CommandLineTools
ls -l SDKs/
total 0
lrwxr-xr-x  1 root  wheel   14 Feb  4 21:41 MacOSX.sdk -> MacOSX11.1.sdk
drwxr-xr-x  8 root  wheel  256 Feb  4 21:43 MacOSX10.15.sdk
drwxr-xr-x  7 root  wheel  224 Feb  4 21:43 MacOSX11.1.sdk

Apple의 개발자 사이트에 접속하여 CLI 툴을 수동으로 다운로드하면 다음과 같은 내용이 폴더에 포함됩니다.

$> ls -l SDKs/
lrwxr-xr-x  1 root  wheel   14 May  4 18:10 MacOSX.sdk -> MacOSX11.3.sdk
drwxr-xr-x  8 root  wheel  256 May  4 18:10 MacOSX10.15.sdk
drwxr-xr-x  7 root  wheel  224 Feb  4 21:43 MacOSX11.1.sdk
drwxr-xr-x  7 root  wheel  224 Mar 16 10:03 MacOSX11.3.sdk
lrwxr-xr-x  1 root  wheel   14 May  4 18:09 MacOSX11.sdk -> MacOSX11.3.sdk

다음의 조작으로 X코드를 리셋 할 필요가 있는 경우가 있습니다.

$> sudo xcode-select --reset
$> sudo xcodebuild -license

확인 방법:

$> sudo xcode-select --print-path
/Applications/Xcode.app/Contents/Developer

마지막으로 컴파일 오류가 아직 표시되는 경우 컴파일러 오류에 주의하여 대처해야 합니다.예를 들어 macOS에서 Big Sur clang은 선언(구조)을 추가하기 위해 특별한 인수가 필요합니다.다음과 같이 수정되었습니다.

export CFLAGS="-fdeclspec $CFLAGS"

궁금하신 분(또는 Ruby 3.0.x의 온라인 답변을 원하시는 분)은 다음과 같습니다.

/usr/local/Cellar/ruby/3.0.1/include/ruby-3.0.0/ruby/internal/fl_type.h:285:1: error: '__declspec' attributes are not enabled; use '-fdeclspec' or '-fms-extensions' to enable support for __declspec attributes

최근에 MAC OS big sur로 업그레이드했는데 gem install 실행 시 오류가 나타나기 시작했는데...

해결책은 CLT를 완전히 제거하고 설치를 다시 실행하는 것입니다.

옵션:

양조업그레이드

실행:

sudo rm -rf / Library / Developer / CommandLineTools

sudo xcode-select --install

Ubuntu 20.04.3 LTS(Focal Fossa) -- WSL

그 전에 해결해야 할 의존관계가 몇 가지 있습니다.다음 일련의 명령어를 사용해 보세요.

# if ERROR: 'Gem installation error: You have to install development tools first'
# BEFORE installing the dev-tools, install dependencies:
# if ERROR: 'GCC fatal error: stdio.h: No such file or directory'
$ sudo apt-get install libc6
# https://stackoverflow.com/a/20150282/5078874
$ sudo apt-get install libc6-dev
$ sudo apt-get install libffi-dev

# Now, go for the development tools
# https://stackoverflow.com/a/63442072/5078874
$ sudo apt-get install ubuntu-dev-tools

# Finally, try again
$ bundle update --bundler
# ... enjoy :)

참고 자료:

여러 버전의 Xcode가 설치되어 있는 경우 최신 버전에서 명령줄 도구를 선택해야 합니다.그렇지 않으면 gem에서 도구를 찾을 수 없습니다.

MacOS Catalina의 경우 실행 후$ brew install coreutils (credit) – - 나는 주방장 설치 에반 호프만의 오래된 기사를 따라갔다(Ruby의 최신 안정적인 릴리스를 포함).

$ curl -L https://www.getchef.com/chef/install.sh | sudo bash

그러면 필요한 개발 도구를 모두 설치한 상태에서 필요한 보석을 설치할 수 있습니다.

$ sudo gem install -V <gem>

주행거리는 Big Sur에 따라 다를 수 있습니다.

Mac에서는 다음 작업을 수행했습니다.

sudo xcode-select --reset

이전에 xcode-select를 설치했는데, 그래도 작동하지 않았습니다.--reset을 하면 문제가 해결됩니다.

언급URL : https://stackoverflow.com/questions/27768420/gem-installation-error-you-have-to-install-development-tools-first-windows

반응형