无法安装 bootsnap 版本 1.4.4

Unable to install bootsnap version 1.4.4

我正在尝试使用 rails 让服务器首次启动。所以我正在使用

 ruby bin\rails server

它给了我:

Could not find gem 'turbolinks (~> 5) x86-mingw32' in any of the gem 
sources listed in your Gemfile.
Run `bundle install` to install missing gems.

当运行bundle install 它给了我:

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

当我尝试命令时它给我:

Error installing bootsnap:
    ERROR: Failed to build gem native extension.

这是错误日志的片段:

Fetching bootsnap 1.4.4
Installing bootsnap 1.4.4 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

current directory:
C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/bootsnap-1.4.4/ext/bootsnap
C:/RailsInstaller/Ruby2.3.3/bin/ruby.exe -r ./siteconf20190516-15728-gz8r2f.rb
extconf.rb
creating Makefile

current directory:
C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/bootsnap-1.4.4/ext/bootsnap
make "DESTDIR=" clean

current directory:
C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/bootsnap-1.4.4/ext/bootsnap
make "DESTDIR="
generating bootsnap-i386-mingw32.def
compiling bootsnap.c
bootsnap.c: In function 'bs_cache_path':
bootsnap.c:245:3: warning: unknown conversion type character 'l' in format
[-Wformat]
bootsnap.c:245:3: warning: too many arguments for format [-Wformat-extra-args]
bootsnap.c: In function 'bs_rb_fetch':
bootsnap.c:286:3: warning: ISO C90 forbids mixed declarations and code
[-Wdeclaration-after-statement]
bootsnap.c: In function 'fetch_cached_data':
bootsnap.c:412:3: warning: comparison is always false due to limited range of
data type [-Wtype-limits]
bootsnap.c: In function 'atomic_write_cache_file':
bootsnap.c:484:3: warning: implicit declaration of function 'mkstemp'
[-Wimplicit-function-declaration]
bootsnap.c: In function 'bs_rb_fetch':
bootsnap.c:632:13: warning: 'output_data' may be used uninitialized in this
function [-Wmaybe-uninitialized]
bootsnap.c:603:9: note: 'output_data' was declared here
linking shared-object bootsnap/bootsnap.so
bootsnap.o: In function `atomic_write_cache_file':
C:\RailsInstaller\Ruby2.3.3\lib\ruby\gems.3.0\gems\bootsnap-1.4.4\ext\bootsnap/bootsnap.c:484:
undefined reference to `mkstemp'
collect2.exe: error: ld returned 1 exit status
make: *** [bootsnap.so] Error 1

make failed, exit code 2

Gem files will remain installed in
C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/bootsnap-1.4.4 for
inspection.
Results logged to
C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/extensions/x86-mingw32/2.3.0/bootsnap-1.4.4/gem_make.out

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

In Gemfile:
  bootsnap

GemFile:

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

ruby '2.3.3'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.2.3'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use Puma as the app server
gem 'puma', '~> 3.11'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
gem 'duktape'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 4.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use ActiveStorage variant
# gem 'mini_magick', '~> 4.8'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', '>= 1.1.0', require: false

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
end

group :development do
  # Access an interactive console on exception pages or by calling 'console' anywhere in the code.
  gem 'web-console', '>= 3.3.0'
end

group :test do
  # Adds support for Capybara system testing and selenium driver
  gem 'capybara', '>= 2.15'
  gem 'selenium-webdriver'
  # Easy installation and use of chromedriver to run system tests with Chrome
  gem 'chromedriver-helper'
end

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

ruby 版本和 bootsnap gem 版本有问题。 所以根据 rails 5.2.3

升级你的 ruby 版本 '2.3.7' 或 '2.4.5'

Which Ruby on Rails is compatible with which Ruby version?

我遇到了完全相似的问题...花了我好几个小时才弄明白。我手动把版本改成gem 'bootsnap', '>= 1.4.4', require: false,还是不行。

所以我通过注释掉解决了。这是因为我发现我的应用程序在没有 bootsnap 的情况下仍然可以工作,因为它可以通过缓存昂贵的操作来加快启动时间。

为此,转到 Gemfile 并像这样注释掉 bootsnap:

#gem 'bootsnap', '>= 1.4.4', 要求: false

然后转到 boot.rb 文件中的配置并注释掉,如下所示:

#require 'bootsnap/setup' # 通过缓存昂贵的操作来加快启动时间。

之后,做

捆绑安装

然后如下启动我的 rails 服务器:

rails s

我尝试了你的建议:-

但它没有用 - 我的服务器启动了但可以加载我的应用程序 - 我的耐心受到了考验。

未评论 -

require 'bootsnap/setup' # Speed up boot time by caching expensive 
operations.

gem 'bootsnap', '>= 1.4.4', require: false 

和运行

Bundle Install

启动我的服务器,我的应用程序 运行 秒

今天我在试用时发生了这种情况 Rails 6. 在我的本地计算机上,我安装了 Ruby 2.7.0 版以及 Rails 6.0 版.1. 事实证明,我 刚刚 将 Mac 的 OS 升级到了 Catalina。我的解决方法是在终端

中 运行
xcode-select --install

我 运行 在我的 ~ 目录中,不确定这是否重要,因为 xcode 安装很可能是全局的。 在 运行 之后,我改回了新的 Rails 应用程序目录、运行 包和所有安装的东西,包括 bootsnap 和 pg。

希望这对最近升级 OS 的所有 Mac 用户有所帮助。请注意,我以前是 运行ning Mojave,在 运行ning Mojave 时已经安装了它,但仍然需要重新安装 xcode。