ruby-on-rails 尝试在GitHub Codespace中运行forked canvas-lms时出错:TypeError:Post不是类

yhived7q  于 2023-03-31  发布在  Ruby
关注(0)|答案(1)|浏览(94)

我正在尝试通过GitHub代码空间运行instructure的canvas-lms,遇到了以下问题。我使用的是免费的4核心计划。代码空间设置的存储库和说明可以在here中找到。有人在尝试在GitHub代码空间中运行他们的forked canvas-lms时使用bundle exec rails canvas:compile_assets后遇到过这个问题吗?我应该能够在这样做之后运行bundle exec rails db:initial_setup以接收身份验证提示。

我运行以下命令:

sudo apt-get update
sudo apt-get -y install postgresql-12 zlib1g-dev libldap2-dev libidn11-dev libxml2-dev libsqlite3-dev libpq-dev libxmlsec1-dev curl build-essential

rvm install "ruby-2.7.0"
rvm use 2.7.0
gem install bundle
gem install bundler:2.3.26
gem install nokogumbo scrypt sanitize ruby-debug-ide
sudo chown -R codespace:codespace /workspaces/canvas-lms/
sudo chown -R codespace:codespace /usr/local/rvm/rubies/ruby-2.7.0/lib/ruby/gems/2.7.0
bundle _2.3.26_ install
yarn install --pure-lockfile
for config in amazon_s3 delayed_jobs domain file_store outgoing_mail security external_migration dynamic_settings database; \
do cp -v config/$config.yml.example config/$config.yml; done
bundle _2.3.26_ update
sudo chown -R codespace:codespace /var/run/postgresql/
export PGHOST=localhost
/usr/lib/postgresql/12/bin/initdb \~/postgresql-data/ -E utf8
/usr/lib/postgresql/12/bin/pg_ctl -D \~/postgresql-data/ -l \~/postgresql-data/server.log start
/usr/lib/postgresql/12/bin/createdb canvas_development
bundle exec rails canvas:compile_assets

**此时抛出以下错误:

Top level ::CompositeIO is deprecated, require 'multipart/post' and use `Multipart::Post::CompositeReadIO` instead!
Top level ::Parts is deprecated, require 'multipart/post' and use `Multipart::Post::Parts` instead!
/usr/local/rvm/gems/ruby-2.7.0/gems/faraday-0.17.4/lib/faraday/upload_io.rb:65: warning: constant ::UploadIO is deprecated
/usr/local/rvm/gems/ruby-2.7.0/gems/faraday-0.17.4/lib/faraday/upload_io.rb:66: warning: constant ::Parts is deprecated
rails aborted!
TypeError: Post is not a class

运行bundle exec rails canvas:compile_assets -trace时,如下所示:

