# Set up shards

**URL:** <https://forum.crystal-lang.org/t/set-up-shards/3998>\
**Category:** Help & Support\
**Created:** [October 25, 2021, 3:19am UTC](https://forum.crystal-lang.org/t/set-up-shards/3998 "2021-10-25T03:19:53Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![BrettKnoss](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/brettknoss/32/1119_2.png) [@BrettKnoss](https://forum.crystal-lang.org/u/BrettKnoss)\
**Post date:** [October 25, 2021, 3:19am UTC](https://forum.crystal-lang.org/t/set-up-shards/3998/1 "2021-10-25T03:19:53Z")

</div>

How do I set up a shard without a framework? I get that I’m supposed to have YAML files, but I have no idea what goes inside them.

---

<div class="post-metadata">

**Author:** ![vlazar](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/vlazar/32/31_2.png) [@vlazar](https://forum.crystal-lang.org/u/vlazar)\
**Post date:** [October 25, 2021, 6:33am UTC](https://forum.crystal-lang.org/t/set-up-shards/3998/2 "2021-10-25T06:33:51Z")

</div>

If by setting up shard you mean installing it then you can just copy-paste required lines from sites like [https://shardbox.org/](https://shardbox.org/)

Let’s say you want to install Kemal. At [kemal@1.1.0 on Shardbox](https://shardbox.org/shards/kemal) you can click copy button on the right which would copy this to clipboard:

```auto
kemal:
  github: kemalcr/kemal
  version: ~> 1.1.0

```

And then you paste it into your `shard.yml` file. For full documentation about `shard.yml` format see [shards/shard.yml.adoc at master · crystal-lang/shards · GitHub](https://github.com/crystal-lang/shards/blob/master/docs/shard.yml.adoc)

If by setting up a shard you mean creating your own shard than Crystal has built-in command that would generate some files for your new shard:

```auto
crystal init lib my_shard

```

If you want to start building application with Crystal use `init app` instead of `init lib` command:

```auto
crystal init app my_app

```

There are not many differences in generated files.

The `init lib` command would add `shard.lock` to `.gitignore` file since you typically would lock shard versions in application that uses it and not in shard itself.

The `init app` command adds `targets` section to the `shard.yml` file so that you can use `shard build` command to build your app.

There are some difference in the generated `README.md` file as well. You can check the full difference between generated `my_shard` and `my_app` folders with:

```auto
git diff --no-index my_shard my_app

```

---

<div class="post-metadata">

**Author:** ![BrettKnoss](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/brettknoss/32/1119_2.png) [@BrettKnoss](https://forum.crystal-lang.org/u/BrettKnoss)\
**Post date:** [October 25, 2021, 5:30pm UTC](https://forum.crystal-lang.org/t/set-up-shards/3998/3 "2021-10-25T17:30:51Z")

</div>

OK, this makes a lot more sense

---

<div class="post-metadata">

**Author:** ![BrettKnoss](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/brettknoss/32/1119_2.png) [@BrettKnoss](https://forum.crystal-lang.org/u/BrettKnoss)\
**Post date:** [October 26, 2021, 2:36am UTC](https://forum.crystal-lang.org/t/set-up-shards/3998/4 "2021-10-26T02:36:20Z")

</div>

How do I call a shard from my program? do I just do require? And how do I open an app to test?

---

<div class="post-metadata">

**Author:** ![vlazar](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/vlazar/32/31_2.png) [@vlazar](https://forum.crystal-lang.org/u/vlazar)\
**Post date:** [October 26, 2021, 6:26am UTC](https://forum.crystal-lang.org/t/set-up-shards/3998/5 "2021-10-26T06:26:49Z")

</div>

Yes. There is nothing special about installed shards. When you do `shards install` it just installs them inside `lib` directory in your project. You can put some code there manually and not use `shards install` - the effect would be the same.

Then you can just `require "some_crystal_file"`.

You can read where and how Crystal searches for files to require in the documentation [Requiring files - Crystal](https://crystal-lang.org/reference/syntax_and_semantics/requiring_files.html)

---

<div class="post-metadata">

**Author:** ![lbarasti](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/lbarasti/32/648_2.png) [@lbarasti](https://forum.crystal-lang.org/u/lbarasti)\
**Post date:** [October 30, 2021, 10:53am UTC](https://forum.crystal-lang.org/t/set-up-shards/3998/6 "2021-10-30T10:53:48Z")

</div>

Hey @BrettKnoss, I made this video on the topic a few months ago - it touches on depending on your own shards, too. I think you might find it useful

[![](https://img.youtube.com/vi/pCHBTyelH04/maxresdefault.jpg "Writing Your First Crystal Library") ](https://www.youtube.com/watch?v=pCHBTyelH04)
