Error: No matching file found
labnol opened this issue · 5 comments
After I upgraded to v2.0, gatsby build is throwing this error. For some reason, it is adding 'static' twice in the file path. I am not using any custom options in the gatsby config file. The build works if I downgrade to v1.
"gatsby-plugin-mdx" threw an error while running the onCreateNode lifecycle:
No matching file found for src "/static/e74f7be9122eaf7ab2744068d022888c/16546/add-calendar-events.png" in static folder "static". Please check static folder name and that file exists at "static/static/e74f7be9122eaf7ab2744068d022888c/16546/add-calendar-events.png". This error will probably cause a "GraphQLDocumentError" later in build. All converted field paths MUST resolve to a matching file in the "static" folder.
Error: No matching file found for src "/static/e74f7be9122eaf7ab2744068d022888c/16546/add-calendar-events.png" in static folder "static". Please check static folder name and that file exists at "static/static/e74f7be9122eaf7ab2 744068d022888c/16546/add-calendar-events.png". This error will probably cause a "GraphQLDocumentError" later in build. All converted field paths MUST resolve to a matching file in the "static" folder.
- index.js:32 Object.exports.findMatchingFile
[domain.com]/[gatsby-remark-relative-images]/dist/index.js:32:15
- index.js:68 Node.<anonymous>
[domain.com]/[gatsby-remark-relative-images]/dist/index.js:68:34
- traversing.js:300 initialize.exports.each
[domain.com]/[gatsby-remark-relative-images]/[cheerio]/lib/api/traversing.js:300:24
- index.js:59
[domain.com]/[gatsby-remark-relative-images]/dist/index.js:59:18
- Array.forEach
- index.js:54
[domain.com]/[gatsby-remark-relative-images]/dist/index.js:54:56
- Generator.next
- index.js:8
[domain.com]/[gatsby-remark-relative-images]/dist/index.js:8:71
- new Promise
- index.js:4 __awaiter
[domain.com]/[gatsby-remark-relative-images]/dist/index.js:4:12
- index.js:36 exports.default
[domain.com]/[gatsby-remark-relative-images]/dist/index.js:36:76
- get-source-plugins-as-remark-plugins.js:59 transformer
[domain.com]/[gatsby-plugin-mdx]/utils/get-source-plugins-as-remark-plugins.js:59:17
- wrap.js:25 wrapped
[domain.com]/[trough]/wrap.js:25:19
- index.js:57 next
[domain.com]/[trough]/index.js:57:24
- wrap.js:55 done
[domain.com]/[trough]/wrap.js:55:16
- wrap.js:62 then
[domain.com]/[trough]/wrap.js:62:5
not finished source and transform nodes - 78.261s
not finished Generating image thumbnails - 8.800s
(sharp:11509): GLib-CRITICAL **: 19:27:19.623: g_hash_table_lookup: assertion 'hash_table != NULL' failed
(sharp:11509): GLib-CRITICAL **: 19:27:19.624: g_hash_table_insert_internal: assertion 'hash_table != NULL' failed
(sharp:11509): GLib-CRITICAL **: 19:27:19.624: g_hash_table_lookup: assertion 'hash_table != NULL' failed
[1] 11508 segmentation fault npm run build
Thanks in advance for any assistance you can provide!
@labnol Thanks for opening the issue. It looks like you are referencing the image with src:
/static/e74f7be9122eaf7ab2744068d022888c/16546/add-calendar-events.png
v2 automatically appends your static folder to the resolved URL so that it can properly match nested files with the potential same name, which gives you:
/static/static/e74f7be9122eaf7ab2744068d022888c/16546/add-calendar-events.png
If you remove the /static
in your src url it should work.
Was there a reason you were referencing it using /static
in the first place? Are you using NetlifyCMS? I realize there may be other use-cases for this plugin so I am open to making changes If need be.
Side note: Let me know if you have any issues using gatsby-plugin-mdx
instead of gatsby-transformer-remark
since I noticed some odd behavior with it not triggering the onCreateNode
before the schema is generated which can result in failed type generation. A quick fix seems to be adding the plugin AGAIN above gatsby-plugin-mdx
as a root plugin.
After trying a bunch of things, I moved 'gatsby-remark-relative-images' before 'gatsby-remark-images' in the config file and that seems to work. I have no idea why but it is no longer throwing that error.
@labnol yes it states in the usage example that it MUST go before gatsby-remark-images
as it needs to transform the URL before it is turned into an image object, that requirement was the same pre v2 as well. If that solved your problem please close the issue, or let me know if you run into anything else. Thanks.
Thank you.