我已经设置好了一切,并尝试导入 flarum_import.rb。但它显示 thimira@THIMIRA:~/discourse/script/import_scripts$ bundle exec ruby flarum_import.rb
Traceback (most recent call last):
1: from flarum_import.rb:3:in <main>'
我该怎么做?请帮忙。
我已经设置好了一切,并尝试导入 flarum_import.rb。但它显示 thimira@THIMIRA:~/discourse/script/import_scripts$ bundle exec ruby flarum_import.rb
Traceback (most recent call last):
1: from flarum_import.rb:3:in <main>'
我该怎么做?请帮忙。
您需要包含更多的输出才能让人猜测,但(证明我在这方面是错的),第三行是
require "mysql2"
所以看起来您需要将它添加到 Gemfile 并运行 bundle install。
怎么做?我的意思是,如何将其添加到 Gemfile 中?
请检查私信。我已留言。
Nowadays, it’s not necessary to manually add these gems to the Gemfile, as they are already included. You only need to enable them by using IMPORT=1 before your command.
So, just do:
IMPORT=1 bundle install
IMPORT=1 bundle exec ruby flarum_import.rb
If bundle install gives you an error, you might also need to run bundle config unset deployment.
我的经验是,如果你执行 IMPORT=1,但尚未安装所有额外导入所需的所有依赖项,你将遇到大量失败,其中一些依赖项很难弄清楚。
嗯,这并非我的经验——而且我无法理解为什么这样做会影响依赖关系?
@thimiraonline,你成功了吗?
像这样的东西:
安装 tiny_tds (2.1.5) 时出错,Bundler 无法继续。
然后,如果你安装 tiny_tds(这并非易事),你就会得到
安装 sqlite3 (1.4.2) 时出错,Bundler 无法继续。
但我认为,如果你包含
- "templates/import/mysql-dep.template.yml"
- "templates/import/mbox.template.yml"
- "templates/import/mssql-dep.template.yml"
然后它可能会起作用。我接下来会尝试这个;我曾一度自己制作模板来安装这些依赖项,但希望我发现我从未需要过。
我试了一下,但他的设置有一个数据库表前缀,而脚本没有设置前缀的选项。我已经让他重命名表,我将再次尝试。
. . . 但导入模板会将 Gem 添加到 Gemfile 中,因此如果您尝试使用 ``IMPORT=1`,您将得到
[!] 解析 `Gemfile` 时出错:您不能为同一个 gem 指定不同的版本要求。
您指定了:sqlite3 (~> 1.3, >= 1.3.13) 和 sqlite3 (>= 0)。Bundler 无法继续。
# 来自 /var/www/discourse/Gemfile:272
# -------------------------------------------
# gem 'mysql2'
> gem 'sqlite3'
# gem 'tiny_tds'
# -------------------------------------------
因为 Gemfile 指定了一个版本而模板没有。
因此,经过一番努力,我找不到让 IMPORT=1 有用的方法。我猜它可以在开发实例上工作,您已经在操作系统中安装了所有这些依赖项,或者您手动创建了一种在容器中安装依赖项的方法。
哦,但是 mbox 导入所做的不仅仅是安装 sqlite3,所以除非您真的想导入 mbox,否则这不是一件好事。
也许我会提交一个 PR 来创建一个 sqlite3 导入模板。
运行脚本时出现此错误,其中 IMPORT=1
1: from /home/user/.rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/zeitwerk-2.5.4/lib/zeitwerk/kernel.rb:28:in `require' /home/user/.rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/zeitwerk-2.5.4/lib/zeitw erk/loader/callbacks.rb:25:in `on_file_autoloaded': expected file /home/user/disco urse/lib/freedom_patches/ip_addr.rb to define constant FreedomPatches::IPAddr, but didn't (Zeitwerk:: NameError)