Skip to content

Classes imported from shards throw a "undefined constant" error #194

@wJoenn

Description

@wJoenn

Describe the bug
I have a small api that uses the jennifer ORM

The shard is required from it's initializer file

# config/initializers/database.cr
require "colorize"
require "jennifer"
require "jennifer/adapter/postgres"

Which itself is imported by the config file

# config/config.cr
require "./initializers/**"
require "../src/models/*"

But in my Task model I get an error saying the Jennifer::Model::Base class is undefined

# src/models/task.cr
class Task < Jennifer::Model::Base
end

The code works though as tests passes

This is true for any class coming from an installed shard which is not required in the file it's being used as far as I can tell

To Reproduce
Create a directory, install shard, require it in a config file and use it from a file that requires the config file

Expected behavior
It shouldn't throw an error

Screenshots
image

Desktop (please complete the following information):

  • OS: Windows 10 + WSL2 Ubuntu22
  • Crystal version: v1.11.2
  • This plugin version: 0.9.3

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions