12a1070
@12a1070 (寺井 智哉)

Are you sure you want to delete the question?

If your question is resolved, you may close it.

Leaving a resolved question undeleted may help others!

We hope you find it useful!

Railsチュートリアルのbundle installがパスできない

解決したいこと

  • Rails7のチュートリアルで$ bundle installがパスしない。
  • (できれば)Rails7のチュートリアルの進め方(何周すればいいか等)のアドバイスが欲しい。

前提

Railsのバージョン $Rails 7.0.8.4
Intel Macローカル環境

エラーの経緯

Rails7のチュートリアル第5章レイアウトを作成する。にてgem "bootstrap-sass", "3.4.1"を入れて
$ bundle installを行ったけどエラーが吐き出された。

発生している問題・エラー

Fetching gem metadata from https://rubygems.org/.........
Resolving dependencies...
Installing sassc 2.4.0 with native extensions
![uploading...0]()

Gem::Ext::BuildError: ERROR: Failed to build gem native extension. 
    
    current directory:
    /Users/名前/.rbenv/versions/3.1.3/lib/ruby/gems/3.1.0/gems/sassc-2.4.0/ext
make DESTDIR\= sitearchdir\=./.gem.20241020-54546-vi9nnq

以下、current directory: が続くので割愛
~~~

An error occurred while installing sassc (2.4.0), and Bundler cannot
continue.


In Gemfile:
  bootstrap-sass was resolved to 3.4.1, which depends on
    sassc

Gemfile

source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby "3.1.3"

# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
gem "rails", "~> 7.0.8", ">= 7.0.8.4"
gem "bootstrap-sass",  "3.4.1" ⇦今回追加

# The original asset pipeline for Rails [https://github.com/rails/sprockets-rails]
gem "sprockets-rails"

# Use sqlite3 as the database for Active Record
gem "sqlite3", "~> 1.4"

# Use the Puma web server [https://github.com/puma/puma]
gem "puma", "~> 5.0"

# Use JavaScript with ESM import maps [https://github.com/rails/importmap-rails]
gem "importmap-rails"

# Hotwire's SPA-like page accelerator [https://turbo.hotwired.dev]
gem "turbo-rails"

# Hotwire's modest JavaScript framework [https://stimulus.hotwired.dev]
gem "stimulus-rails"

# Build JSON APIs with ease [https://github.com/rails/jbuilder]
gem "jbuilder"

# Use Redis adapter to run Action Cable in production
# gem "redis", "~> 4.0"

# Use Kredis to get higher-level data types in Redis [https://github.com/rails/kredis]
# gem "kredis"

# Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword]
# gem "bcrypt", "~> 3.1.7"

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem "tzinfo-data", platforms: %i[ mingw mswin x64_mingw jruby ]

# Reduces boot times through caching; required in config/boot.rb
gem "bootsnap", require: false

# Use Sass to process CSS

# gem "sassc-rails"

# Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images]
# gem "image_processing", "~> 1.2"

group :development, :test do
  # See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
  gem "debug", platforms: %i[ mri mingw x64_mingw ]
end

group :development do
  # Use console on exceptions pages [https://github.com/rails/web-console]
  gem "web-console"
  gem "solargraph",          "0.50.0"
  gem "irb",                 "1.10.0"
  gem "repl_type_completor", "0.1.2"

  # Add speed badges [https://github.com/MiniProfiler/rack-mini-profiler]
  # gem "rack-mini-profiler"

  # Speed up commands on slow machines / big apps [https://github.com/rails/spring]
  # gem "spring"
end

group :test do
  # Use system testing [https://guides.rubyonrails.org/testing.html#system-testing]
  gem "capybara"
  gem "selenium-webdriver"
  gem "minitest"
  gem "minitest-reporters"
  gem "webdrivers"
  gem "guard"
  gem "guard-minitest"

end

自分で試したこと

  • エラー文1
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

「Gem::Ext::BuildError: ERROR: gem ネイティブ拡張のビルドに失敗しました。」

  • エラー文2
An error occurred while installing sassc (2.2.1), and Bundler cannot
continue.

sassc (2.2.1) のインストール中にエラーが発生しました。

chat GPTで質問したところ

  1. $ xcode-select --install をやってみようとのこと。
    結果として既にインストール済み

  2. sassc (2.2.1) のインストール中にエラーが発生しました。
    そもそもgem "sassc-rails"がコメントアウトになっているのに外す必要があるのか不明。gem "sassc-rails"のコメントを外して bundleすると

  bootstrap-sass was resolved to 3.4.1, which depends on
    sassc 

bootstrap-sass は 3.4.1 に解決されました。・・・解決とは?

余談

当初チュートリアルをprivateリポジトリで行っていたのですがシンプルブラウザからサーバーを立ち上げに切り替えたり、Renderへの自動デプロイがうまくいかずローカル環境のpublicリポジトリでアプリを再度作り直してきました。このまま続けて行っても大丈夫でしょうか?意見をいただけると幸いです。

0

1Answer

Comments

  1. @12a1070

    Questioner

    https://qiita.com/mmaumtjgj/items/ca07d3149a4f5577c667
    を拝見して

    bundle config set --local build.sassc -- --disable-march-tune-native
    

    した後、bundleを行ったのですが

    Installing sassc 2.4.0 with native extensions
    Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
    
    current directory:
    /Users/teraitomoya/.rbenv/versions/3.1.3/lib/ruby/gems/3.1.0/gems/sassc-2.4.0/ext
    /Users/teraitomoya/.rbenv/versions/3.1.3/bin/ruby -I
    /Users/teraitomoya/.rbenv/versions/3.1.3/lib/ruby/3.1.0 extconf.rb
    creating Makefile
    
    current directory:
    /Users/teraitomoya/.rbenv/versions/3.1.3/lib/ruby/gems/3.1.0/gems/sassc-2.4.0/ext
    make DESTDIR\= sitearchdir\=./.gem.20241020-55496-pnfuvx
    sitelibdir\=./.gem.20241020-55496-pnfuvx clean
    
    current directory:
    /Users/teraitomoya/.rbenv/versions/3.1.3/lib/ruby/gems/3.1.0/gems/sassc-2.4.0/ext
    make DESTDIR\= sitearchdir\=./.gem.20241020-55496-pnfuvx
    sitelibdir\=./.gem.20241020-55496-pnfuvx
    compiling ./libsass/src/ast.cpp
    In file included from ./libsass/src/ast.cpp:3:
    In file included from ./libsass/src/sass.hpp:55:
    In file included from ./libsass/src/memory.hpp:8:
    ./libsass/src/memory/allocator.hpp:8:10: fatal error: 'vector' file not found
        8 | #include <vector>
          |          ^~~~~~~~
    1 error generated.
    make: *** [ast.o] Error 1
    
    make failed, exit code 2
    

    どうやらヘッダファイルが見つからない。とchat GPTで調べたら返ってきまして
    Xcodeのコマンドラインツールをインストール/更新(macOS)

    xcode-select --install
    

    を行い、と返ってきまして。
    $ bundle config をしたところ

    Settings are listed in order of priority. The top value will be used.
    build.sassc
    Set for your local app (/Users/teraitomoya/workspace/sample_app/.bundle/config): "--disable-march-tune-native"
    

    再度 bundle installしたのですが全く反応がなくなってしまいました。Ctrl+Cで抜けることは可能です。

Your answer might help someone💌