# ERROR: directory is already being watched!

**URL:** <https://talk.jekyllrb.com/t/error-directory-is-already-being-watched/8612>\
**Category:** Help\
**Created:** [October 11, 2023, 7:26pm UTC](https://talk.jekyllrb.com/t/error-directory-is-already-being-watched/8612 "2023-10-11T19:26:16Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![VillyVretthorn](https://avatars.discourse-cdn.com/v4/letter/v/a587f6/32.png) [@VillyVretthorn](https://talk.jekyllrb.com/u/VillyVretthorn)\
**Post date:** [October 11, 2023, 7:26pm UTC](https://talk.jekyllrb.com/t/error-directory-is-already-being-watched/8612/1 "2023-10-11T19:26:16Z")

</div>

Hi,  
I use a Makefile to build my Jekyll site as well as to initiate jekyll server.  
When I do this, I always get this error:

`ERROR: directory is already being watched!`

Why is this happening?  
Below is my Makefile.  
(btw. I would highly appreciate any feedback/improvements to my Makefile - especially regarding how images are built - I do that now using a shellscript called “convert\_images” that takes source images and generates copies in different resolutions/qualities using imagemagick. However, it is highly inefficient. I would love to know how others approach this - maybe a topic for another thread…)

```auto
all : site

README.html:
        markdown _meta/README.md > _meta/README.html

checklinks: 
        htmlproofer --check-html ./_site

assets:
        ./convert_images 

site: README.html assets 
        jekyll build

server: site assets
        jekyll server --port 4005 --watch --livereload --livereload-port 14005 --trace --drafts --future

clean:
        $(RM) -rfv _site assets/images/*

```

```auto
$ make server 
markdown _meta/README.md > _meta/README.html
jekyll build
Configuration file: /home/....../jekyll-site/_config.yml
            Source: /home/....../jekyll-site
       Destination: /home/....../jekyll-site/_site
 Incremental build: disabled. Enable with --incremental
      Generating... 
                    done in 11.641 seconds.
 Auto-regeneration: disabled. Use --watch to enable.
jekyll server --port 4005 --watch --livereload --livereload-port 14005 --trace --drafts --future
Configuration file: /home/....../jekyll-site/_config.yml
            Source: /home/....../jekyll-site
       Destination: /home/....../jekyll-site/_site
 Incremental build: disabled. Enable with --incremental
      Generating... 
                    done in 5.671 seconds.
 Auto-regeneration: enabled for '/home/....../jekyll-site'
        **ERROR: directory is already being watched!**

        Directory: /home/....../jekyll-site/assets/bootstrap

        is already being watched through: /home/....../jekyll-site/assets/bootstrap-5.2.0-dist

        MORE INFO: https://github.com/guard/listen/blob/master/README.md
LiveReload address: http://0.0.0.0:14005
    Server address: http://0.0.0.0:4005
  Server running... press ctrl-c to stop.
Maximum depth of replacement has been reached. Entry uuid: {xxxxxxxxxxxxxxxxxx}

```

---

<div class="post-metadata">

**Author:** ![michaelbach](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/michaelbach/32/2151_2.png) [@michaelbach](https://talk.jekyllrb.com/u/michaelbach)\
**Post date:** [October 11, 2023, 9:30pm UTC](https://talk.jekyllrb.com/t/error-directory-is-already-being-watched/8612/2 "2023-10-11T21:30:03Z")

</div>

Check whether another instance of the server is already running.

---

<div class="post-metadata">

**Author:** ![VillyVretthorn](https://avatars.discourse-cdn.com/v4/letter/v/a587f6/32.png) [@VillyVretthorn](https://talk.jekyllrb.com/u/VillyVretthorn)\
**Post date:** [October 12, 2023, 6:09am UTC](https://talk.jekyllrb.com/t/error-directory-is-already-being-watched/8612/3 "2023-10-12T06:09:48Z")

</div>

Well, I do have other jekyll servers running - but they’re running for other servers. Can I only have one jekyll server running per machine?  
If this is the case, I really think this should be more clear from the documentation. The man page just says:

```
   s, serve, server
          Serve the site locally.

```

Nothing there about “you may only run one instance per machine”. I also think the actual error about a folder already being watched could be better. It should have a hint about this being the cause if this is the typical cause…

What is the actual directory that is “being watched” (which I am not even sure what means here)? I mean, this sounds like some path being shared across instances (maybe /tmp?) - can’t I somehow configure each instance to use a separate dir?

---

<div class="post-metadata">

**Author:** ![michaelbach](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/michaelbach/32/2151_2.png) [@michaelbach](https://talk.jekyllrb.com/u/michaelbach)\
**Post date:** [October 12, 2023, 6:27am UTC](https://talk.jekyllrb.com/t/error-directory-is-already-being-watched/8612/4 "2023-10-12T06:27:30Z")

</div>

I understand your rant, but have you checked if my hypothesis really explains your error message?

---

<div class="post-metadata">

**Author:** ![rdyar](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/rdyar/32/710_2.png) [@rdyar](https://talk.jekyllrb.com/u/rdyar)\
**Post date:** [October 12, 2023, 11:26pm UTC](https://talk.jekyllrb.com/t/error-directory-is-already-being-watched/8612/5 "2023-10-12T23:26:40Z")

</div>

keep in mind jekylls’ built in web server is really meant for development use - it is not meant to be a production server, just to make it easier to run your site locally to preview it while you are editing it.

Not that it can’t be done (at least for a single site), but it would be better to use an actual web server app for production if that is what you are doing.

In my opinion it is way easier to host via S3 (via amazon amplify) or Netlify - dirt cheap and easy to setup.

---

<div class="post-metadata">

**Author:** ![VillyVretthorn](https://avatars.discourse-cdn.com/v4/letter/v/a587f6/32.png) [@VillyVretthorn](https://talk.jekyllrb.com/u/VillyVretthorn)\
**Post date:** [October 13, 2023, 9:00pm UTC](https://talk.jekyllrb.com/t/error-directory-is-already-being-watched/8612/6 "2023-10-13T21:00:53Z")

</div>

> [@michaelbach](#):
>
> I understand your rant, but have you checked if my hypothesis really explains your error message?

Good point. I just checked it. And the hypothesis has been falsified… I get the error even if only one instance of jekyll is running… So it gotta be something else… How do I debug this deeper?

---

<div class="post-metadata">

**Author:** ![VillyVretthorn](https://avatars.discourse-cdn.com/v4/letter/v/a587f6/32.png) [@VillyVretthorn](https://talk.jekyllrb.com/u/VillyVretthorn)\
**Post date:** [October 13, 2023, 9:03pm UTC](https://talk.jekyllrb.com/t/error-directory-is-already-being-watched/8612/7 "2023-10-13T21:03:24Z")

</div>

> [@rdyar](#):
>
> keep in mind jekylls’ built in web server is really meant for development use - it is not meant to be a production server, just to make it easier to run your site locally to preview it while you are editing it.

This is what I use it for - development. I work on 6-8 different sites at the moment. These sites are pairwise somewhat similar, so I typically work on at least two simultaneously. Thus, I will typically have two jekyll server instances running on different ports.

However, I just found out that I get the error about dir already being watched even when only one instance is running.

---

<div class="post-metadata">

**Author:** ![michaelbach](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/michaelbach/32/2151_2.png) [@michaelbach](https://talk.jekyllrb.com/u/michaelbach)\
**Post date:** [October 13, 2023, 9:26pm UTC](https://talk.jekyllrb.com/t/error-directory-is-already-being-watched/8612/8 "2023-10-13T21:26:37Z")

</div>

I haven’t the foggiest, sorry. But we have incredibly knowledgeable people here on the forum…

---

<div class="post-metadata">

**Author:** ![VillyVretthorn](https://avatars.discourse-cdn.com/v4/letter/v/a587f6/32.png) [@VillyVretthorn](https://talk.jekyllrb.com/u/VillyVretthorn)\
**Post date:** [October 13, 2023, 9:34pm UTC](https://talk.jekyllrb.com/t/error-directory-is-already-being-watched/8612/9 "2023-10-13T21:34:56Z")

</div>

I just found out some more.  
I think the error relates to this: I have a symlink in `/assets/bootstrap -> bootstrap-5.2.0-dist`

This is such that I can refer to the folder `bootstrap` throughout my code. And when I upgrade bootstrap to a new version, I do not have to update all those references.

It seems jekyll treats /assets/bootstrap, and /assets/bootstrap-5.2.0-dist as two different folders and does not see that one is a symlink to the other…

Any way to fix this?

---

<div class="post-metadata">

**Author:** ![VillyVretthorn](https://avatars.discourse-cdn.com/v4/letter/v/a587f6/32.png) [@VillyVretthorn](https://talk.jekyllrb.com/u/VillyVretthorn)\
**Post date:** [October 13, 2023, 9:40pm UTC](https://talk.jekyllrb.com/t/error-directory-is-already-being-watched/8612/10 "2023-10-13T21:40:25Z")

</div>

I think this is related to the problem I am experiencing:

> <https://github.com/guard/listen/pull/273>
>
> @rymai, @thibaudgg - I think this is pretty drastic, so I wanted some feedback b…efore thinking of releasing this.
> \### TL;DR With this patch - Listen aborts (!) if you symlink a directory to another directory within the project
> \#### There are 3 scenarios:
> 
> 1) \_normal symlink\_ - when there's a symlink to a directory outside the watched dir, e.g.
> foo/bar -\> /baz/bar # outside watched dir
> 
> 2) \_duplicate watched dir\_ - when a symlink points to a directory WITHIN the watched dir
> 
> 3) Bad, i.e. \_filesystem loop\_ (and e.g. \`find -L\` also halts on this)
> foo/bar/baz -\> ../..
> \#### The patch
> 
> This patch makes Listen abort on \`3\` (obviously), but also aborts on \`2\`, which I think is ok, because either the user resolves the ambiguity (see below), or complex resolving would have to be implemented in Listen (pointless waste of time).
> \#### Best solution
> 
> The "best" solution is for users to set watchdirs in \`Listen\` in such a way, that \`2\` is avoided.
> \#### Biggest challenge with symlinks:
> 
> Intuitively, users "expect" Listen to do a "REVERSE symlink resolution" and ... return ONLY one path/event!
> 
> E.g., given the user edits: \`project/foo/bar/hello.rb\`, and \`project/foo\` links to \`-\> project/vendor/baz\`, and listen watches \`project\` then what should Listen report as modified?
> 
> a) what the user edited? (\`foo/bar/hello.rb\`)
> 
> b) or what physically changed relative to the watched dir ? (\`vendor/baz/bar/hello.rb\`)
> 
> Of course, option a) is most "user friendly" and "expected", but it gets hairy if you have multiple symlinks pointing to \`vendor/baz/bar\`.
> \#### My stance on this
> 
> I'm in favor of not letting users watch the same physical directory multiple times (files are ok) because of:
> \- complexity
> \- ambiguity
> \- resources (threads mostly)
> \- performance
> 
> Of course it would be up to the user to make sure there are no loops or symlinks - and I believe that's how it should be, because Listen cannot "lock" the filesystem for itself or find out what symlink was used when a file changed.
> \#### Semver
> 
> At the very least I can release a 3.0 of Listen.
> 
> What do you think?

I am not sure what the fix is though. Does this mean that I simply cannot use symlinks?  
Please note that, the linked issue is about symlink loops which would obviously cause problems. But I do not have loops. These are regular simple symlinks to a folder within the folder structure being watched.
