添加 gem docx_converter 后出现问题 运行 'rails s'
Problem running 'rails s' after adding gem docx_converter
长话短说:
我应该使用 docx gem 而不是(较旧的)docx_converter。这似乎与 Rails 5.2.
更兼容
我正在学习 rails 并且有一个可用的应用程序。但是,当我将 gem docx_converter 添加到我的 Gemfile 时(这样我就可以将 Word 文件转换为 markdown 以进一步处理),服务器无法启动。
该应用程序具有三个模型:公司,has_many 用户,has_many 项目。 (用户由 Devise 控制,公司 has_many 通过用户进行项目。)当用户创建项目时,他们可以使用 active_storage 将文件上传到该项目,并将其存储在我的开发环境中的磁盘上(这是我在这里关心的)。
我对上述任何一项都没有问题 - 我可以创建用户和项目,以及从项目中添加和删除文件。
但是,如果我将 gem 'docx_converter'
添加到我的 Gemfile 和 运行 bundle update
,我将无法再 运行 rails 服务器。在此操作之前,一切都很好。紧接着,服务器不会 运行 并且回溯(最后几行)是:
10: from /Users/john/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require'
9: from /Users/john/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/docx_converter-1.0.0/lib/docx_converter.rb:18:in `<main>'
8: from /Users/john/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `require'
7: from /Users/john/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:257:in `load_dependency'
6: from /Users/john/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `block in require'
5: from /Users/john/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:26:in `require'
4: from /Users/john/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:40:in `rescue in require'
3: from /Users/john/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require_with_bootsnap_lfi'
2: from /Users/john/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/loaded_features_index.rb:89:in `register'
1: from /Users/john/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `block in require_with_bootsnap_lfi'
/Users/john/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require': cannot load such file -- publishr (LoadError)
鉴于对 bootsnap 的引用,我尝试将其从 Gemfile 和 config/boot.rb 中删除,但这导致在不同的地方出现相同的错误但大致相同(发布者):
10: from /Users/john/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/bundler-2.0.1/lib/bundler/runtime.rb:65:in `require'
9: from /Users/john/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/bundler-2.0.1/lib/bundler/runtime.rb:65:in `each'
8: from /Users/john/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/bundler-2.0.1/lib/bundler/runtime.rb:76:in `block in require'
7: from /Users/john/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/bundler-2.0.1/lib/bundler/runtime.rb:76:in `each'
6: from /Users/john/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/bundler-2.0.1/lib/bundler/runtime.rb:81:in `block (2 levels) in require'
5: from /Users/john/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/bundler-2.0.1/lib/bundler/runtime.rb:81:in `require'
4: from /Users/john/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/docx_converter-1.0.0/lib/docx_converter.rb:18:in `<top (required)>'
3: from /Users/john/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `require'
2: from /Users/john/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:257:in `load_dependency'
1: from /Users/john/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `block in require'
/Users/john/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `require': cannot load such file -- publishr (LoadError)
我试过通过 "gem install publishr" 安装 publishr,但没用。
我的 Gemfile 是:
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby '2.6.2'
gem 'rails', '~> 5.2.3'
gem 'puma', '~> 3.11'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.2'
gem 'turbolinks', '~> 5'
gem 'jbuilder', '~> 2.5'
gem 'bcrypt', '~> 3.1.7'
gem 'bootsnap', '>= 1.1.0', require: false
# Manually added gems
gem 'will_paginate', '~> 3.1.6'
gem 'devise', '~> 4.6.2'
gem 'cancancan', '~>3.0.1'
gem 'docx_converter', '~>1.0.0'
group :development, :test do
gem 'sqlite3'
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
gem 'faker', '~> 1.7.3'
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
这个 gem 和 Rails 5.2.3 似乎有问题,但是有人知道这里发生了什么以及我如何让它工作吗? (或者,另一个 gem 用于将 Word docx 文件转换为可用的文件)
bootsnap
可能在所有这一切中发挥作用,因为它会干扰 Rails 的启动。尝试确保清理所有 spring 个进程 ps -ef | grep spring
。删除 bootsnap
gem 和 bundle install
。然后尝试再次启动服务器 rails s
.
经过一定程度的潜入兔子洞后,我发现我需要明确要求两个额外的 gems 才能使 docx_converter 工作,并且还必须锁定其中一个的版本他们。
gem 'publishr'
gem 'rubyzip', '~>0.9.9'
gem 'docx_converter', '~>1.0.0'
我没有详尽地测试功能,但至少服务器现在启动了!谢谢大家的建议!
编辑
即使在获得服务器 运行 之后,我也遇到了这个 gem 的问题 - 正如@engineersmnky 所说,它已经很旧并且没有记录。所以我换到了 docx gem,它并没有尝试做那么多,但似乎 (a) 在 Rails 5.2 上加载没有问题,并且 (b) 可以工作!
长话短说:
我应该使用 docx gem 而不是(较旧的)docx_converter。这似乎与 Rails 5.2.
更兼容我正在学习 rails 并且有一个可用的应用程序。但是,当我将 gem docx_converter 添加到我的 Gemfile 时(这样我就可以将 Word 文件转换为 markdown 以进一步处理),服务器无法启动。
该应用程序具有三个模型:公司,has_many 用户,has_many 项目。 (用户由 Devise 控制,公司 has_many 通过用户进行项目。)当用户创建项目时,他们可以使用 active_storage 将文件上传到该项目,并将其存储在我的开发环境中的磁盘上(这是我在这里关心的)。
我对上述任何一项都没有问题 - 我可以创建用户和项目,以及从项目中添加和删除文件。
但是,如果我将 gem 'docx_converter'
添加到我的 Gemfile 和 运行 bundle update
,我将无法再 运行 rails 服务器。在此操作之前,一切都很好。紧接着,服务器不会 运行 并且回溯(最后几行)是:
10: from /Users/john/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require'
9: from /Users/john/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/docx_converter-1.0.0/lib/docx_converter.rb:18:in `<main>'
8: from /Users/john/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `require'
7: from /Users/john/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:257:in `load_dependency'
6: from /Users/john/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `block in require'
5: from /Users/john/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:26:in `require'
4: from /Users/john/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:40:in `rescue in require'
3: from /Users/john/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require_with_bootsnap_lfi'
2: from /Users/john/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/loaded_features_index.rb:89:in `register'
1: from /Users/john/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `block in require_with_bootsnap_lfi'
/Users/john/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require': cannot load such file -- publishr (LoadError)
鉴于对 bootsnap 的引用,我尝试将其从 Gemfile 和 config/boot.rb 中删除,但这导致在不同的地方出现相同的错误但大致相同(发布者):
10: from /Users/john/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/bundler-2.0.1/lib/bundler/runtime.rb:65:in `require'
9: from /Users/john/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/bundler-2.0.1/lib/bundler/runtime.rb:65:in `each'
8: from /Users/john/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/bundler-2.0.1/lib/bundler/runtime.rb:76:in `block in require'
7: from /Users/john/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/bundler-2.0.1/lib/bundler/runtime.rb:76:in `each'
6: from /Users/john/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/bundler-2.0.1/lib/bundler/runtime.rb:81:in `block (2 levels) in require'
5: from /Users/john/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/bundler-2.0.1/lib/bundler/runtime.rb:81:in `require'
4: from /Users/john/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/docx_converter-1.0.0/lib/docx_converter.rb:18:in `<top (required)>'
3: from /Users/john/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `require'
2: from /Users/john/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:257:in `load_dependency'
1: from /Users/john/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `block in require'
/Users/john/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `require': cannot load such file -- publishr (LoadError)
我试过通过 "gem install publishr" 安装 publishr,但没用。
我的 Gemfile 是:
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby '2.6.2'
gem 'rails', '~> 5.2.3'
gem 'puma', '~> 3.11'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.2'
gem 'turbolinks', '~> 5'
gem 'jbuilder', '~> 2.5'
gem 'bcrypt', '~> 3.1.7'
gem 'bootsnap', '>= 1.1.0', require: false
# Manually added gems
gem 'will_paginate', '~> 3.1.6'
gem 'devise', '~> 4.6.2'
gem 'cancancan', '~>3.0.1'
gem 'docx_converter', '~>1.0.0'
group :development, :test do
gem 'sqlite3'
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
gem 'faker', '~> 1.7.3'
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
这个 gem 和 Rails 5.2.3 似乎有问题,但是有人知道这里发生了什么以及我如何让它工作吗? (或者,另一个 gem 用于将 Word docx 文件转换为可用的文件)
bootsnap
可能在所有这一切中发挥作用,因为它会干扰 Rails 的启动。尝试确保清理所有 spring 个进程 ps -ef | grep spring
。删除 bootsnap
gem 和 bundle install
。然后尝试再次启动服务器 rails s
.
经过一定程度的潜入兔子洞后,我发现我需要明确要求两个额外的 gems 才能使 docx_converter 工作,并且还必须锁定其中一个的版本他们。
gem 'publishr'
gem 'rubyzip', '~>0.9.9'
gem 'docx_converter', '~>1.0.0'
我没有详尽地测试功能,但至少服务器现在启动了!谢谢大家的建议!
编辑
即使在获得服务器 运行 之后,我也遇到了这个 gem 的问题 - 正如@engineersmnky 所说,它已经很旧并且没有记录。所以我换到了 docx gem,它并没有尝试做那么多,但似乎 (a) 在 Rails 5.2 上加载没有问题,并且 (b) 可以工作!