# Are you able to change the require order? Crystal 0.35.1

**URL:** <https://forum.crystal-lang.org/t/are-you-able-to-change-the-require-order-crystal-0-35-1/2951>\
**Category:** Help & Support\
**Created:** [February 10, 2021, 2:14am UTC](https://forum.crystal-lang.org/t/are-you-able-to-change-the-require-order-crystal-0-35-1/2951 "2021-02-10T02:14:23Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![TheOneAndOnly](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/theoneandonly/32/1152_2.png) [@TheOneAndOnly](https://forum.crystal-lang.org/u/TheOneAndOnly)\
**Post date:** [February 10, 2021, 2:14am UTC](https://forum.crystal-lang.org/t/are-you-able-to-change-the-require-order-crystal-0-35-1/2951/1 "2021-02-10T02:14:23Z")

</div>

I’m using REPL.it, I would LOVE to use the latest version but I have to wait for them. Anyways… in short: I’ve made a class in one file, being able to use it everywhere else I put a `require "./*"`, but now in another the require stops working – I get a compile error saying the class doesn’t exist. I don’t know what’s happening although I suspect it has something to do with require order and what’s available at one point to another. Trouble is, I tested out a smaller version of the same problem and it went away! So I’m very confused. Link if it’s relevant: [https://repl.it/@Th3OneAndOnly/AwesomeHonorableParallelprocessing](https://repl.it/@Th3OneAndOnly/AwesomeHonorableParallelprocessing)

---

<div class="post-metadata">

**Author:** ![Blacksmoke16](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/blacksmoke16/32/1241_2.png) [@Blacksmoke16](https://forum.crystal-lang.org/u/Blacksmoke16)\
**Post date:** [February 10, 2021, 2:19am UTC](https://forum.crystal-lang.org/t/are-you-able-to-change-the-require-order-crystal-0-35-1/2951/2 "2021-02-10T02:19:49Z")

</div>

The best solution here is to just not use that and require the files manually. Using a glob like that usually isn’t the best idea as you run into problems like this.

Another solution would ofc be to install Crystal locally and get the latest version 😉.

---

<div class="post-metadata">

**Author:** ![TheOneAndOnly](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/theoneandonly/32/1152_2.png) [@TheOneAndOnly](https://forum.crystal-lang.org/u/TheOneAndOnly)\
**Post date:** [February 10, 2021, 2:21am UTC](https://forum.crystal-lang.org/t/are-you-able-to-change-the-require-order-crystal-0-35-1/2951/3 "2021-02-10T02:21:47Z")

</div>

> [@Blacksmoke16](#):
>
> Another solution would ofc be to install Crystal locally and get the latest version 😉.

I would if I could ☹. I’m a Windows User.

For the actual answer, I find that solution to be a bit tedious, but oh well. Thank you!

---

<div class="post-metadata">

**Author:** ![Blacksmoke16](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/blacksmoke16/32/1241_2.png) [@Blacksmoke16](https://forum.crystal-lang.org/u/Blacksmoke16)\
**Post date:** [February 10, 2021, 2:23am UTC](https://forum.crystal-lang.org/t/are-you-able-to-change-the-require-order-crystal-0-35-1/2951/4 "2021-02-10T02:23:54Z")

</div>

[Install On Windows Subsystem for Linux - The Crystal Programming Language](https://crystal-lang.org/install/on_wsl/) is always an option. Are quite a few people that use it and as far as I know it works quite well.

Also fwiw every file doesn’t need to require every other file. Normally you have a main file that requires all the children. Only times I noticed when a sub file needs an explicit require is if it uses a type defined before it. I.e. type `a.cr` uses a type defined in `z.cr` within some sub directory.

---

<div class="post-metadata">

**Author:** ![TheOneAndOnly](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/theoneandonly/32/1152_2.png) [@TheOneAndOnly](https://forum.crystal-lang.org/u/TheOneAndOnly)\
**Post date:** [February 10, 2021, 2:26am UTC](https://forum.crystal-lang.org/t/are-you-able-to-change-the-require-order-crystal-0-35-1/2951/5 "2021-02-10T02:26:21Z")

</div>

I was thinking of “tree” like structure file requiring. In my project, I’m replicating craftinginterpreters in Crystal so maybe I’d have `lox.cr` require `scan.cr`, `parse.cr`, and `interpret.cr`. Then those require both `expr.cr`, `tokentype.cr`, and, when I get there, `stmt.cr`. Or is there a more efficient method to which you were referring?

---

<div class="post-metadata">

**Author:** ![Blacksmoke16](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/blacksmoke16/32/1241_2.png) [@Blacksmoke16](https://forum.crystal-lang.org/u/Blacksmoke16)\
**Post date:** [February 10, 2021, 2:35am UTC](https://forum.crystal-lang.org/t/are-you-able-to-change-the-require-order-crystal-0-35-1/2951/6 "2021-02-10T02:35:34Z")

</div>

Right yea. Have `run.cr` require `lox.cr`. Then `lox.cr` require the files that it uses. Most of the time it’s a good idea if each file requires the stuff it uses that isn’t already included where that file was included.

---

<div class="post-metadata">

**Author:** ![matthewmcgarvey](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/matthewmcgarvey/32/983_2.png) [@matthewmcgarvey](https://forum.crystal-lang.org/u/matthewmcgarvey)\
**Post date:** [February 10, 2021, 3:00am UTC](https://forum.crystal-lang.org/t/are-you-able-to-change-the-require-order-crystal-0-35-1/2951/7 "2021-02-10T03:00:19Z")

</div>

I’m not sure if it’s correct but I’ve always assumed files are required in alphabetical order when using a glob require. So if you do `require "./*"` it will load `a.cr` before `b.cr`. If there’s a specific file that is being required later than you need it to with the glob, you can just add it above the glob to force it to be required first

```crystal
require "./b"
require "./*"

```
