Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Route path does not begin with a slash: "C:/Program Files/Git" #574

Closed
Tobbe opened this issue May 21, 2020 · 7 comments · Fixed by #763
Closed

Error: Route path does not begin with a slash: "C:/Program Files/Git" #574

Tobbe opened this issue May 21, 2020 · 7 comments · Fixed by #763

Comments

@Tobbe
Copy link
Member

Tobbe commented May 21, 2020

I'm on Windows, following the tutorial.

$ node --version && yarn --version
v13.8.0
1.22.4
$ less node_modules/\@redwoodjs/core/package.json | grep version
  "version": "0.7.0",

GitBash
image

After creating the Home page

$ yarn rw g page home /
yarn run v1.22.4
$ C:\Users\tobbe\dev\redwood\redwoodblog\node_modules\.bin\rw g page home "C:/Program Files/Git"
  √ Generating page files...
    √ Writing `./web\src\pages\HomePage\HomePage.test.js`...
    √ Writing `./web\src\pages\HomePage\HomePage.js`...
  √ Updating routes file...
Done in 2.19s.

I get this in my browser:

Error: Route path does not begin with a slash: "C:/Program Files/Git"
▼ 20 stack frames were expanded.
validatePath
C:/Users/tobbe/dev/redwood/redwoodblog/node_modules/@redwoodjs/router/dist/util.js:218
_loop
C:/Users/tobbe/dev/redwood/redwoodblog/node_modules/@redwoodjs/router/dist/named-routes.js:59
mapNamedRoutes
C:/Users/tobbe/dev/redwood/redwoodblog/node_modules/@redwoodjs/router/dist/named-routes.js:68
RouterImpl
C:/Users/tobbe/dev/redwood/redwoodblog/node_modules/@redwoodjs/router/dist/router.js:200
renderWithHooks
C:/Users/tobbe/dev/redwood/redwoodblog/node_modules/react-dom/cjs/react-dom.development.js:14803
mountIndeterminateComponent
C:/Users/tobbe/dev/redwood/redwoodblog/node_modules/react-dom/cjs/react-dom.development.js:17482
beginWork
C:/Users/tobbe/dev/redwood/redwoodblog/node_modules/react-dom/cjs/react-dom.development.js:18596
HTMLUnknownElement.callCallback
C:/Users/tobbe/dev/redwood/redwoodblog/node_modules/react-dom/cjs/react-dom.development.js:188
invokeGuardedCallbackDev
C:/Users/tobbe/dev/redwood/redwoodblog/node_modules/react-dom/cjs/react-dom.development.js:237
invokeGuardedCallback
C:/Users/tobbe/dev/redwood/redwoodblog/node_modules/react-dom/cjs/react-dom.development.js:292
beginWork$1
C:/Users/tobbe/dev/redwood/redwoodblog/node_modules/react-dom/cjs/react-dom.development.js:23203
performUnitOfWork
C:/Users/tobbe/dev/redwood/redwoodblog/node_modules/react-dom/cjs/react-dom.development.js:22154
workLoopSync
C:/Users/tobbe/dev/redwood/redwoodblog/node_modules/react-dom/cjs/react-dom.development.js:22130
performSyncWorkOnRoot
C:/Users/tobbe/dev/redwood/redwoodblog/node_modules/react-dom/cjs/react-dom.development.js:21756
scheduleUpdateOnFiber
C:/Users/tobbe/dev/redwood/redwoodblog/node_modules/react-dom/cjs/react-dom.development.js:21188
updateContainer
C:/Users/tobbe/dev/redwood/redwoodblog/node_modules/react-dom/cjs/react-dom.development.js:24373
(anonymous function)
C:/Users/tobbe/dev/redwood/redwoodblog/node_modules/react-dom/cjs/react-dom.development.js:24758
unbatchedUpdates
C:/Users/tobbe/dev/redwood/redwoodblog/node_modules/react-dom/cjs/react-dom.development.js:21903
legacyRenderSubtreeIntoContainer
C:/Users/tobbe/dev/redwood/redwoodblog/node_modules/react-dom/cjs/react-dom.development.js:24757
render
C:/Users/tobbe/dev/redwood/redwoodblog/node_modules/react-dom/cjs/react-dom.development.js:24840
▲ 20 stack frames were expanded.
Module../src/index.js
C:/Users/tobbe/dev/redwood/redwoodblog/web/src/index.js:9
   6 | 
   7 | import './index.css'
   8 | 
>  9 | ReactDOM.render(
  10 |   <FatalErrorBoundary page={FatalErrorPage}>
  11 |     <RedwoodProvider>
  12 |       <Routes />

This issue looks related, but is closed #277

@Tobbe
Copy link
Member Author

Tobbe commented May 21, 2020

This is Routes.js

const Routes = () => {
  return (
    <Router>
      <Route path="C:/Program Files/Git" page={HomePage} name="home" />
      <Route notfound page={NotFoundPage} />
    </Router>
  )
}

It works if I update the path to look like this

const Routes = () => {
  return (
    <Router>
      <Route path="/" page={HomePage} name="home" />
      <Route notfound page={NotFoundPage} />
    </Router>
  )
}

@Tobbe
Copy link
Member Author

Tobbe commented May 21, 2020

If you specify command-line options starting with a slash, POSIX-to-Windows path conversion will kick in converting e.g. "/usr/bin/bash.exe" to "C:\Program Files\Git\usr\bin\bash.exe". When that is not desired -- e.g. "--upload-pack=/opt/git/bin/git-upload-pack" or "-L/regex/" -- you need to set the environment variable MSYS_NO_PATHCONV temporarily, like so:

MSYS_NO_PATHCONV=1 git blame -L/pathconv/ msys2_path_conv.cc

Alternatively, you can double the first slash to avoid POSIX-to-Windows path conversion, e.g. "//usr/bin/bash.exe".

- https://github.com/git-for-windows/build-extra/blob/master/ReleaseNotes.md

With the above info in mind, I tried doing this

$ yarn rw g page home //

And it worked great! :)

@thedavidprice
Copy link
Contributor

Hi @Tobbe Just a quick note to let you know we'll be looking into both this issue and #575 Sorry for the hassle on each. But greatly appreciate you taking the time to diagnose and let us know!

And 👍for adding your system information! That's normally my first question, but you already have it covered. Have a great weekend.

@thedavidprice
Copy link
Contributor

@Tobbe seems like your work in #656 specific to packages/cli/src/commands/generate/helpers.js might be the fix for this... maybe?

@thedavidprice
Copy link
Contributor

thedavidprice commented Jun 9, 2020

Windows 10, @redwoodjs 0.9.2-canary.1

Powershell
Cannot reproduce this issue.

Git Bash
I can reproduce this error with identical results.

Potentially Tutorial Breaking with Workaround
Workaround is to use the double slash, e.g. //, or edit Routes.js.

@jeliasson
Copy link
Contributor

Just a sidenote. If you are not running Windows Subsystem for Linux on your Windows 10, you are missing out ✌️

@Tobbe
Copy link
Member Author

Tobbe commented Jun 28, 2020

@jeliasson I still haven't intsalled the latest windows build, so I don't have WSL2 yet. Will wait to try it until I do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants