instructure / canvas-lms

The open LMS by Instructure, Inc.
https://github.com/instructure/canvas-lms/wiki
GNU Affero General Public License v3.0
5.41k stars 2.42k forks source link

Issue using canvas:compile | Parallel::UndumpableException: FrozenError: can't modify frozen Array #2303

Open aidangibson opened 5 months ago

aidangibson commented 5 months ago

Summary:

Working through the installation guide for the simple install, and have reached an issue I can't for the life of me work out. I am trying to run Canvas LMS on Ubuntu Server 22.04.3 LTS.

When running bundle exec rails canvas:compile_assets orbundle exec rake canvas:compile_assets the compilation breaks with FrozenError.

FrozenError: The error FrozenError: can't modify frozen Array indicates that the code is trying to modify an array that has been frozen (made immutable) and cannot be changed.

This error occurs in the Rails engine setup (as indicated by the path /var/lib/gems/3.1.0/gems/railties-7.0.8/lib/rails/engine.rb).

Specific Location of the Error:

The error specifically occurs at engine.rb:575 in the rails gem. This line is involved in the process of initializing the Rails application.

It occurs at this point within canvas:compile_assets:

--> Finished: 'js:webpack_production' in 60.63s rake aborted! Parallel::UndumpableException: FrozenError: can't modify frozen Array: ["/home/user/canvas/app/middleware", "/home/user/canvas/lib/base"]

Steps to reproduce:

1) Follow the instructions at https://github.com/instructure/canvas-lms/wiki/Quick-Start

2) Run command bundle exec rails canvas:compile_assets

Expected behavior:

Successful compilation of canvas-lms

Actual behavior:

FrozenError

Additional notes:

Compile Canvas Output.md

psenicka0101 commented 4 months ago

Having the exact same problem... I've tried the prod and all the recent stable branches and master branch with no luck. Also had no luck with their docker script.

0711kps commented 4 months ago

I'm not sure if it's related, but I had the same issue before, and the error was solved(or maybe just disappear for some reason) after I delete .bundle/plugin folder and run bundle install again

Maclenn77 commented 4 months ago

I recently installed canvas in a self-hosted vm instance. bundle exec rake canvas:compile_assetswas a pain point.

Despite the problem doesn't seem the same, just running bundle exec rails js:webpack_production works for me.

If you google the error, all the issues are canvas related, so I guess that they are wrapping a memory error with that exception. It seems that js:webpack_production is a task with heavy memory requirements and that's why it fails often to compile.

virgo47 commented 3 months ago

I'm trying to put together a production Dockerfile, but I'm also verifying the steps in Ubuntu 22.04 VM. I got stuck on this as well, FrozenError, although in my case it's after css:compile so I guess it's sooner?

