Closed nokaa closed 6 years ago
@nokaa what version of cobalt are you using? a similar issue was fixed in 0.4
I am using 0.4.0. I installed cobalt from crates.io a few days ago.
@nokaa what is in your .cobalt.yml
?
rss: rss.xml
name: name
description: description
link: https://example.com
I'm pretty sure this was happening without a .cobalt.yml
though.
@nokaa So it might be picking up a change in the folder you are running it from. Maybe try and add an ignore to the config to ignore the files that are changing and causing it to rebuild. If that is not the case. What OS are you on?
It looks as though this only happens if I have a .git
folder. My shell displays the current status of a git repository; so my guess is that it causes some change in one of the .git
files.
Adding ignore: [.git/]
to my config doesn't seem to do anything.
@nokaa try ignore: ".git/*"
That didn't work. I can try building from source and debugging it in a couple days if you'd like.
I happened to find out today that the correct ignore syntax would be ignore: [".git/*"]
, which solves this issue.
I just created a Cobalt site locally and have the same problem without having changed anything in .cobalt.yml
whenever I run cobalt watch
from inside the Cobalt site directory.
Running it from a different location triggers a full rebuild (I understand incremental builds aren't there yet), but is there any way to get watch
to work without cd
ing out elsewhere (or writing a wrapper script, etc.)?
Let me see if I understand.
When you run cobalt watch
from inside the same directory as your .cobalt.yml
, your project endlessly rebuilds?
And if your run cobalt watch -c <PATH.YML>
from a different location, it doesn't endlessly loop but rebuilds when it is supposed to?
What version of cobalt? What does your .cobalt.yml
look like?
@epage sorry for the slow response. Yes, the behavior is exactly as you describe it. I think the ignore functionality isn't working properly.
I just tried this with a new Cobalt site, and it's the same behavior.
<*> cobalt init coblog
[warn] No .cobalt.yml file found in current directory, using default config.
[info] Created new project at coblog
<*> cd coblog
<*> tree
.
├── build
│ ├── index.html
│ └── posts
│ └── post-1.html
├── index.liquid
├── _layouts
│ ├── default.liquid
│ └── post.liquid
└── posts
└── post-1.md
I compiled Cobalt from master
last week:
<*> cobalt -V
Cobalt 0.7.2
I have the default .cobalt.yml
:
<*> cat .cobalt.yml
name: cobalt blog
source: "."
dest: "build"
ignore:
- .git/*
- build/*
Here is what happens when I compile from within the site directory:
<*> cobalt watch -s . -d "build"
[info] Using config file .cobalt.yml
[info] Building from . into build
[info] Created build/posts/post-1.html
[info] Created build/index.html
[info] Copying remaining assets
[info] Build successful
[info] Serving "build" through static file server
[info] Watching "." for changes
[info] Server Listening on 127.0.0.1:3000
[info] Ctrl-c to stop the server
< here I edited posts/post-1.md >
[info] Building from . into build
[info] Created build/index.html
[info] Copying remaining assets
[info] Build successful
[info] Building from . into build
[info] Created build/posts/post-1.html
[info] Created build/index.html
[info] Copying remaining assets
[info] Build successful
[info] Building from . into build
[info] Created build/posts/post-1.html
[info] Created build/index.html
[info] Copying remaining assets
[info] Build successful
...
I am having the same issue.
After installing cobalt 0.7.2
with cargo and running cobalt serve
in the root directory of the project I get the same output as @mrkgnao. Mine .cobalt.yml
is also the same as his...
Yeah, I re-did how watch triggers rebuilds and forgot to protect against this case!
The fun of me testing things by having my destination outside of the project folder.
@nokaa I edited your posting of the issue to include the workaround (ignore the build directory) though we should fix this in cobalt itself.
@mrkgnao, you have an attempt at the work around, not sure why it isn't working.
ignore:
- .git/*
- build/*
I know I've had to play some with the ignore syntax (trying just build
, build/*
, build/**
, etc). I really need to better understand gitignore and how to properly use burntsushi's Gitignore code to make sure the syntax is right. And then figure out how to communicate what to do clearly :)
So here's a workaround that I use on macOS until the issue is resolved:
# Start server in background
cobalt serve &
# Watch for changes in the "blog" directory and trigger a build
fswatch -0 -d blog | xargs -0 -n1 sh -c 'cobalt build'
What's cool about it is, that you can combine that with a browser refresh after every change. I've created a script to refresh the current tab on Firefox from the commandline:
activate application "Firefox"
tell application "System Events" to keystroke "r" using command down
Then, I've created a Makefile
with the following content:
dev:
pkill cobalt
cobalt serve &
fswatch -0 -d blog | xargs -0 -n1 sh -c 'cobalt build && osascript refresh-firefox.scpt'
.PHONY: dev
I start it with make dev
.
This way, whenever I change a blog entry, it shows a fresh version in my browser. 😎
I ran
cobalt watch
on my project and then rancd /my/project/dir
in another terminal. Cobalt starts to endlessly rebuild the project.Work around: add an
ignore
for yourdest
folder, like