我正在尝试使用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\2.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]
答案 0 :(得分:0)
ruby版本和bootsnap gem版本存在问题。 因此请按照Rails 5.2.3升级您的ruby版本“ 2.3.7”或“ 2.4.5”
答案 1 :(得分:0)
我也有类似的问题...花了我几个小时才弄清楚。我手动将版本更改为gem'bootsnap','> = 1.4.4',要求:false,但是不起作用。
所以我通过注释解决了。这是因为我发现我的应用程序无需引导即可运行,因为它通过缓存昂贵的操作来加快启动时间很有用。
为此,请转到Gemfile并注释掉引导,如下所示:
#gem'bootsnap','> = 1.4.4',要求:false
然后转到config中的boot.rb文件并注释掉,如下所示:
#require'bootsnap / setup'#通过缓存昂贵的操作来加快启动时间。
之后,做
捆绑安装
然后按如下所示启动我的Rails服务器:
rails s
答案 2 :(得分:0)
我尝试了您的建议:-
但是它不起作用-我的服务器启动了,但可以加载我的应用程序-我的耐心已经过测试。
未注释-
require 'bootsnap/setup' # Speed up boot time by caching expensive
operations.
gem 'bootsnap', '>= 1.4.4', require: false
并运行
Bundle Install
启动我的服务器,我的应用程序在几秒钟内启动
答案 3 :(得分:0)
今天,当我尝试使用Rails 6时,这发生在我身上。在我的本地计算机上,我安装了Ruby 2.7.0版以及Rails 6.0.1版。 原来,我已经 just 将Mac的操作系统升级到了Catalina。对我来说,解决方法是在终端机上运行
xcode-select --install
我在~
目录中运行了此文件,不确定这是否重要,因为xcode安装很可能是全局安装。
运行此命令后,我回到我的新Rails应用程序目录,运行捆绑软件,安装的所有内容都没有问题,包括bootsnap和pg。
希望这对最近升级了操作系统的所有Mac用户有帮助。请注意,我以前运行Mojave,但在运行Mojave时已经安装了xcode,仍然需要重新安装xcode。