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: RelayParser: Encountered duplicate defintitions for one or more documents #11688

Closed
ChildishhAlbino opened this issue Feb 11, 2019 · 26 comments · Fixed by #12005
Closed
Labels
status: confirmed Issue with steps to reproduce the bug that’s been verified by at least one reviewer. type: bug An issue or pull request relating to a bug in Gatsby

Comments

@ChildishhAlbino
Copy link

Description

Building a blog / portfolio with GatsbyJS and I'm struggling with this issue. I had the website working for the most part but all of a sudden it's stopped working. Really not sure why. The error doesn't make much sense to me. Hoping someone cold help me work out why.

Steps to reproduce

https://github.com/ChildishhAlbino/childishhalbino.github.io/tree/problem-fixing

Above is a git repo with the project as I last left it.

  1. run NPM install for node packages
  2. Run gatsby develop.
  3. Visit localhost/8000

An error screen should appear with the above error.

Expected result

  • Page should load without errors.
  • There should be 3 blog posts with the content from the /posts/ markdown files.
  • The 'about' tab should display 3 'cards' each with information from the /bio/ markdown files.
  • The blurb should load with information from the 'blurb.md' file.

There will be warnings. There are some imports that aren't being used but aside from that everything should be fine.

Actual result

  • Page will not load -> returns above error.
  • Unsure how else to describe the issue.

Environment

Run npx gatsby info --clipboard in your project directory and paste the output here.

System:
OS: Windows 10
CPU: (4) x64 Intel(R) Core(TM) i5-6600K CPU @ 3.50GHz
Binaries:
npm: 6.4.1 - D:\Software Development\Languages, Frameworks,
etc\nodeJs\npm.CMD
Languages:
Python: 3.7.0 - C:\Users\conno\AppData\Local\Programs\Python\Python37-32\python.EXE
Browsers:
Edge: 42.17134.1.0
npmPackages:
gatsby: ^2.0.118 => 2.0.118
gatsby-image: ^2.0.19 => 2.0.29
gatsby-plugin-buildtime-timezone: ^1.0.3 => 1.0.3
gatsby-plugin-manifest: ^2.0.7 => 2.0.17
gatsby-plugin-offline: ^2.0.23 => 2.0.23
gatsby-plugin-react-helmet: ^3.0.1 => 3.0.6
gatsby-plugin-sass: ^2.0.2 => 2.0.10
gatsby-plugin-sharp: ^2.0.11 => 2.0.20
gatsby-source-filesystem: ^2.0.6 => 2.0.20
gatsby-transformer-remark: ^2.2.4 => 2.2.4
gatsby-transformer-sharp: ^2.1.7 => 2.1.13

error The system cannot find the path specified.

Error: The system cannot find the path specified.

  • envinfo.js:1 Function.e.exports.sync
    [childishhalbino.github.io]/[envinfo]/dist/envinfo.js:1:4970

  • envinfo.js:1 Object.copySync
    [childishhalbino.github.io]/[envinfo]/dist/envinfo.js:1:6694 8

  • envinfo.js:1 Object.t.writeSync.e [as writeSync]
    [childishhalbino.github.io]/[envinfo]/dist/envinfo.js:1:4877 7

  • envinfo.js:1
    [childishhalbino.github.io]/[envinfo]/dist/envinfo.js:1:4693 4

  • envinfo.js:1 Promise.all.then.e
    [childishhalbino.github.io]/[envinfo]/dist/envinfo.js:1:4694 9

  • util.js:16 tryCatcher
    [childishhalbino.github.io]/[bluebird]/js/release/util.js:16 :23

  • promise.js:512 Promise._settlePromiseFromHandler
    [childishhalbino.github.io]/[bluebird]/js/release/promise.js :512:31

  • promise.js:569 Promise._settlePromise
    [childishhalbino.github.io]/[bluebird]/js/release/promise.js :569:18

  • promise.js:614 Promise._settlePromise0
    [childishhalbino.github.io]/[bluebird]/js/release/promise.js :614:10

  • promise.js:694 Promise._settlePromises
    [childishhalbino.github.io]/[bluebird]/js/release/promise.js :694:18

  • promise.js:638 Promise._fulfill
    [childishhalbino.github.io]/[bluebird]/js/release/promise.js :638:18

  • promise_array.js:126 PromiseArray._resolve
    [childishhalbino.github.io]/[bluebird]/js/release/promise_ar ray.js:126:19

  • promise_array.js:144 PromiseArray._promiseFulfilled
    [childishhalbino.github.io]/[bluebird]/js/release/promise_ar ray.js:144:14

  • promise.js:574 Promise._settlePromise
    [childishhalbino.github.io]/[bluebird]/js/release/promise.js :574:26

  • promise.js:614 Promise._settlePromise0
    [childishhalbino.github.io]/[bluebird]/js/release/promise.js :614:10

  • promise.js:694 Promise._settlePromises
    [childishhalbino.github.io]/[bluebird]/js/release/promise.js :694:18

