簡體   English   中英

使用 rails 的捆綁器問題(mac 用戶)

[英]Problem with bundler using rails (mac user)

當我嘗試運行我的應用程序時,出現以下錯誤:

Could not find racc-1.5.2 in any of the sources
Run `bundle install` to install missing gems.

我跑:

$ bundle install

回復:

Your user account isn't allowed to install to the system RubyGems.
  You can cancel this installation and run:

      bundle config set --local path 'vendor/bundle'
      bundle install

$ 輸入密碼兩次(系統詢問兩次)

回復:

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /var/folders/_b/7g9qk9qn2tbc7m16nsnj7jww0000gn/T/bundler20210303-5388-861puoracc-1.5.2/gems/racc-1.5.2/ext/racc/cparse
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby -I /Library/Ruby/Site/2.6.0 -r ./siteconf20210303-5388-1sxj4i7.rb extconf.rb
checking for rb_ary_subseq()... *** 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=/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/$(RUBY_BASE_NAME)
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:467:in `try_do': The compiler failed to generate an executable file.
(RuntimeError)
You have to install development tools first.
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:546:in `block in try_link0'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/tmpdir.rb:93:in `mktmpdir'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:543:in `try_link0'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:570:in `try_link'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:782:in `try_func'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:1069:in `block in have_func'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:959:in `block in checking_for'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:361:in `block (2 levels) in postpone'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:331:in `open'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:361:in `block in postpone'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:331:in `open'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:357:in `postpone'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:958:in `checking_for'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:1068:in `have_func'
    from extconf.rb:6:in `<main>'

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /var/folders/_b/7g9qk9qn2tbc7m16nsnj7jww0000gn/T/bundler20210303-5388-861puoracc-1.5.2/extensions/universal-darwin-20/2.6.0/racc-1.5.2/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /var/folders/_b/7g9qk9qn2tbc7m16nsnj7jww0000gn/T/bundler20210303-5388-861puoracc-1.5.2/gems/racc-1.5.2 for inspection.
Results logged to
/var/folders/_b/7g9qk9qn2tbc7m16nsnj7jww0000gn/T/bundler20210303-5388-861puoracc-1.5.2/extensions/universal-darwin-20/2.6.0/racc-1.5.2/gem_make.out

An error occurred while installing racc (1.5.2), and Bundler cannot continue.
Make sure that `gem install racc -v '1.5.2' --source 'https://rubygems.org/'` succeeds before bundling.

In Gemfile:
  rails was resolved to 6.1.3, which depends on
    actioncable was resolved to 6.1.3, which depends on
      actionpack was resolved to 6.1.3, which depends on
        actionview was resolved to 6.1.3, which depends on
          rails-dom-testing was resolved to 2.0.3, which depends on
            nokogiri was resolved to 1.11.1, which depends on
              racc


Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /var/folders/_b/7g9qk9qn2tbc7m16nsnj7jww0000gn/T/bundler20210303-5388-5s57nvnio4r-2.5.5/gems/nio4r-2.5.5/ext/nio4r
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby -I /Library/Ruby/Site/2.6.0 -r ./siteconf20210303-5388-1yywys0.rb extconf.rb
checking for unistd.h... *** 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=/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/$(RUBY_BASE_NAME)
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:467:in `try_do': The compiler failed to generate an executable file.
(RuntimeError)
You have to install development tools first.
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:585:in `block in try_compile'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:534:in `with_werror'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:585:in `try_compile'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:1109:in `block in have_header'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:959:in `block in checking_for'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:361:in `block (2 levels) in postpone'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:331:in `open'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:361:in `block in postpone'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:331:in `open'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:357:in `postpone'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:958:in `checking_for'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:1108:in `have_header'
    from extconf.rb:15:in `<main>'

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /var/folders/_b/7g9qk9qn2tbc7m16nsnj7jww0000gn/T/bundler20210303-5388-5s57nvnio4r-2.5.5/extensions/universal-darwin-20/2.6.0/nio4r-2.5.5/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /var/folders/_b/7g9qk9qn2tbc7m16nsnj7jww0000gn/T/bundler20210303-5388-5s57nvnio4r-2.5.5/gems/nio4r-2.5.5 for
inspection.
Results logged to
/var/folders/_b/7g9qk9qn2tbc7m16nsnj7jww0000gn/T/bundler20210303-5388-5s57nvnio4r-2.5.5/extensions/universal-darwin-20/2.6.0/nio4r-2.5.5/gem_make.out

An error occurred while installing nio4r (2.5.5), and Bundler cannot continue.
Make sure that `gem install nio4r -v '2.5.5' --source 'https://rubygems.org/'` succeeds before bundling.

In Gemfile:
  rails was resolved to 6.1.3, which depends on
    actioncable was resolved to 6.1.3, which depends on
      nio4r


Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /var/folders/_b/7g9qk9qn2tbc7m16nsnj7jww0000gn/T/bundler20210303-5388-4k1ekzbcrypt-3.1.16/gems/bcrypt-3.1.16/ext/mri
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby -I /Library/Ruby/Site/2.6.0 -r ./siteconf20210303-5388-1xu8ddx.rb extconf.rb
creating Makefile

current directory: /var/folders/_b/7g9qk9qn2tbc7m16nsnj7jww0000gn/T/bundler20210303-5388-4k1ekzbcrypt-3.1.16/gems/bcrypt-3.1.16/ext/mri
make DESTDIR\= clean

current directory: /var/folders/_b/7g9qk9qn2tbc7m16nsnj7jww0000gn/T/bundler20210303-5388-4k1ekzbcrypt-3.1.16/gems/bcrypt-3.1.16/ext/mri
make DESTDIR\=
make: *** No rule to make target
`/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/universal-darwin20/ruby/config.h',
needed by `bcrypt_ext.o'.  Stop.

make failed, exit code 2

Gem files will remain installed in /var/folders/_b/7g9qk9qn2tbc7m16nsnj7jww0000gn/T/bundler20210303-5388-4k1ekzbcrypt-3.1.16/gems/bcrypt-3.1.16 for
inspection.
Results logged to
/var/folders/_b/7g9qk9qn2tbc7m16nsnj7jww0000gn/T/bundler20210303-5388-4k1ekzbcrypt-3.1.16/extensions/universal-darwin-20/2.6.0/bcrypt-3.1.16/gem_make.out

An error occurred while installing bcrypt (3.1.16), and Bundler cannot continue.
Make sure that `gem install bcrypt -v '3.1.16' --source 'https://rubygems.org/'` succeeds before bundling.

In Gemfile:
  devise was resolved to 4.7.3, which depends on
    bcrypt


Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /var/folders/_b/7g9qk9qn2tbc7m16nsnj7jww0000gn/T/bundler20210303-5388-z8an9bbindex-0.8.1/gems/bindex-0.8.1/ext/skiptrace
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby -I /Library/Ruby/Site/2.6.0 -r ./siteconf20210303-5388-1k62vcs.rb extconf.rb
creating Makefile

current directory: /var/folders/_b/7g9qk9qn2tbc7m16nsnj7jww0000gn/T/bundler20210303-5388-z8an9bbindex-0.8.1/gems/bindex-0.8.1/ext/skiptrace
make DESTDIR\= clean

current directory: /var/folders/_b/7g9qk9qn2tbc7m16nsnj7jww0000gn/T/bundler20210303-5388-z8an9bbindex-0.8.1/gems/bindex-0.8.1/ext/skiptrace
make DESTDIR\=
make: *** No rule to make target
`/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/universal-darwin20/ruby/config.h',
needed by `cruby.o'.  Stop.

make failed, exit code 2

Gem files will remain installed in /var/folders/_b/7g9qk9qn2tbc7m16nsnj7jww0000gn/T/bundler20210303-5388-z8an9bbindex-0.8.1/gems/bindex-0.8.1 for
inspection.
Results logged to
/var/folders/_b/7g9qk9qn2tbc7m16nsnj7jww0000gn/T/bundler20210303-5388-z8an9bbindex-0.8.1/extensions/universal-darwin-20/2.6.0/bindex-0.8.1/gem_make.out

An error occurred while installing bindex (0.8.1), and Bundler cannot continue.
Make sure that `gem install bindex -v '0.8.1' --source 'https://rubygems.org/'` succeeds before bundling.

In Gemfile:
  web-console was resolved to 4.1.0, which depends on
    bindex


Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /var/folders/_b/7g9qk9qn2tbc7m16nsnj7jww0000gn/T/bundler20210303-5388-tk45tbmsgpack-1.4.2/gems/msgpack-1.4.2/ext/msgpack
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby -I /Library/Ruby/Site/2.6.0 -r ./siteconf20210303-5388-5tsgu7.rb extconf.rb
checking for ruby/st.h... *** 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=/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/$(RUBY_BASE_NAME)
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:467:in `try_do': The compiler failed to generate an executable file.
(RuntimeError)
You have to install development tools first.
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:585:in `block in try_compile'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:534:in `with_werror'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:585:in `try_compile'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:1109:in `block in have_header'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:959:in `block in checking_for'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:361:in `block (2 levels) in postpone'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:331:in `open'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:361:in `block in postpone'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:331:in `open'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:357:in `postpone'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:958:in `checking_for'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:1108:in `have_header'
    from extconf.rb:3:in `<main>'

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /var/folders/_b/7g9qk9qn2tbc7m16nsnj7jww0000gn/T/bundler20210303-5388-tk45tbmsgpack-1.4.2/extensions/universal-darwin-20/2.6.0/msgpack-1.4.2/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /var/folders/_b/7g9qk9qn2tbc7m16nsnj7jww0000gn/T/bundler20210303-5388-tk45tbmsgpack-1.4.2/gems/msgpack-1.4.2 for
inspection.
Results logged to
/var/folders/_b/7g9qk9qn2tbc7m16nsnj7jww0000gn/T/bundler20210303-5388-tk45tbmsgpack-1.4.2/extensions/universal-darwin-20/2.6.0/msgpack-1.4.2/gem_make.out

An error occurred while installing msgpack (1.4.2), and Bundler cannot continue.
Make sure that `gem install msgpack -v '1.4.2' --source 'https://rubygems.org/'` succeeds before bundling.

In Gemfile:
  bootsnap was resolved to 1.7.2, which depends on
    msgpack


Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /var/folders/_b/7g9qk9qn2tbc7m16nsnj7jww0000gn/T/bundler20210303-5388-pjciubbyebug-11.1.3/gems/byebug-11.1.3/ext/byebug
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby -I /Library/Ruby/Site/2.6.0 -r ./siteconf20210303-5388-18f31t0.rb extconf.rb
creating Makefile

current directory: /var/folders/_b/7g9qk9qn2tbc7m16nsnj7jww0000gn/T/bundler20210303-5388-pjciubbyebug-11.1.3/gems/byebug-11.1.3/ext/byebug
make DESTDIR\= clean

current directory: /var/folders/_b/7g9qk9qn2tbc7m16nsnj7jww0000gn/T/bundler20210303-5388-pjciubbyebug-11.1.3/gems/byebug-11.1.3/ext/byebug
make DESTDIR\=
make: *** No rule to make target
`/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/universal-darwin20/ruby/config.h',
needed by `breakpoint.o'.  Stop.

make failed, exit code 2

Gem files will remain installed in /var/folders/_b/7g9qk9qn2tbc7m16nsnj7jww0000gn/T/bundler20210303-5388-pjciubbyebug-11.1.3/gems/byebug-11.1.3 for
inspection.
Results logged to
/var/folders/_b/7g9qk9qn2tbc7m16nsnj7jww0000gn/T/bundler20210303-5388-pjciubbyebug-11.1.3/extensions/universal-darwin-20/2.6.0/byebug-11.1.3/gem_make.out

An error occurred while installing byebug (11.1.3), and Bundler cannot continue.
Make sure that `gem install byebug -v '11.1.3' --source 'https://rubygems.org/'` succeeds before bundling.

In Gemfile:
  byebug

信息:

ruby -v
ruby 2.6.3p62 (2019-04-16 revision 67580) [universal.x86_64-darwin20]

Bundler 版本 2.2.12(2021-03-01 提交 1de3f8de73)(這是我開始遇到問題的時候)

rails -v
Rails 6.1.3

我自己也有這個問題。 您只需要更新 Mac 的 CommandLineTools。

在我的根目錄中運行此代碼已修復它:

xcode-選擇--安裝

確保您已授予開發人員工具對終端的訪問權限,沒有它,無論您執行多少次xcode-select --install它都不會工作在此處輸入圖像描述

我能夠通過以下教程解決問題

https://gorails.com/setup/osx/11.0-big-sur

嘗試安裝

sudo gem install package_name

然后再次運行

bundle install 

要解決此問題,我必須將以下環境變量添加到我的~/.profile / ~/.bash_profile中:

export SDKROOT=$(xcrun --sdk macosx --show-sdk-path)
export LIBRARY_PATH="/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib"

一旦我添加了這些,我就能夠安裝racc Gem。

請注意,您可能需要先通過以下方式安裝/設置 Xcode SDK/庫:

xcode-select --install
sudo xcodebuild -license
sudo xcode-select --switch /Applications/Xcode.app

您很可能缺少ruby-dev源庫。 您也很可能使用系統提供的 ruby,而不是安裝在您自己的主目錄中的。

我強烈建議您安裝rvmrbenv並使用其中任何一個來配置您的系統。

這里有一些非常完整的 MacOS 安裝說明,用於安裝和配置 ruby 2.7.1 開發環境。

https://gist.github.com/mcls/3118518

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM