如何解决升级到 Ruby 3.0 后应用 (rails 6.1.1) 无法启动
这是 Gemfile:
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby '3.0.0'
# Bundle edge Rails instead: gem 'rails',github: 'rails/rails'
gem 'rails','~> 6.1.0'
# Use mysql as the database for Active Record
gem 'mysql2','>= 0.4.4'
# Use Puma as the app server
gem 'puma','~> 5.0'
# Use SCSS for stylesheets
gem 'sass-rails','>= 6'
# Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker
gem 'webpacker','~> 5.0'
# 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.7'
# Flexible authentication solution for Rails with Warden
gem 'devise','~> 4.7'
# A simple HTTP and REST client
gem 'rest-client','~> 2.1'
# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap','>= 1.4.2',require: false
# Devise supports i18n in controllers,models,and in other areas,# but it does not have support for internationalized views.
# devise-i18n adds this support.
gem 'devise-i18n','~> 1.9'
# Devise Bootstrap Views
gem 'devise-bootstrap-views','~> 1.0'
# Configure Devise to send its emails asynchronously using ActiveJob
gem 'devise-async','~> 1.0'
# Stripe is the easiest way to accept payments online
gem 'stripe','~> 5.22'
# A gem that provides a client interface for the Sentry error logger
gem 'sentry-raven','~> 3.0'
# Taming Rails' Default Request Logging
gem 'lograge','~> 0.11'
# Ruby state machines
gem 'aasm','~> 5.0'
# Allows to use ActiveRecord transactional callbacks outside of ActiveRecord models,literally everywhere in your application.
gem 'after_commit_everywhere','~> 0.1','>= 0.1.5'
# Agnostic pagination in plain ruby
gem 'pagy','~> 3.8'
# Connection Pool
gem 'connection_pool','~> 2.2'
# Redis client
gem 'hiredis','~> 0.6'
gem 'redis','~> 4.1',require: ['redis','redis/connection/hiredis']
# Sidekiq
gem 'sidekiq','~> 6.0'
# Check password strength against several rules
gem 'password_strength','~> 1.1'
# Slack Ruby Client
gem 'slack-ruby-client','~> 0.15'
# Assets on AWS S3/CloudFront
gem 'asset_sync','~> 2.12'
gem 'fog-aws','~> 3.6'
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'
gem 'listen','>= 3.0.5'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
gem 'spring-watcher-listen','~> 2.0'
gem 'rspec-rails','~> 4.0'
gem 'amazing_print','~> 1.2'
end
group :test do
# Adds support for Capybara system testing and selenium driver
gem 'capybara','>= 2.15'
gem 'capybara-screenshot'
gem 'selenium-webdriver'
# Easy installation and use of web drivers to run system tests with browsers
gem 'webdrivers'
gem 'factory_bot_rails','~> 6.0'
gem 'shoulda-matchers','~> 4.1'
gem 'rails-controller-testing'
gem 'faker'
gem 'database_cleaner-active_record'
gem 'coderay'
gem 'mock_redis'
end
应用程序似乎在 Rails.application.initialize!
期间被阻止。
不知道会不会是Ruby 3.0不兼容的gem,但是我从头开始了一个新的应用,安装了所有的gem,应用正常启动。
我使用 puma (5.1.1) 作为网络服务器。 该应用程序通过 docker-compose 在 docker 容器中运行。
FROM ruby:2.7.2
# Update for security reason
RUN apt-get update -yqq && apt-get upgrade -yqq -o Dpkg::Options::="--force-confold" && apt-get install -yqq --no-install-recommends \
vim # needed for editing rails credentials
# Ensure we install an up-to-date version of Node
RUN curl -sL https://deb.nodesource.com/setup_14.x | bash -
# Ensure latest packages for Yarn
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
RUN echo "deb https://dl.yarnpkg.com/debian stable main" | tee /etc/apt/sources.list.d/yarn.list
RUN apt-get update -yqq && apt-get install -yqq --no-install-recommends \
nodejs \
yarn
ENV RAILS_ROOT /var/www/app
RUN mkdir -p $RAILS_ROOT
COPY Gemfile* /var/www/app/
WORKDIR /var/www/app
ENV BUNDLE_PATH /gems
RUN bundle install
COPY package.json package.json
COPY yarn.lock yarn.lock
RUN yarn install --check-files
COPY . /var/www/app/
EXPOSE 3000
# Clean up APT when done.
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
ENTRYPOINT ["./puma-entrypoint.sh"]
CMD ["bundle","exec","puma","-C","config/puma/development.rb"]
# Puma can serve each request in a thread from an internal thread pool.
# The `threads` method setting takes two numbers: a minimum and maximum.
# Any libraries that use thread pools should be configured to match
# the maximum value specified for Puma. Default is set to 5 threads for minimum
# and maximum; this matches the default thread size of Active Record.
#
max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count }
threads min_threads_count,max_threads_count
# Specifies the `worker_timeout` threshold that Puma will use to wait before
# terminating a worker in development environments.
#
worker_timeout 3600 if ENV.fetch("RAILS_ENV","development") == "development"
# Specifies the `port` that Puma will listen on to receive requests; default is 3000.
#
port ENV.fetch("PORT") { 3000 }
# Specifies the `environment` that Puma will run in.
#
environment ENV.fetch("RAILS_ENV") { "development" }
# Specifies the `pidfile` that Puma will use.
pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" }
# Specifies the number of `workers` to boot in clustered mode.
# Workers are forked web server processes. If using threads and workers together
# the concurrency of the application would be max `threads` * `workers`.
# Workers do not work on JRuby or Windows (both of which do not support
# processes).
#
# workers ENV.fetch("WEB_CONCURRENCY") { 2 }
# Use the `preload_app!` method when specifying a `workers` number.
# This directive tells Puma to first boot the application and load code
# before forking the application. This takes advantage of Copy On Write
# process behavior so workers use less memory.
#
# preload_app!
# Allow puma to be restarted by `rails restart` command.
plugin :tmp_restart
有没有办法让日志来查看启动过程中发生的事情?
解决方法
请提供更多信息。
- 你在哪个系统上?
- 您如何开始申请?如果遇到问题,请始终在控制台上启动。
- Puma 有一个日志输出。搜索此位置。将日志输出放在这里。
- 尝试移除所有 gem 或其中大部分以查找错误。
研究这个话题,我发现没有太多有用的信息,所以只是想为这个事业做出贡献......
您没有提供太多信息,但再次尝试将 Dockerfile 中的 FROM ruby:2.7.2
更改为 FROM ruby: 3.0.0
。还要检查 Bundler 是否仍在使用 ruby 3.0,如果不是,请尝试将其更新到 v2.2。
https://www.ruby-lang.org/en/news/2020/12/25/ruby-3-0-0-released/ https://bundler.io/blog/
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。