error UNHANDLED REJECTION

Error: The system cannot find the path specified.

  • envinfo.js:1 Function.e.exports.sync
    [childishhalbino.github.io]/[envinfo]/dist/envinfo.js:1:4970

  • envinfo.js:1 Object.copySync
    [childishhalbino.github.io]/[envinfo]/dist/envinfo.js:1:6694 8

  • envinfo.js:1 Object.t.writeSync.e [as writeSync]
    [childishhalbino.github.io]/[envinfo]/dist/envinfo.js:1:4877 7

  • envinfo.js:1
    [childishhalbino.github.io]/[envinfo]/dist/envinfo.js:1:4693 4

  • envinfo.js:1 Promise.all.then.e
    [childishhalbino.github.io]/[envinfo]/dist/envinfo.js:1:4694 9

  • util.js:16 tryCatcher
    [childishhalbino.github.io]/[bluebird]/js/release/util.js:16 :23

  • promise.js:512 Promise._settlePromiseFromHandler
    [childishhalbino.github.io]/[bluebird]/js/release/promise.js :512:31

  • promise.js:569 Promise._settlePromise
    [childishhalbino.github.io]/[bluebird]/js/release/promise.js :569:18

  • promise.js:614 Promise._settlePromise0
    [childishhalbino.github.io]/[bluebird]/js/release/promise.js :614:10

  • promise.js:694 Promise._settlePromises
    [childishhalbino.github.io]/[bluebird]/js/release/promise.js :694:18

  • promise.js:638 Promise._fulfill
    [childishhalbino.github.io]/[bluebird]/js/release/promise.js :638:18

  • promise_array.js:126 PromiseArray._resolve
    [childishhalbino.github.io]/[bluebird]/js/release/promise_ar ray.js:126:19

  • promise_array.js:144 PromiseArray._promiseFulfilled
    [childishhalbino.github.io]/[bluebird]/js/release/promise_ar ray.js:144:14

  • promise.js:574 Promise._settlePromise
    [childishhalbino.github.io]/[bluebird]/js/release/promise.js :574:26

  • promise.js:614 Promise._settlePromise0
    [childishhalbino.github.io]/[bluebird]/js/release/promise.js :614:10

  • promise.js:694 Promise._settlePromises
    [childishhalbino.github.io]/[bluebird]/js/release/promise.js :694:18

@pieh pieh added type: bug An issue or pull request relating to a bug in Gatsby status: confirmed Issue with steps to reproduce the bug that’s been verified by at least one reviewer. labels Feb 11, 2019
@pieh
Copy link
Contributor

pieh commented Feb 11, 2019

This is defenitely a bug in gatsby.

For now you can workaround this by changing line in https://github.com/ChildishhAlbino/childishhalbino.github.io/blob/problem-fixing/gatsby-node.js#L34
to:

component: path.resolve(`./src/components/Blog/BlogPostTemplate/blogPostTemplate.js`),

(I adjusted file/directory names casing to match one that exists in repository). It will get you pass that graphql error, but there will be some additional fixes needed elsewhere too because I hit:

error Building static HTML failed for path "/GatsbyJS and Web development/"

See our docs page on debugging HTML builds for help https://gatsby.app/debug-html

  11 |                  <div className="blurb">
  12 |                          <Image fluid={data.image.childImageSharp.fluid} />
> 13 |                          <Markdown source={data.blurb.childMarkdownRemark.rawMarkdownBody} />
     |                                                                           ^
  14 |                  </div>
  15 |          )}
  16 |  />


  WebpackError: TypeError: Cannot read property 'rawMarkdownBody' of null

But this is not really related to issue itself.

I will start working on fix to handle casing differences and to not throw this confusing error message.

