# How to configure source\_dirs with latest Hanami?

**URL:** <https://discourse.hanakai.org/t/how-to-configure-source-dirs-with-latest-hanami/842>\
**Category:** questions\
**Created:** [June 12, 2023, 1:16pm UTC](https://discourse.hanakai.org/t/how-to-configure-source-dirs-with-latest-hanami/842 "2023-06-12T13:16:27Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![wuarmin](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.hanakai.org/wuarmin/32/548_2.png) [@wuarmin](https://discourse.hanakai.org/u/wuarmin)\
**Post date:** [June 12, 2023, 1:16pm UTC](https://discourse.hanakai.org/t/how-to-configure-source-dirs-with-latest-hanami/842/1 "2023-06-12T13:16:27Z")

</div>

Hey,  
some releases ago it was possible to configure the source\_dirs:  
[comprehensive-source-dirs-configuration-for-advanced-users](https://hanamirb.org/blog/2022/01/12/announcing-hanami-200alpha5/#comprehensive-source-dirs-configuration-for-advanced-users-).

This possibility seems no longer available in this way. Does somebody know, how to achieve this with latest Hanami 2.x?

I want to add something like that:

```ruby
config.component_dirs.add "app" do |dir|
  dir.instance = proc do |component|
    if component.identifier.include?("entities")
      component.loader.constant(component)
    else
      component.loader(component)
    end
  end
end

```

Thanks

---

<div class="post-metadata">

**Author:** ![alassek](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.hanakai.org/alassek/32/532_2.png) [@alassek](https://discourse.hanakai.org/u/alassek)\
**Post date:** [June 12, 2023, 6:43pm UTC](https://discourse.hanakai.org/t/how-to-configure-source-dirs-with-latest-hanami/842/2 "2023-06-12T18:43:11Z")

</div>

Removed in [this PR](https://github.com/hanami/hanami/pull/1174). You can use `config.no_auto_register_paths` or magic comments to exclude certain files.

---

<div class="post-metadata">

**Author:** ![timriley](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.hanakai.org/timriley/32/621_2.png) [@timriley](https://discourse.hanakai.org/u/timriley)\
**Post date:** [June 13, 2023, 7:41am UTC](https://discourse.hanakai.org/t/how-to-configure-source-dirs-with-latest-hanami/842/3 "2023-06-13T07:41:39Z")

</div>

You should still be able to configure component dirs, but inside a `prepare_container` block.

The idea with `prepare_container` is to give people a “use at your own risk” method for customising internal container config.

The block is run after Hanami has already configured its containers.

So you could try something like this:

```ruby
module MyApp
  class App < Hanami::App
    prepare_container do |container|
      # container is the Dry::System::Container for the app

      # configure an automatically-configured dir like this
      container.config.component_dirs.dir("some/dir") do |dir|
        # configure the dir here
      end

      # or add your own
      container.config.component_dirs.add "another/dir" do |dir|
      end

      # or do any other kind of config you want
    end
  end
end

```

---

<div class="post-metadata">

**Author:** ![wuarmin](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.hanakai.org/wuarmin/32/548_2.png) [@wuarmin](https://discourse.hanakai.org/u/wuarmin)\
**Post date:** [June 13, 2023, 8:13am UTC](https://discourse.hanakai.org/t/how-to-configure-source-dirs-with-latest-hanami/842/4 "2023-06-13T08:13:59Z")

</div>

@timriley Thank you. I’m still not used to the awesomeness that hanami offers. I’m still excited every day.
