首页 > 解决方案 > 无法加载此类文件 -- autoprefixer-rails (LoadError) | 导轨 5

问题描述

几天来,我不知道原因,但每次我想开始或做一个动作并且gem 'bootstrap', git: ' https://github.com/twbs/bootstrap-rubygem'我的应用程序 rails 5 上安装了 boostrap ( ) 时,它总是给我同样的错误: /Users/Admin/.rvm/gems/ruby-2.5.3/bundler/gems/bootstrap-rubygem-2f5416832341/lib/bootstrap/engine.rb:3:in 'require': cannot load such file -- autoprefixer-rails (LoadError)

我已经尝试多次卸载所有内容(rails + all gems),但仍然无法正常工作。

完整的错误信息:

Traceback (most recent call last):
25: from bin/rails:4:in `<main>'
24: from bin/rails:4:in `require'
23: from /Users/theo/.rvm/gems/ruby-2.5.3/gems/railties-5.1.6.1/lib/rails/commands.rb:16:in `<top (required)>'
22: from /Users/theo/.rvm/gems/ruby-2.5.3/gems/railties-5.1.6.1/lib/rails/command.rb:44:in `invoke'
21: from /Users/theo/.rvm/gems/ruby-2.5.3/gems/railties-5.1.6.1/lib/rails/command/base.rb:63:in `perform'
20: from /Users/theo/.rvm/gems/ruby-2.5.3/gems/thor-0.20.3/lib/thor.rb:387:in `dispatch'
19: from /Users/theo/.rvm/gems/ruby-2.5.3/gems/thor-0.20.3/lib/thor/invocation.rb:126:in `invoke_command'
18: from /Users/theo/.rvm/gems/ruby-2.5.3/gems/thor-0.20.3/lib/thor/command.rb:27:in `run'
17: from /Users/theo/.rvm/gems/ruby-2.5.3/gems/railties-5.1.6.1/lib/rails/commands/server/server_command.rb:130:in `perform'
16: from /Users/theo/.rvm/gems/ruby-2.5.3/gems/railties-5.1.6.1/lib/rails/commands/server/server_command.rb:130:in `tap'
15: from /Users/theo/.rvm/gems/ruby-2.5.3/gems/railties-5.1.6.1/lib/rails/commands/server/server_command.rb:133:in `block in perform'
14: from /Users/theo/.rvm/gems/ruby-2.5.3/gems/railties-5.1.6.1/lib/rails/commands/server/server_command.rb:133:in `require'
13: from /Users/theo/Documents/Projet/Startizy/Startizy/config/application.rb:7:in `<top (required)>'
12: from /Users/theo/.rvm/gems/ruby-2.5.3/gems/bundler-1.17.2/lib/bundler.rb:114:in `require'
11: from /Users/theo/.rvm/gems/ruby-2.5.3/gems/bundler-1.17.2/lib/bundler/runtime.rb:65:in `require'
10: from /Users/theo/.rvm/gems/ruby-2.5.3/gems/bundler-1.17.2/lib/bundler/runtime.rb:65:in `each'
 9: from /Users/theo/.rvm/gems/ruby-2.5.3/gems/bundler-1.17.2/lib/bundler/runtime.rb:76:in `block in require'
 8: from /Users/theo/.rvm/gems/ruby-2.5.3/gems/bundler-1.17.2/lib/bundler/runtime.rb:76:in `each'
 7: from /Users/theo/.rvm/gems/ruby-2.5.3/gems/bundler-1.17.2/lib/bundler/runtime.rb:81:in `block (2 levels) in require'
 6: from /Users/theo/.rvm/gems/ruby-2.5.3/gems/bundler-1.17.2/lib/bundler/runtime.rb:81:in `require'
 5: from /Users/theo/.rvm/gems/ruby-2.5.3/bundler/gems/bootstrap-rubygem-2f5416832341/lib/bootstrap.rb:75:in `<top (required)>'
 4: from /Users/theo/.rvm/gems/ruby-2.5.3/bundler/gems/bootstrap-rubygem-2f5416832341/lib/bootstrap.rb:11:in `load!'
 3: from /Users/theo/.rvm/gems/ruby-2.5.3/bundler/gems/bootstrap-rubygem-2f5416832341/lib/bootstrap.rb:61:in `register_rails_engine'
 2: from /Users/theo/.rvm/gems/ruby-2.5.3/bundler/gems/bootstrap-rubygem-2f5416832341/lib/bootstrap.rb:61:in `require'
 1: from /Users/theo/.rvm/gems/ruby-2.5.3/bundler/gems/bootstrap-rubygem-2f5416832341/lib/bootstrap/engine.rb:3:in `<top (required)>'
/Users/theo/.rvm/gems/ruby-2.5.3/bundler/gems/bootstrap-rubygem-2f5416832341/lib/bootstrap/engine.rb:3:in `require': cannot load such file -- autoprefixer-rails (LoadError)

我的宝石文件:

source 'https://rubygems.org'
ruby '2.5.3'

git_source(:github) do |repo_name|
  repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
  "https://github.com/#{repo_name}.git"
end


# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.1.6'
# Use PG as the database for Active Record
gem 'pg', '0.21.0'

gem "singularitygs", "~>1.4"
gem "autoprefixer-rails"

# Use SCSS for stylesheets
gem 'bootstrap', git: 'https://github.com/twbs/bootstrap-rubygem'
gem 'sass-rails'
gem 'jquery-rails'

gem 'sendgrid-ruby'

# PDF generator
gem 'wicked_pdf'
gem 'wkhtmltopdf-binary'

# Generate Word
gem 'htmltoword'

# FOR WHAT ??
gem 'smtpapi'

# Use Uglifier as compressor for JavaScript assets
gem 'uglifier'

# ICONES
gem 'font-awesome-sass', '~> 4.7.0'
gem 'simple-line-icons-rails'

# Pagination
gem 'will_paginate'
gem 'will_paginate-bootstrap4' # For the style on Bootstrap 4

# URL FRIENDLY
gem 'friendly_id', '~> 5.1.0'

# Cookie gestion by session store
gem 'activerecord-session_store'

# Security
gem 'devise'

## Deployment
gem 'puma'

## EXCEPTION
gem 'exception_notification'

## WORD
gem 'docx_replace'
gem 'odf-report'

# Image upload handling
gem 'carrierwave', github: 'carrierwaveuploader/carrierwave'
gem "fog-aws"
gem 'aws-sdk-s3'

# For generatting sitemaps
gem 'sitemap_generator'

# READ Excel
gem 'roo'

# For JOBs
gem 'sidekiq'
gem 'rest-client'

# For Javascript Updates
gem 'best_in_place', '~> 3.0.1'

# THIRD PARTY APPS
#
gem 'twilio-ruby', '~> 5.2.1'

group :development, :test do
  gem 'byebug', platform: :mri
end

group :development do
  gem 'mailcatcher'
end

无论命令如何,都会出现此消息:rails db:migrate, rails s, rails c, 等等...

编辑:

我也尝试了该命令gem pristine --all,但它没有改变任何东西,我仍然有这个错误。

标签: ruby-on-railsruby

解决方案


你的 Gemfile 应该是:

source "https://rubygems.org"
gem "singularitygs", "~>1.4"
gem "autoprefixer-rails", "~>5.1.0"

然后运行bundle install看看有没有帮助...


推荐阅读