--> Finished: 'css:compile' in 17.58s
rake aborted!
Parallel::UndumpableException: FrozenError: can't modify frozen Array: ["/var/canvas/app/controllers", "/var/canvas/app/controllers/concerns", "/var/canvas/app/graphql", "/var/canvas/app/helpers", "/var/canvas/app/messages", "/var/canvas/app/models", "/var/canvas/app/observers", "/var/canvas/app/presenters", "/var/canvas/app/serializers", "/var/canvas/app/services", "/var/canvas/app/stylesheets", "/var/canvas/lib", "/var/canvas/gems/plugins/qti_exporter/lib", "/var/canvas/gems/plugins/moodle_importer/lib", "/var/canvas/gems/plugins/account_reports/lib", "/var/canvas/gems/plugins/academic_benchmark/lib", "/var/canvas/vendor/bundle/ruby/3.1.0/gems/sentry-rails-5.16.1/app/jobs", "/var/canvas/vendor/bundle/ruby/3.1.0/gems/canvas_webex-0.18.2/app/models", "/var/canvas/vendor/bundle/ruby/3.1.0/gems/canvas_webex-0.18.2/lib", "/var/canvas/vendor/bundle/ruby/3.1.0/gems/canvas_connect-0.3.16/app/models", "/var/canvas/vendor/bundle/ruby/3.1.0/gems/canvas_connect-0.3.16/lib", #<Pathname:/var/canvas/lib/stubs>]
/var/canvas/vendor/bundle/ruby/3.1.0/gems/railties-7.0.8/lib/rails/engine.rb:574:in `unshift'

No change after deleting .bundle/plugin and running bundle install.

I used https://github.com/instructure/canvas-lms/archive/prod.tar.gz, I'd rather go for a concrete pinned version, but I don't know how to do it and existing guides differ quite a lot on how and what to download, often leading to 404 anyway.

nogara commented 3 months ago

I had the same exact problem when using my own Dockerfile, and I gave up on it after a few tries.

I decided to give it another try today, and following Production Start almost to the letter on the master branch finally worked. I used a c5.2xlarge instance on AWS to get a lot of CPU and memory and eliminate this from the equation.

I'm going to try creating a Dockerfile again using the master branch to see if it works too.

virgo47 commented 3 months ago

Just to be sure, could that error indicate a lack of memory? I'm no Rails/Ruby expert, but just from the message itself, I assume it's the source code problem. EDIT: I'm using Ubuntu VM with 16GB of RAM, 8 vCPU and Docker on it. 16GB should be enough, or not?

aidangibson commented 3 months ago

What are the memory requirements? It's quite a strange one. I'm a novice with ruby. I haven't picked this project back up for the last few months.


From: virgo47 @.> Sent: Tuesday, 26 March 2024 8:00 pm To: instructure/canvas-lms @.> Cc: aidangibson @.>; Author @.> Subject: Re: [instructure/canvas-lms] Issue using canvas:compile | Parallel::UndumpableException: FrozenError: can't modify frozen Array (Issue #2303)

Just to be sure, could that error indicate a lack of memory? I'm no Rails/Ruby expert, but just from the message itself, I assume it's the source code problem.

— Reply to this email directly, view it on GitHubhttps://github.com/instructure/canvas-lms/issues/2303#issuecomment-2019525618, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ADCOZDG6ZMRTQVSIIGNACXLY2EFIHAVCNFSM6AAAAABCB7JNKCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMJZGUZDKNRRHA. You are receiving this because you authored the thread.Message ID: @.***>

virgo47 commented 3 months ago

EDIT: So my problem seems to be that I wanted to run this as Dockerfile step - but this step requires config/database.yml correctly configured and DB initalized. The error message is unbelievably cryptic, but the reason is simple and the step is shown AFTER DB initialization for good reason. In order to optimize Dockerfile steps, I reordered some, but this one must go after DB init. It probably can't be done during Docker image preparation (unless one prepares some temporary DB as well?) and I'll put these steps into some kind of "seeder job" in my Helm chart.

0711kps commented 3 months ago

I notice there's a line Managed item /home/science/canvas/node\_modules/plugin-bundles-generated.js isn't a directory or doesn't contain a package.json (see snapshot.managedPaths option) in your complete output log

is the file/folder exist? maybe you can try to make a backup for it, removing it and run the compile assets command again

aidangibson commented 3 months ago

I will have to give this a go over Easter, or in a few weeks time. There have been a few good pieces of input as of late to inspire me to give it another go.


From: Pero @.> Sent: Thursday, March 28, 2024 10:36:03 PM To: instructure/canvas-lms @.> Cc: aidangibson @.>; Author @.> Subject: Re: [instructure/canvas-lms] Issue using canvas:compile | Parallel::UndumpableException: FrozenError: can't modify frozen Array (Issue #2303)

I notice there's a line Managed item /home/science/canvas/node_modules/plugin-bundles-generated.js isn't a directory or doesn't contain a package.json (see snapshot.managedPaths option) in your complete output log

is the file/folder exist? maybe you can try to make a backup for it, removing it and run the compile assets command again

— Reply to this email directly, view it on GitHubhttps://github.com/instructure/canvas-lms/issues/2303#issuecomment-2024772053, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ADCOZDC4HN2ZHPO2TKJRVLLY2PQAHAVCNFSM6AAAAABCB7JNKCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMRUG43TEMBVGM. You are receiving this because you authored the thread.Message ID: @.***>

nogara commented 1 month ago

I'm still getting the same error, even after trying different versions of ruby and different branches... Did anyone have any luck fixing this?

aidangibson commented 1 week ago

Unfortunately I didn't, which is a bit of a shame. I'm not sure I'll get more time to investigate before December.


From: Luiz Gustavo Nogara @.> Sent: Wednesday, 22 May 2024 6:08 am To: instructure/canvas-lms @.> Cc: aidangibson @.>; Author @.> Subject: Re: [instructure/canvas-lms] Issue using canvas:compile | Parallel::UndumpableException: FrozenError: can't modify frozen Array (Issue #2303)

I'm still getting the same error, even after trying different versions of ruby and different branches... Did anyone have any luck fixing this?

— Reply to this email directly, view it on GitHubhttps://github.com/instructure/canvas-lms/issues/2303#issuecomment-2123169434, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ADCOZDDXLON5UHKWEM4CRYDZDOETTAVCNFSM6AAAAABCB7JNKCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMRTGE3DSNBTGQ. You are receiving this because you authored the thread.Message ID: @.***>

phil-davis commented 4 days ago

I was following the "quick" start for developers: https://github.com/instructure/canvas-lms/wiki/Quick-Start

And getting this FrozenError

Then I did later DB setup steps:

$ cp config/database.yml.example config/database.yml
$ createdb canvas_development
$ cp config/security.yml.example config/security.yml
$ bundle exec rails db:initial_setup

And then came back and did:

bundle exec rails canvas:compile_assets

Now it only gives me a warning (unrelated to this issue):

WARNING in ⚠ custom stage for process_assets is not supported yet, so Infinity is fallback to Compilation.PROCESS_ASSETS_STAGE_REPORT(5000)

The installation and set up process needs to be reviewed by "someone who knows what they are doing" (tm), and the order of steps etc. be adjusted.