Top level ::CompositeIO is deprecated, require 'multipart/post' and use `Multipart::Post::CompositeReadIO` instead!
Top level ::Parts is deprecated, require 'multipart/post' and use `Multipart::Post::Parts` instead!
/usr/local/rvm/gems/ruby-2.7.0/gems/faraday-0.17.4/lib/faraday/upload_io.rb:65: warning: constant ::UploadIO is deprecated
/usr/local/rvm/gems/ruby-2.7.0/gems/faraday-0.17.4/lib/faraday/upload_io.rb:66: warning: constant ::Parts is deprecated
rails aborted!
TypeError: Post is not a class
/usr/local/rvm/gems/ruby-2.7.0/gems/multipart-post-2.3.0/lib/multipart/post/parts.rb:25: previous definition of Post was here
/workspaces/canvas-lms/gems/multipart/lib/multipart/post.rb:23:in `<module:Multipart>' /workspaces/canvas-lms/gems/multipart/lib/multipart/post.rb:22:in `\<main\>'
/usr/local/rvm/gems/ruby-2.7.0/gems/bootsnap-1.13.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require' /usr/local/rvm/gems/ruby-2.7.0/gems/bootsnap-1.13.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
/usr/local/rvm/gems/ruby-2.7.0/gems/zeitwerk-2.6.7/lib/zeitwerk/kernel.rb:38:in `require' /workspaces/canvas-lms/gems/multipart/lib/multipart.rb:40:in `\<module:Multipart\>'
/workspaces/canvas-lms/gems/multipart/lib/multipart.rb:35:in `<main>' /usr/local/rvm/gems/ruby-2.7.0/gems/bootsnap-1.13.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
/usr/local/rvm/gems/ruby-2.7.0/gems/bootsnap-1.13.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require' /usr/local/rvm/gems/ruby-2.7.0/gems/zeitwerk-2.6.7/lib/zeitwerk/kernel.rb:38:in `require'
/workspaces/canvas-lms/gems/canvas_kaltura/lib/canvas_kaltura/kaltura_client_v3.rb:26:in `<main>' /usr/local/rvm/gems/ruby-2.7.0/gems/bootsnap-1.13.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
/usr/local/rvm/gems/ruby-2.7.0/gems/bootsnap-1.13.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require' /usr/local/rvm/gems/ruby-2.7.0/gems/zeitwerk-2.6.7/lib/zeitwerk/kernel.rb:38:in `require'
/workspaces/canvas-lms/gems/canvas_kaltura/lib/canvas_kaltura.rb:24:in `<module:CanvasKaltura>' /workspaces/canvas-lms/gems/canvas_kaltura/lib/canvas_kaltura.rb:23:in `\<main\>'
/usr/local/rvm/gems/ruby-2.7.0/gems/bootsnap-1.13.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require' /usr/local/rvm/gems/ruby-2.7.0/gems/bootsnap-1.13.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
/usr/local/rvm/gems/ruby-2.7.0/gems/zeitwerk-2.6.7/lib/zeitwerk/kernel.rb:38:in `require' /usr/local/rvm/gems/ruby-2.7.0/gems/bundler-2.3.26/lib/bundler/runtime.rb:60:in `block (2 levels) in require'
/usr/local/rvm/gems/ruby-2.7.0/gems/bundler-2.3.26/lib/bundler/runtime.rb:55:in `each' /usr/local/rvm/gems/ruby-2.7.0/gems/bundler-2.3.26/lib/bundler/runtime.rb:55:in `block in require'
/usr/local/rvm/gems/ruby-2.7.0/gems/bundler-2.3.26/lib/bundler/runtime.rb:44:in `each' /usr/local/rvm/gems/ruby-2.7.0/gems/bundler-2.3.26/lib/bundler/runtime.rb:44:in `require'
/usr/local/rvm/gems/ruby-2.7.0/gems/bundler-2.3.26/lib/bundler.rb:186:in `require' /workspaces/canvas-lms/config/application.rb:28:in `\<main\>'
/usr/local/rvm/gems/ruby-2.7.0/gems/bootsnap-1.13.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require' /usr/local/rvm/gems/ruby-2.7.0/gems/bootsnap-1.13.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
/workspaces/canvas-lms/Rakefile:6:in `<main>' /usr/local/rvm/gems/ruby-2.7.0/gems/rake-13.0.3/lib/rake/rake_module.rb:29:in `load'
/usr/local/rvm/gems/ruby-2.7.0/gems/rake-13.0.3/lib/rake/rake_module.rb:29:in `load_rakefile' /usr/local/rvm/gems/ruby-2.7.0/gems/rake-13.0.3/lib/rake/application.rb:703:in `raw_load_rakefile'
/usr/local/rvm/gems/ruby-2.7.0/gems/rake-13.0.3/lib/rake/application.rb:104:in `block in load_rakefile' /usr/local/rvm/gems/ruby-2.7.0/gems/rake-13.0.3/lib/rake/application.rb:186:in `standard_exception_handling'
/usr/local/rvm/gems/ruby-2.7.0/gems/rake-13.0.3/lib/rake/application.rb:103:in `load_rakefile' /usr/local/rvm/gems/ruby-2.7.0/gems/railties-7.0.3/lib/rails/commands/rake/rake_command.rb:20:in `block in perform'
/usr/local/rvm/gems/ruby-2.7.0/gems/rake-13.0.3/lib/rake/rake_module.rb:59:in `with_application' /usr/local/rvm/gems/ruby-2.7.0/gems/railties-7.0.3/lib/rails/commands/rake/rake_command.rb:18:in `perform'
/usr/local/rvm/gems/ruby-2.7.0/gems/railties-7.0.3/lib/rails/command.rb:51:in `invoke' /usr/local/rvm/gems/ruby-2.7.0/gems/railties-7.0.3/lib/rails/commands.rb:18:in `\<main\>'
/usr/local/rvm/gems/ruby-2.7.0/gems/bootsnap-1.13.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require' /usr/local/rvm/gems/ruby-2.7.0/gems/bootsnap-1.13.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
/workspaces/canvas-lms/bin/rails:16:in `<top (required)>' /usr/local/rvm/gems/ruby-2.7.0/gems/spring-4.0.0/lib/spring/client/rails.rb:30:in `load'
/usr/local/rvm/gems/ruby-2.7.0/gems/spring-4.0.0/lib/spring/client/rails.rb:30:in `call' /usr/local/rvm/gems/ruby-2.7.0/gems/spring-4.0.0/lib/spring/client/command.rb:7:in `call'
/usr/local/rvm/gems/ruby-2.7.0/gems/spring-4.0.0/lib/spring/client.rb:30:in `run' /usr/local/rvm/gems/ruby-2.7.0/gems/spring-4.0.0/bin/spring:49:in `\<top (required)\>'
/usr/local/rvm/gems/ruby-2.7.0/gems/spring-4.0.0/lib/spring/binstub.rb:11:in `load' /usr/local/rvm/gems/ruby-2.7.0/gems/spring-4.0.0/lib/spring/binstub.rb:11:in `\<top (required)\>'
/workspaces/canvas-lms/bin/spring:21:in `require' /workspaces/canvas-lms/bin/spring:21:in `\<top (required)\>'
bin/rails:5:in `load' bin/rails:5:in `\<main\>'
hgtggwj0

