Error: Error copying static files when run from a OneDrive folder on windows

When I run hugo from a OneDrive folder in windows, it fails to copy static files. If I copy the whole thing to a non-onedrive folder it all works fine.

In theory the fact that a folder is synced with onedrive should be transparent to apps, so Hugo must be doing something out of the ordinary here.I even tried copying it to a different folder within the onedrive folder (and it still fails). Here’s the full error:

Error: Error copying static files to C:\Users\Sebastian\OneDrive\Documents\Blog\public: open C:\Users\Sebastian\OneDrive\Documents\Blog\public: is a directory

Can I gather some other kinds of logs?

1 Like

That’s kinda funny.

Anyhow, if Hugo is doing something out of the ordinary, it is possible you told it to. Link to your site’s source code, and we can see how you have set up, and test it.

I don’t really know Windows error messages, but that looks like a permission or path issue. Maybe OneDrive requires a particular user to access it.

I don’t currently have my site’s source online, but I’ve built a tiny repro:!AjL69IOnjhAA54FsCguUQB2pC_8UmQ

Put that in a onedrive folder on windows and you’ll see the problem on the latest release.

I’m running hugo as me, so the fact that I can access the folders fine (e.g. I can manually copy the static files to the public folder) but Hugo can’t is a weird.

Perhaps I should add that I use the OneDrive folder as my main “documents” folder, which means that just about every app I use touches it, and nothing else has had any issues so far.

  • Is this “hugo server” or regular “hugo”?
  • What is really a OneDrive directory? Your problems suggests that this isn’t a regular directory, but some kind of remote mount. But I don’t know. I don’t have OneDrive (anymore), so I cannot test it.
  • It feels more natural to ask Microsoft about this. They sold you the product.

Either regular or server.

Onedrive is a thing in windows that basically syncs your folder to the cloud and across all your devices, like dropbox.

It definitely seems like this is an issue with Onedrive, since in theory it should behave like a regular folder, but clearly it isn’t. However, it also doesn’t seem ideal if Hugo doesn’t work with Onedrive in the meantime. Given that this is the only app I’ve found (so far) that doesn’t work, it seems likely that it’s doing something that hits a corner case. Is hugo doing anything particularly exotic with how it handles file IO perhaps?

EDIT: tried this on another windows PC and it does not happen there. It’s an older build of windows on it, so perhaps it’s a recent issue (or perhaps it’s not 100% repro).
EDIT2: Unlinking the ondrive syncing makes it work again (turns it into a regular folder I guess?). Setting up the same onedrive folder on a different drive and it fails again. So it’s definitely 100% repro on this machine at least.

That is of course correct. But know that Hugo is using libraries for these file operations built to handle lots of different operating systems, one of them Windows, so there are bound to be some corner cases. There is a known issue with watching (aka hugo server) on file shares, but that doesn’t sound like this issue.

I hit the same issue just after the fall creator update.
With an old version (Hugo Static Site Generator v0.26 windows/amd64 BuildDate: 2017-09-09T17:07:47-04:00) I have the following error:

Error: Unable to locate Config file. Perhaps you need to create a new site.
       Run `hugo help new` for details. (Config File "config" Not Found in "[C:\\Users\\theo\\OneDrive\\Projets\\home]")

And if I pass the config I have this issue:

Error: Unable to find theme Directory: 

I updated Hugo (Hugo Static Site Generator v0.30.2 windows/amd64 BuildDate: 2017-11-04T01:23:23-04:00) and now have the same issue:

Error: Error copying static files to C:\Users\theo\OneDrive\Projets\home\public: open C:\Users\theo\OneDrive\Projets\home\public\: is a directory

I’m not sure if this means that something changed in Hugo, but it’s interessting to see that passing the config have an effect.

If I copy the whole folder somewhere else (outside OneDrive) it’s working. If I copy it back to OneDrive it’s also working for a short period.

One more information, if I deactivate OneDrive Files On-Demand and copy the folder into a new OneDrive location it works and keep working. So it’s very likely an issue with OneDrive.

I wonder if this occurs because of an edge case in Hugo or in the Go library

Have you considered asking Microsoft about this? OneDrive (and Windows etc.) is a commercial service with support.

FWIW I filed a bug in the feedback app (with a trace of the problem) and tweeted the onedrive team ( )

1 Like

I continued my investigations and it looks like the root cause is in the Go standard library. I just install Go so I may be missing something obvious but

src := "C:\\Users\\theo\\goSrc"
srcO := "C:\\Users\\theo\\OneDrive\\Projets\\homeTest\\static"
fi, _ := os.Stat(src)
fiO, _ := os.Stat(srcO)

return true/false.

I will double check ping back OneDrive and see is this is a know issue in Go and let you know what I found. So far it definitly seems related to the fileOnDemand feature and the Go os package.

Looking around a bit it appears that IsDIr doesn’t work for symlinks. Perhaps that’s the issue here (i.e. either Go’s std lib should treat symlinks transparently, or Hugo should make sure that any checks for directories also need to handle symlinks specially, see e.g. )

Right, that’s the code here:

I opened a bug in Go ( but if the issue is because of symlink it may not be a bug.

I’m not sure the issue is directly in Hugo but rather in spf13/fsync. I not sure what could be the next step to solve that. I moved my folder outside OneDrive as a workaround.

Ruminating on this, I would not be surprised if in addition to OneDrive, Dropbox and Google Drive also do funky things with how they present their folder to the standard UI in various OSs.

Super anecdotal but, I remember having some trouble with standard copy operations in both Dropbox and Google Drive.

So it sounds like either IsDir (and maybe other ops) should return true for symlinks to directories, or code using the Go standard library has to start being a lot more careful about their IO ops to correctly handle symlinks. The former seems better to me since it would avoid subtle errors. But perhaps Hugo should start checking for symlinks explicitly. If IsDir semantics are changed in the future maybe it won’t be necessary anymore, but right now it seems like it’s Hugo that’s broken with symlinks due to not handling them specially (which the current IO library requries).

A company I work with just upgraded their Windows build from 1703 to 1709 (Fall creators update) which introduced some new features to OneDrive. Now all of our Hugo sites that we were collaborating on using OneDrive have stopped working. I have seen a few other posts in the forum related to this [1,2] and the solution is to move the folder outside of OneDrive, but that defeats the excellent collaboration workflow we had setup.

Following this thread I noticed that one of the bugs submitted to Go looks to have been resolved in Go version 1.11. Has anyone managed to get this working doing a custom build of Hugo with Go 1.11beta?

Sorry, just noticed there is an issue related to this open on Hugo

I’ve noticed other issues related to the OneDrive sync client which we also use extensively at work.

If you temporarily pause synchronisation, does it work then? That seems to certainly fix issues with large-scale copy/change events.

Thanks @TotallyInformation, I just tried pausing Sync but still get the same errors.