# Come la cartella \`lib\` dei plugin viene aggiunta a \`$LOAD\_PATH\`

**URL:** <https://meta.discourse.org/t/how-lib-folder-of-plugins-are-added-to-the-load-path/204309>\
**Category:** Development\
**Created:** [23 Settembre 2021, 1:36pm UTC](https://meta.discourse.org/t/how-lib-folder-of-plugins-are-added-to-the-load-path/204309 "2021-09-23T13:36:09Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![AhmedLoud](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ahmedloud/32/576547_2.png) [@AhmedLoud](https://meta.discourse.org/u/AhmedLoud)\
**Post date:** [23 Settembre 2021, 1:36pm UTC](https://meta.discourse.org/t/how-lib-folder-of-plugins-are-added-to-the-load-path/204309/1 "2021-09-23T13:36:09Z")

</div>

Ho notato che, quando creo un plugin, se aggiungo una cartella lib e alcuni file al suo interno, posso usare `require` perché viene aggiunta a `$LOAD_PATH`.

Ad esempio, il plugin `docker_manager` contiene un file `lib/docker_manager/git_repo.rb`. Quindi, eseguendo la console di Rails con `rails c`, posso scrivere `require 'docker_manager/git_repo'`.

Sono curioso di sapere come Discourse rende disponibili tutti questi percorsi.

Ho notato che nel file `/lib/plugin/instance.rb`, se commento la riga 671 `self.instance_eval File.read(path), path`, il comando `require` non funziona. Tuttavia, non capisco come `instance_eval` possa aggiungere directory a `load_path`.

---

_[View the full topic](https://meta.discourse.org/t/how-lib-folder-of-plugins-are-added-to-the-load-path/204309)._
