question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

DS_Store files created by finder on mac result in Server Errors

See original GitHub issue

Have you read the Contributing Guidelines on issues?

Description

After opening a folder on MacOS using their Finder program, it creates .DS_Store files automatically. When starting the server and browsing to a directory (events, services or event the homepage) a “Server Error” is shown:

Steps to reproduce

  1. Open one of the program directories, can be the root or events, services,… using Finder
  2. Start the server (npm run dev)
  3. A crash occurs when viewing the page associated with a folder containing a .DS_Store file.

Expected behavior

No crash should occur even if there is a .DS_Store file, these files should be ignored.

Actual behavior

Server Error

Error: ENOTDIR: not a directory, open '/Users/harm/Projects/cashless-pay/docs/event-catalog/events/.DS_Store/index.md'
This error happened while generating the page. Any console logs will be displayed in the terminal window.
Source
Object.openSync
node:fs (585:3)
Object.readFileSync
node:fs (453:35)

lib/file-reader.ts (19:15) @ readMarkdownFile

  17 | 
  18 | export const readMarkdownFile = (pathToFile: string) => {
> 19 |   const file = fs.readFileSync(pathToFile, {
     |               ^
  20 |     encoding: 'utf-8',
  21 |   });
  22 |   return matter(file);

Call Stack
eval
lib/events.ts (136:38)
Array.map
<anonymous>
getAllEvents
lib/events.ts (135:17)
getStaticProps
pages/events.tsx (252:29)
Object.renderToHTML
file:/Users/harm/Projects/cashless-pay/docs/event-catalog/node_modules/next/dist/server/render.js (442:26)
async doRender
file:/Users/harm/Projects/cashless-pay/docs/event-catalog/node_modules/next/dist/server/base-server.js (855:38)
async
file:/Users/harm/Projects/cashless-pay/docs/event-catalog/node_modules/next/dist/server/base-server.js (950:28)

Your environment

  • EventCatalog version used: 0.0.1
  • Environment name and version (e.g. Chrome 89, Node.js 16.4): node 8.3.1, firefox 97
  • Operating system and version (e.g. Ubuntu 20.04.2 LTS): MacOS 12.2.1

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
mikaelvesavuoricommented, Jun 30, 2022

Not a solution but a quick fix to not get stuck is to add a basic command for removing those files before building:

"build": "npm run clean && eventcatalog build",
"clean": "find . -name '.DS_Store' -type f -delete",

There is no real danger in removing them, so this should be safe and good.

On another note I did a 10-second test by just adding an fs.existsSync(dir) to return empty if the relevant code path is not a directory but the logic is deeper than that, so we still need to spend a bit more effort getting that to work beyond that basic check.

1reaction
mikaelvesavuoricommented, Jul 7, 2022

Since the command will be unrecognized on Windows, and also since the .DS_Store will never be generated on a Windows machine, it is all completely Linux/Mac oriented. I advise against putting this in EventCatalog, though the checks in the code should ignore/not return non-directory items—i.e. solving the actual problem, rather than its symptom.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error message "The operation can't be com…
Error message "The operation can't be completed because an item with the name .DS_Store already exists". Major headaches with copying files ...
Read more >
Hidden .DS_Store files from a macOS causes files to error ...
A .DS_Store file is a hidden file on your Mac's operating system that the macOS creates automatically whenever you browse a folder through ......
Read more >
How to Fix Error Code -36 '.DS_Store can't be read or written'
DS_Store (Desktop Services Store) is a series of hidden cache files created by Mac OS. If they don't exist by default, your macOS...
Read more >
How can I Remove .DS_Store files from a Git repository?
DS_Store files, do not to use the OS X Finder to view folders. An alternative way to view folders is to use UNIX...
Read more >
Can't write file ".DS_Store", error -50 (feature not supported)
It's possible that you logged on to the destination at one time as "root" or some such, and caused the Finder to create...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found