ruby-on-rails Rails gems在Ruby版本更新后崩溃

chy5wohz  于 2023-05-08  发布在  Ruby
关注(0)|答案(1)|浏览(162)

我们正在运行一个遗留的Rails应用程序,我们最近从Rails 4更新到Rails 6。
然而,当试图将其更新到版本7时,似乎我们需要更改Ruby版本。使用rbenv很简单:

rbenv local 2.7.4

之后,我们尝试使用更新后的Gemfile运行bundle install,得到以下错误:

current directory: /home/petarangelov/Desktop/dev/realappeal-esra/vendor/bundle/ruby/2.7.0/gems/skylight-5.0.1/ext
/home/petarangelov/.rbenv/versions/2.7.4/bin/ruby -I /home/petarangelov/.rbenv/versions/2.7.4/lib/ruby/2.7.0 -r ./siteconf20230504-290002-1y0acei.rb extconf.rb
*** 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=/XX/XX/.rbenv/versions/2.7.4/bin/$(RUBY_BASE_NAME)
/XX/XX/.rbenv/versions/2.7.4/lib/ruby/2.7.0/psych.rb:456:in `parse_stream': undefined method `parse' for #<Psych::Parser:0x000055c964928528> (NoMethodError)

看起来它是由skylight引起的,尽管我不明白为什么它不能正确编译。
更新后的Gemfile:

source 'https://rubygems.org'

gem 'rubocop'
gem 'pry'
gem 'aasm', '~> 5.0'
gem 'airbrake'
gem 'american_date'
gem "audited"
gem 'aws-sdk', '~> 2.0'
gem 'better_errors', '~> 2.5.1', group: :development
gem 'binding_of_caller', '~> 0.8.0', group: :development
gem 'byebug'
gem 'capistrano', '~> 3.7'
gem 'capistrano-bundler', '~> 1.4'
gem 'capistrano-passenger'
gem 'capistrano-rails', '~> 1.4'
gem 'capistrano-rbenv', '~> 2.1'
gem 'capistrano3-delayed-job', '~> 1.0'
gem 'capybara', group: [:development, :test]
gem 'capybara-screenshot', group: [:development, :test]
gem 'chosen-rails'
gem 'compass-rails', '3.1.0'
gem 'cucumber-rails', require: false, group: [:development, :test]
gem 'daemons'
gem 'database_cleaner', group: [:development, :test]
gem 'ddtrace'
gem 'delayed_job_active_record'
gem 'devise', '~> 4.7.3'
gem 'devise-async', git: 'https://github.com/mhfs/devise-async.git', ref: '177f6363a002f7ff28f1d289c8cab7ad8d9cb8c5'
gem 'devise-security'
gem 'factory_bot_rails', group: [:development, :test]
gem 'faker', group: [:development, :test, :staging]
gem 'fixedwidth', git: 'https://github.com/gristmill/fixedwidth.git', ref: '82575c2d6faa2d1aa82158147c5268f0d4f673bd'
gem 'fog-aws'
gem 'httparty'
gem 'jbuilder', '~> 2.7'
gem 'jquery-rails'
gem 'jquery-turbolinks'
gem 'launchy', group: [:development, :test]
gem 'lograge'
gem 'logstash-event'
gem 'mysql2', '>= 0.4.4', '< 0.6.0'
gem 'net-sftp'
gem 'omniauth-azure-activedirectory'
gem 'omniauth-saml'
gem 'paperclip', '~> 6.1'
gem 'poltergeist', group: [:development, :test]

gem 'rails', '7.0'
gem 'rails-erd'
gem 'rspec-rails', '> 5', group: [:development, :test]
gem 'ruby-kafka'
gem 'sass-rails', '~> 5.0'
gem 'sdoc', '~> 1.0', group: :doc
gem 'select2-rails'
gem 'simplecov', require: false, group: :test
gem 'skylight'
gem 'spring', group: :development
gem 'stupidedi'
gem 'timecop', group: :test
gem 'thread_safe'
gem 'trix'
gem 'validates_timeliness'
gem 'puma', '~> 5.6'
gem 'chronic'
gem 'unicorn'
gem 'turbolinks'
gem 'uglifier'
gem 'jc-validates_timeliness'

gem 'after_commit_everywhere'
gem 'rails-controller-testing'
gem 'will_paginate'

任何线索,至于这是从哪里来的,将大大赞赏:)

qojgxg4l

qojgxg4l1#

skylight目前是5.3.4,并声称与Ruby >= 2.6兼容,
skylight 5.0.1声称与Ruby >= 2.5兼容,这表明在2.5和2.6之间有一个突破性的变化。
这很可能是v5.1.0中的confirmed by this issue不能在Ruby 2.5.x中工作,因为当时对Psyche进行了更改
看来你也有类似的问题:

ruby/2.7.0/psych.rb:456:in `parse_stream': undefined method `parse' for #<Psych::Parser:0x000055c964928528> (NoMethodError)

我通常遵循这样的模式:
1.安装我想要的Ruby版本
1.从我的Gemfile中删除所有版本约束
1.在我想要的Ruby版本上执行bundle install
1.重新锁定我的gem版本(虽然我只软锁定到次要版本)

相关问题