@ChildishhAlbino
Copy link
Author

Thanks for working that out for me! I actually didn't think it was a bug in Gatsby but whaddya know? ]

Quickly worked out those errors and the sites working again!

Thanks heaps :D

Have a nice day, good luck fixing the bug!

@imshuffling
Copy link
Contributor

i think I'm having a similar issue, any update on a fix for this?

@pieh
Copy link
Contributor

pieh commented Feb 13, 2019

@imshuffling hopefully I'll open PR today. Just to confirm if your issue have similar root problem - are you on Mac? Because it seems that on Linux and Windows when you use wrong casing for component argument in createPage we will throw error saying that file can't be found.

@imshuffling
Copy link
Contributor

@pieh Yeah I'm on a mac, i've logged a issue here - it may be related #11732

@pieh
Copy link
Contributor

pieh commented Feb 13, 2019

Oh, this seems different. Error from this is:
Error: RelayParser: Encountered duplicate defintitions for one or more documents

@AlexanderProd
Copy link
Contributor

AlexanderProd commented Feb 16, 2019

I'm encountering the same bug as well when I create a new gatsby project using this starter and run gatsby develop.

My error message:

GraphQL Error There was an error while compiling your site's GraphQL queries.
  Error: RelayParser: Encountered duplicate defintitions for one or more documents: each document must have a unique name. Duplicated documents:
- usersAlexanderhoerlSitesBiobalanceSrcTemplatesProductPageIndexJs721922104

I'm also on mac.

System:
  OS: macOS 10.14.3
  CPU: (8) x64 Intel(R) Core(TM) i7-4750HQ CPU @ 2.00GHz
  Shell: 3.2.57 - /bin/bash
Binaries:
  Node: 11.7.0 - /usr/local/bin/node
  Yarn: 1.13.0 - /usr/local/bin/yarn
  npm: 6.5.0 - /usr/local/bin/npm
Languages:
  Python: 2.7.10 - /usr/bin/python
Browsers:
  Chrome: 72.0.3626.109
  Safari: 12.0.3
npmPackages:
  gatsby: ^2.0.111 => 2.0.111 
  gatsby-image: ^2.0.20 => 2.0.25 
  gatsby-plugin-google-analytics: ^2.0.13 => 2.0.13 
  gatsby-plugin-layout: ^1.0.11 => 1.0.11 
  gatsby-plugin-manifest: ^2.0.9 => 2.0.12 
  gatsby-plugin-offline: ^2.0.16 => 2.0.20 
  gatsby-plugin-react-helmet: ^3.0.6 => 3.0.6 
  gatsby-plugin-sharp: ^2.0.14 => 2.0.16 
  gatsby-source-filesystem: ^2.0.8 => 2.0.12 
  gatsby-source-shopify2: ^2.0.7 => 2.0.7 
  gatsby-transformer-sharp: ^2.1.8 => 2.1.9 

@pieh
Copy link
Contributor

pieh commented Feb 16, 2019

@AlexanderProd From quick look it seems like same issue. This is because
file path casing in https://github.com/AlexanderProd/gatsby-shopify-starter/blob/cff5d01029e514cf9ac8ac70987d01cd03a16f82/gatsby-node.js#L19
doesn't match casing exactly:

in gatsby-node: component: path.resolve(`./src/templates/ProductPage/index.js`),
in filesystem:                             src/templates/productPage/index.js
                                                         ^ one `p` is uppercase other is lower case

so as a workaround, adjusting path in gatsby-node should fix this.

@AlexanderProd
Copy link
Contributor

@AlexanderProd From quick look it seems like same issue. This is because
file path casing in https://github.com/AlexanderProd/gatsby-shopify-starter/blob/cff5d01029e514cf9ac8ac70987d01cd03a16f82/gatsby-node.js#L19
doesn't match casing exactly:

in gatsby-node: component: path.resolve(`./src/templates/ProductPage/index.js`),
in filesystem:                             src/templates/productPage/index.js
                                                         ^ one `p` is uppercase other is lower case

so as a workaround, adjusting path in gatsby-node should fix this.

I've noticed when I change it to a small p building and developing works on Ubuntu machines but not on macOS, what makes it pretty difficult to develop on a mac and build on a linux server.

@ZolderonGitHub
Copy link

i have same problem

@mrcongliu
Copy link

I met the same error.
The problem is because I was using Hyper terminal in windows.
Solution is using the default terminal in windows.

@philkrause
Copy link

I met the same error.
The problem is because I was using Hyper terminal in windows.
Solution is using the default terminal in windows.

This solved it for me. Thanks. I did not have this issue on mac.

@john20xdoe
Copy link

john20xdoe commented Aug 4, 2019

Additional info if anyone else stumble on this issue on Windows:

The gatsby npm run script is case-sensitive not only with the src file names, but including the entire path name:

I store all my projects in a folder in D: named Dev, (D:\Dev)
The "duplicate definitions" error is picking on the entire path (im running in WSL Vscode):
filesystem: /d/Dev/longreponame/gatsby-project/component-name-something
is apparently different from what it is generating:
page: /d/dev/longreponame/gatsby-project/component-name-something

I had to rename the Dev folder to lowercase just to fix it.

@patrick-wc
Copy link

Gatsby should really add a warning to any Windows users about having capital letters in their dir names. This must stump quite a few users.

@drillprop
Copy link

I met the same error.
The problem is because I was using Hyper terminal in windows.
Solution is using the default terminal in windows.

works for me too, thank you!

@cleophasmogeni
Copy link

This error can be quite vague for starters but it is actually a warning due to the case sensitive nature of gatsby run scripts. For example: avoid this Myblog in you file path. You can use myblog or even myBlog

@djD-REK
Copy link

djD-REK commented Aug 31, 2019

Gatsby should really add a warning to any Windows users about having capital letters in their dir names. This must stump quite a few users.

Thanks @patrick-wc ! It did stump me!

@mickm77
Copy link

mickm77 commented Sep 3, 2019

On Windows 10 using git bash, i was getting these errors/warnings because I had typed
cd /c/dev/git/projectname
code .

I quit code, and did
cd /C/Dev/Git/projectname
code .

And it all just worked...

@lowtolerance
Copy link

lowtolerance commented Oct 10, 2019

This started happening to me, seemingly out of nowhere. Exiting out of the command line and reentering seemed to do the trick

@8ctopotamus
Copy link

8ctopotamus commented Oct 11, 2019

This is still happening using Git Bash in VSCode terminal on Windows.

Git Bash by itself works fine.

@patrik-u
Copy link

On Windows 10 using git bash, i was getting these errors/warnings because I had typed
cd /c/dev/git/projectname
code .

I quit code, and did
cd /C/Dev/Git/projectname
code .

And it all just worked...

Fixed it for me as well. Used Windows PowerShell and worked when I typed cd FolderName with correct casing.

@benflinn
Copy link

wow i just randomly started having the same error. played around with different content folders for like half an hour before I realized that definitely wasn't it. after renaming my project folder it's working 100% now instantly.

@8ctopotamus
Copy link

I have found that explicitly typing out cd ~/path/to/project avoids this issue (Using Gitbash in VSCode).

@Coffeegerm
Copy link

This is still occurring when I run gatsby develop within a PowerShell prompt on Windows, but not when using the Command Prompt

@assainov
Copy link

For me the error was introduced when I duplicated a src/template/template.js. I moved the file to src/fonts/ folder to eliminate this variant, but gatsby found it even there. Moving the file out of src folder resolved the issue. I think it has to do with a GraphQL queries being similar in different templates.

@KishokanthJeganathan
Copy link

KishokanthJeganathan commented Jun 23, 2020

I had this same issue with when I was having the below code in 2 pages

export const query = graphql`
	query contentFulAddBlogPost($slug: String, $locale: String) {
		contentfulAddBlogPost(path: { eq: $slug }, node_locale: { eq: $locale }) {
			path
			node_locale
		}
	}
`;


to avoid this I changed contentFulAddBlogPost to allContentFulAddBlogPost in one of the components as below

export const query = graphql`
	query allContentFulAddBlogPost($slug: String, $locale: String) {
		contentfulAddBlogPost(path: { eq: $slug }, node_locale: { eq: $locale }) {
			path
			node_locale
		}
	}
`;

worked like a charm. hope it helps you guys in the future :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: confirmed Issue with steps to reproduce the bug that’s been verified by at least one reviewer. type: bug An issue or pull request relating to a bug in Gatsby
Projects
None yet
Development

Successfully merging a pull request may close this issue.