安装gem“设计”时如何修复错误?

Posted

技术标签:

【中文标题】安装gem“设计”时如何修复错误?【英文标题】:How to fix errors when install gem "devise"? 【发布时间】:2019-09-05 07:19:56 【问题描述】:

我在 Rails 应用程序中添加 gem “devise”,然后运行“bundle install”,它显示如下错误::

/home/hoanglien/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bootstrap-sass-3.3.7/lib/bootstrap-sass/version.rb:2: 警告:已初始化常量 Bootstrap::VERSION /home/hoanglien/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bootstrap-4.3.1/lib/bootstrap/version.rb:4: 警告:以前的 VERSION 定义在这里 /home/hoanglien/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bootstrap-sass-3.3.7/lib/bootstrap-sass/version.rb:3: 警告:已初始化常量 Bootstrap::BOOTSTRAP_SHA /home/hoanglien/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bootstrap-4.3.1/lib/bootstrap/version.rb:5: 警告:BOOTSTRAP_SHA 的先前定义在这里 /home/hoanglien/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/activesupport-5.2.3/lib/active_support/message_encryptor.rb:206:in _decrypt 中的救援:ActiveSupport::MessageEncryptor::InvalidMessage (ActiveSupport::MessageEncryptor::InvalidMessage) 来自 /home/hoanglien/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/activesupport-5.2.3/lib/active_support/message_encryptor.rb:183:in 来自的`_decrypt' /home/hoanglien/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/activesupport-5.2.3/lib/active_support/message_encryptor.rb:157:in 'decrypt_and_verify' 来自 /home/hoanglien/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/activesupport-5.2.3/lib/active_support/messages/rotator.rb:21:in 'decrypt_and_verify' 来自 /home/hoanglien/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/activesupport-5.2.3/lib/active_support/encrypted_file.rb:79:in 从解密 /home/hoanglien/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/activesupport-5.2.3/lib/active_support/encrypted_file.rb:42:in '读取'来自 /home/hoanglien/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/activesupport-5.2.3/lib/active_support/encrypted_configuration.rb:21:in 读自 /home/hoanglien/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/activesupport-5.2.3/lib/active_support/encrypted_configuration.rb:33:in 来自的“配置” /home/hoanglien/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/activesupport-5.2.3/lib/active_support/encrypted_configuration.rb:38:in 来自的“选项” /home/hoanglien/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/activesupport-5.2.3/lib/active_support/core_ext/module/delegation.rb:271:in 来自的'method_missing' /home/hoanglien/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/devise-4.6.2/lib/devise/secret_key_finder.rb:24:in “key_exists?”来自 /home/hoanglien/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/devise-4.6.2/lib/devise/secret_key_finder.rb:10:in '查找'来自 /home/hoanglien/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/devise-4.6.2/lib/devise/rails.rb:37:in '阻止'来自 /home/hoanglien/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/railties-5.2.3/lib/rails/initializable.rb:32:in 'instance_exec' 来自 /home/hoanglien/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/railties-5.2.3/lib/rails/initializable.rb:32:in '运行'来自 /home/hoanglien/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/railties-5.2.3/lib/rails/initializable.rb:61:in 'block in run_initializers' 来自 /home/hoanglien/.rbenv/versions/2.5.1/lib/ruby/2.5.0/tsort.rb:228:in 'block in tsort_each' 来自 /home/hoanglien/.rbenv/versions/2.5.1/lib/ruby/2.5.0/tsort.rb:350:in 每个_strongly_connected_component'中的块(2个级别)来自 /home/hoanglien/.rbenv/versions/2.5.1/lib/ruby/2.5.0/tsort.rb:431:in each_strongly_connected_component_from' 来自 /home/hoanglien/.rbenv/versions/2.5.1/lib/ruby/2.5.0/tsort.rb:349:in 阻止来自的 each_strongly_connected_component' /home/hoanglien/.rbenv/versions/2.5.1/lib/ruby/2.5.0/tsort.rb:347:in 每个'来自 /home/hoanglien/.rbenv/versions/2.5.1/lib/ruby/2.5.0/tsort.rb:347:in 来自 /home/hoanglien/.rbenv/versions/2.5.1/lib/ruby/2.5.0/tsort.rb:347:in 每个_strongly_connected_component'来自 /home/hoanglien/.rbenv/versions/2.5.1/lib/ruby/2.5.0/tsort.rb:226:in tsort_each' 来自 /home/hoanglien/.rbenv/versions/2.5.1/lib/ruby/2.5.0/tsort.rb:205:in tsort_each' 来自 /home/hoanglien/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/railties-5.2.3/lib/rails/initializable.rb:60:in run_initializers' 来自 /home/hoanglien/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/railties-5.2.3/lib/rails/application.rb:361:in 初始化!'来自 /home/hoanglien/Rails/dating-app/config/environment.rb:5:in ' 来自 /home/hoanglien/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bootsnap-1.4.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in 需要'来自 /home/hoanglien/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bootsnap-1.4.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in 阻止来自的require_with_bootsnap_lfi' /home/hoanglien/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bootsnap-1.4.3/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in 从注册 /home/hoanglien/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bootsnap-1.4.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in 来自的require_with_bootsnap_lfi' /home/hoanglien/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bootsnap-1.4.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in 需要'来自 /home/hoanglien/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in block in 来自 /home/hoanglien/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:257:in load_dependency'来自 /home/hoanglien/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in 来自 /home/hoanglien/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/spring-2.0.2/lib/spring/application.rb:102:in 来自的预加载 /home/hoanglien/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/spring-2.0.2/lib/spring/application.rb:153:in 来自 /home/hoanglien/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/spring-2.0.2/lib/spring/application.rb:141:in 阻止运行'来自 /home/hoanglien/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/spring-2.0.2/lib/spring/application.rb:135:in 循环'来自 /home/hoanglien/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/spring-2.0.2/lib/spring/application.rb:135:in 从运行 /home/hoanglien/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/spring-2.0.2/lib/spring/application/boot.rb:19:in '来自 /home/hoanglien/.rbenv/versions/2.5.1/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in 需要'来自 /home/hoanglien/.rbenv/versions/2.5.1/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in 需要'来自 -e:1:in ' **

在我的 gemfile 中:

    "https://rubygems.org" git_source(:github)  |repo|  "https://github.com/#repo.git" 
ruby "2.5.1"
    gem "rails", "~>5.2.3"
    gem "puma", "~> 3.11"
    gem "mysql2", ">= 0.4.4", "< 0.6.0"
    gem "sass-rails", "~> 5.0"
    gem "uglifier", ">= 1.3.0"
    gem "turbolinks",    "~> 5"
    gem "jbuilder", "~> 2.5"
    gem "bootstrap", "~> 4.0"
    gem "bootstrap-sass", "3.3.7"
    gem "jquery-rails", "~> 4.3", ">= 4.3.1"
    gem "bootsnap", ">= 1.1.0", require: false
    gem "i18n"
    gem "i18n-js"
    gem "config"
    gem "devise"
   group :development, :test do
     gem "byebug",    platforms: [:mri, :mingw, :x64_mingw]
   end
   group :development do
     gem "web-console", ">= 3.3.0"
     gem "listen", ">= 3.0.5", "< 3.2"
     gem "spring"
     gem "spring-watcher-listen", "~> 2.0.0"
   end
   group :test do
     gem "capybara", ">= 2.15"
     gem "selenium-webdriver"
     gem "chromedriver-helper"
     gem "tzinfo-data", platforms: [:mingw,    :mswin, :x64_mingw, :jruby]
   end

【问题讨论】:

尝试更新您的bundler 版本gem update bundler 并尝试捆绑。 尝试运行spring stop,然后运行bundle install 抱歉,当我运行“rails generate devise:install”时,它会显示类似 up 的错误 【参考方案1】:

您的 RubyGems 是否已加载到您的 PATH 中?尝试运行

bundle exec rails g devise:install

【讨论】:

谢谢,搞定了。但是当我生成一个控制器时,它会显示相同的错误,请帮助我。

以上是关于安装gem“设计”时如何修复错误?的主要内容,如果未能解决你的问题,请参考以下文章

在gem依赖中处理错误修复的最佳方法是什么?

如何修复 charlock_holmes gem 使其适用于 opensuse Tumbleweed?

使用终端安装 Parcel Bundler 时如何修复权限错误

安装 VueJS CLI 时如何修复 npm WARN deprecated 错误

安装 mod_wsgi 时如何修复错误消息?

如何修复错误“错误:命令错误退出状态 1:python。”尝试使用 pip 安装 fitz 模块时?