remix: [BUG]: .DS_Store files in app/routes dir breaks app

What version of Remix are you using?

1.3.3

Steps to Reproduce

  1. Create a new remix repo
  2. Create a new folder in routes like routes/about
  3. Copy a .DS_Store file (on Mac OS X) or any non-standard encoded file into routes/about
  4. Run npx remix routes --json

Expected Behavior

Remix routes command should ignore the .DS_Store file

Actual Behavior

Remix throws an error:

Error: Invalid route module file: /home/runner/remix-ds-store-breaks-routes-cmd/app/routes/about/.DS_Store
    at /home/runner/remix-ds-store-breaks-routes-cmd/node_modules/@remix-run/dev/config/routesConvention.js:74:11
    at visitFiles (/home/runner/remix-ds-store-breaks-routes-cmd/node_modules/@remix-run/dev/config/routesConvention.js:214:7)
    at visitFiles (/home/runner/remix-ds-store-breaks-routes-cmd/node_modules/@remix-run/dev/config/routesConvention.js:212:7)
    at Object.defineConventionalRoutes (/home/runner/remix-ds-store-breaks-routes-cmd/node_modules/@remix-run/dev/config/routesConvention.js:63:3)
    at Object.readConfig (/home/runner/remix-ds-store-breaks-routes-cmd/node_modules/@remix-run/dev/config.js:158:47)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Object.routes (/home/runner/remix-ds-store-breaks-routes-cmd/node_modules/@remix-run/dev/cli/commands.js:136:18)
    at async Object.run (/home/runner/remix-ds-store-breaks-routes-cmd/node_modules/@remix-run/dev/cli/run.js:346:7)

Demo

Created a reproduction demo at https://replit.com/@eccentric-j/remix-ds-store-breaks-routes-cmd#package.json.

Solution

Was able to solve this by updating the ignoreRoutes in remix.config.js:

	ignoredRouteFiles: ['**/.*'],

Would you be open to a PR to make that default in https://github.com/remix-run/remix/blob/d9ae8e6478bcee326895b8e61a28a3e8d7f19fe7/templates/remix-ts/remix.config.js#L5?

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 5
  • Comments: 15 (1 by maintainers)

Most upvoted comments

Then the default ".*" would not work with routes/.well-known and based on https://remix.run/docs/en/v1/api/conventions#escaping-special-characters, that route-file should be defined like [.]well-known.{mdx,js,tsx}

That’s very subjective. Once you start adding to the default pattern, everyone’s going to start wanting to include their special patterns, when it’s simple to just do it yourself.

Perhaps an acceptable middle-ground is to use the .gitignore patterns as well. This will typically include patterns like .DS_Store or *.~undo-tree~ already. Since these files won’t be committed, it makes sense that they are not valid route files either.