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

Spaces in project path break Markdoc integration #8164

Closed
1 task
suhaylmv opened this issue Aug 20, 2023 · 14 comments · Fixed by #8759
Closed
1 task

Spaces in project path break Markdoc integration #8164

suhaylmv opened this issue Aug 20, 2023 · 14 comments · Fixed by #8759
Labels
- P2: has workaround Bug, but has workaround (priority) pkg: markdoc Related to the `@astrojs/markdoc` package (scope)

Comments

@suhaylmv
Copy link

What version of astro are you using?

2.10.12

Are you using an SSR adapter? If so, which one?

No

What package manager are you using?

npm

What operating system are you using?

Linux

What browser are you using?

Firefox

Describe the Bug

Had a fully functional blog which uses .md files, but after installing markdoc and creating the config file, right when I rename a .md file to .mdoc throws this error:

Failed to load url /mnt/D/Docs/Web%20projects/randomproject/markdoc.config.mjs (resolved id: /mnt/D/Docs/Web%20projects/randomproject/markdoc.config.mjs) in /mnt/D/Docs/Web projects/randomproject/src/content/blog/randomblogpost.mdoc. Does the file exist?

What's the expected result?

It should keep working

Link to Minimal Reproducible Example

Link to my project repo: https://github.com/suhaylmv/minov-studio . Check the branch "test"

Participation

  • I am willing to submit a pull request for this issue.
@github-actions github-actions bot added the needs triage Issue needs to be triaged label Aug 20, 2023
@lilnasy
Copy link
Contributor

lilnasy commented Aug 20, 2023

Thanks for bringing this up!

It's probably going to be difficult to diagnose it from your real project that you linked. Could you create a minimal reproduction?

@lilnasy lilnasy added needs repro Issue needs a reproduction and removed needs triage Issue needs to be triaged labels Aug 20, 2023
@github-actions
Copy link
Contributor

Hello @suhaylmv. Please provide a minimal reproduction using a GitHub repository or StackBlitz. Issues marked with needs repro will be closed if they have no activity within 3 days.

@suhaylmv
Copy link
Author

suhaylmv commented Aug 20, 2023

@lilnasy
I installed this markdoc template https://github.com/withastro/astro/tree/latest/examples/with-markdoc , and when I run npm run dev it throws exactly the same error. Could you please try this template and see if it works for you? If it does, then it must be problem of my machine

@lilnasy
Copy link
Contributor

lilnasy commented Aug 20, 2023

It seems to work fine, both in dev and build.

image

@suhaylmv
Copy link
Author

That's odd. I think the problem is the OS. Now I'm on Elementary OS (debian based), but before when I used Arch I never had such issues. I had a fuckton of other problems too because of Elementary. Distro hopping is never going to end). Thank you for help!

@suhaylmv
Copy link
Author

I made a fresh install of pop os and I'm having the same problem. Idk what to do

@suhaylmv
Copy link
Author

Ok I found a solution. For some reason when the project folder is inside an external hdd drive and the project uses markdoc, gives this error. I would suggest trying the same on other machines to see if the same error occurs. If it does, then maybe it's worth adding the information to the troubleshooting page in the documentation.

@lilnasy
Copy link
Contributor

lilnasy commented Aug 21, 2023

You also seem to have a space in your project path, could that be the issue?

@suhaylmv
Copy link
Author

You also seem to have a space in your project path, could that be the issue?

Where?

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Aug 26, 2023
@lilnasy lilnasy reopened this Sep 21, 2023
@github-actions github-actions bot added the needs triage Issue needs to be triaged label Sep 21, 2023
@lilnasy
Copy link
Contributor

lilnasy commented Sep 21, 2023

Good first issue!

This is an opportunity for astro users to learn about how astro works by fixing a small but real bug. You can expect to get help setting up the dev environment, and understanding the project structure in the #dev channel of our discord: https://astro.build/chat. If you have already been contributing for a while, consider guiding an enthusiastic newcomer.

What's the bug?

You can reproduce it by creating a new project using the with-markdoc template and renaming the created project to include a space. The project would fail to build.

What's going wrong here?

The cause of the issue is a space in the path. Astro config stores most paths as URL objects. Part of URL encoding is using %20 in place of a space. This would need to be converted back so that vite can understand it. See #8614 for a similar fix.

Where do I start looking?

The markdoc integration uses the Astro config (with URLs) here.

@lilnasy lilnasy added - P2: has workaround Bug, but has workaround (priority) pkg: markdoc Related to the `@astrojs/markdoc` package (scope) help wanted Please help with this issue! and removed needs repro Issue needs a reproduction needs triage Issue needs to be triaged labels Sep 21, 2023
@lilnasy lilnasy changed the title Fails to import markdoc.config.mjs Spaces in project path break Markdoc integration Sep 26, 2023
@lutaok
Copy link
Contributor

lutaok commented Oct 4, 2023

Hello @lilnasy,
I'd like to contribute on this.

I actually already have a fix for this thanks to your suggestions, but I also wanted to add a test case for this scenario. Do you think it could be valuable?

If yes, proper tests would be of "render", "render html" and "variables" categories, is that correct?

Thank you in advance!

@lilnasy
Copy link
Contributor

lilnasy commented Oct 5, 2023

Thanks for looking into it!

And yes, those categories sound appropriate.

@natemoo-re
Copy link
Member

Just linked this issue to the next release so GitHub will display what release the fix is included in!

@natemoo-re natemoo-re removed the help wanted Please help with this issue! label Oct 27, 2023
@bluwy
Copy link
Member

bluwy commented Jan 3, 2024

Looks like GitHub didn't automatically close this. Fixed in #8759

@bluwy bluwy closed this as completed Jan 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P2: has workaround Bug, but has workaround (priority) pkg: markdoc Related to the `@astrojs/markdoc` package (scope)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants