Forest_liana - Upgrade - Empty collections

Hey there!! I am having some trouble upgrading our forest_liana gem version from 4.0.0 to 6.3.5.

Expected behavior

I have followed the upgrade guides in order to do so:

  • forest_application_url set in secrets.yml and used in forest_liana initialiser
  • CORS adapted
  • Static client_id set in secrets.yml and used in forest_liana initialiser

I can successfully connect to forestadmin UI and I would expect to see my data collection.

Actual behavior

I am having an error indicating I have no collections to show.

When digging further into the problem I can observe that the .forestadmin-schema.json has been updated when performing the forest_liana upgrade. The list of collections now seems to be empty.

I stumbled across another topic mentioning the rake forest:send_apimap command. With this command I successfully manage to regenerate my .forestadmin-schema.json containing my collections but once I startup my server, this file is re-modified to contain an empty set of collections…

This seems to be the root of the problem but I cannot figure out why starting up my server generates a different schema file than using the above stated rake task.

Note: Our rails version is


Hello @Alexis_Philippart_de ! :wave: Welcome to our community :tada: :confetti_ball:

At first glance, as you jump from a version 4.X to 6.X, I’m not able to spot the problem.

We will try to dig into your problem. I’m seeing a Copy your layout configuration. Can you try to follow this link ?

Informations & Upgrade notes

Just for information, the static clientId is only required if you’re running multiple instances of your agent (with a load balancer for exemple) or if you don’t want to enable caching on your environment.
As a side note you can enable caching with rails dev:cache on your development environment.

Hey there.

Following this link just brings me to my list of environments but nothing more I can do! The problem seems to be on forest_liana’s side (removing all collections from the schema file) and not on the UI.

The issue only seems to occur when the schema is automatically generated when starting up a rails server. Indeed when I run:

  • in my rails console :point_right: A correct schema is being generated
  • The moment I spin up a server with rails s :point_right: My schema is being overridden to contain an empty set of collections

As for the clientId, I am aware I can enable caching but wanted to keep changes to my rails config minimal.


Hello @Alexis_Philippart_de,

It looks like a problem in the order initializers are run. Your problem can occur when the connection to the DB is not correctly initialized when the liana is generating its schema.

Do you have this problem when you upgrade to the v5? We would like to isolate the origin of your issue.

Hey @GuillaumeGautreau ,

If downgraded gradually up to the point where the issue is not occurring. It appears the last version that worked well for us was 4.0.2 once upgrading to 4.1.0 the issue is appearing. However, when I add a collection to the lib/forest_liana/collections directory AND manually specify fields, then those fields are included correctly in the forest admin schema file.

What I also saw from your changelog is that the 4.1.0 upgrade added support for rails 6 applications. Rails 6 introduced Zeitwerk as new code loader engine vs. classic for Rails <6. However, to reduce the upgrade complexity, we’ve decided to keep the classic code loader engine. Maybe, this could be linked to our issue? When the the auto generation of the schema file is started with rails s, the models may not have been loaded yet ? That would explain why running generates the file alright? Is forest_liana maybe somehow supposing that all rails 6 are using zeitwerk as their code loader engine?

Thanks for your help,

Thanks a lot for your investigations.

Do you think that something is wrong with the initial implementation that added the support of the new version of Rails: [+] Rails Versions - Support Rails 6 projects by arnaudbesnier · Pull Request #330 · ForestAdmin/forest-rails · GitHub

      if Rails::VERSION::MAJOR > 5 && defined?(Zeitwerk::Loader)

In your case, can you find a more restrictive condition that would work in your case?

Hey @GuillaumeGautreau, I my opinion, the implementation should be something like:

      if Rails.autoloaders.zeitwerk_enabled?

Rails has a specific method dedicated to check if zeitwerk is enabled on the rails project or not see here.

As per Rails upgrading guide, people with Rails 6 can choose to opt out of autoloading with zeitwerk by adding

config.autoloader = :classic

to their application.rb file. See here.

Let me know if you need any further info regarding the issue…


Are you confident enough to create a pull request with this change on the repository? I think it’ll be faster for you to have a new version with the fix.

Will have a look at your repo in order to do so. Thx

Hey @GuillaumeGautreau PR open here

1 Like

Thanks a lot, we’ll take a look at it very soon. I asked @arnaud to review your PR.

Hi again @Alexis_Philippart_de,

You released a new version of forest-liana! Congrats! :partying_face: Thanks a lot for the help on this!

You can install this version 6.3.7 and it should fix your issue :slightly_smiling_face:

1 Like

Hi @GuillaumeGautreau did the trick, thx!!