hgtggwj01#

我找到了一个解决方案。请不要把这个当作好的建议-这只是我在Github代码空间中运行开发Canvas环境时的一个工作。我还没有遇到过一些未来错误的可能性很大,但这已经足够让我在开发项目中使用Canvas代码空间了。
我看到 Post is not a class 错误。当然是,但我在网上搜索了类似的错误,并看到关于重复类名的讨论是一个潜在的问题。因此,我改变了一些事情。

  • /workspaces/canvas-lms/gems/multipart/lib/multipart.rb
  • 将需要'post.rb'的行更改为'posts.rb'
  • /workspaces/canvas-lms/gems/multipart/lib/multipart/post.rb
  • 将此文件名更改为'posts.rb'
  • /workspaces/canvas-lms/gems/multipart/lib/multipart/posts.rb
  • 将类名从Post更改为Posts

我能够再次运行canvas:compile_assets命令,并且没有得到相同的错误。然而,在大部分编译工作似乎正常后,我得到了一个新的错误。错误:
--〉完成:'js:webpack_development' in 100.79s rails aborted!Parallel::UndumpableException:活动记录::语句无效:PG::未定义表格:错误:关联“public.brand_configs”不存在行1:DELETE FROM“public”.“brand_configs”WHERE(NOT EXISTS(SELE... ^ /workspaces/canvas-lms/config/initializers/active_record.rb:1430:in delete_all' /workspaces/canvas-lms/config/initializers/active_record.rb:1462:in delete_all' /workspaces/canvas-lms/app/models/brand_config.rb:266:in `clean_unused_from_db!'
我再次搜索类似的错误,发现这个讨论:https://github.com/instructure/canvas-lms/issues/2023
讨论给了我一个测试的命令:
COMPILE_ASSETS_BRAND_CONFIGs=0 RAILS_ENV=production bundle exec rake canvas:compile_assets
这个命令显然是“production”,但它让我顺利地通过了compile_assets。我能够使用凭证初始化DB,在代码空间中启动Canvas,并且迄今为止能够将其用于我正在进行的开发。

相关问题