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 when running gatsby build with --prefix-paths #13

Closed
bryanberger opened this issue Nov 5, 2019 · 13 comments
Closed

Error when running gatsby build with --prefix-paths #13

bryanberger opened this issue Nov 5, 2019 · 13 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@bryanberger
Copy link

Issue Summary

Trying to use this plugin and deploy to Github Pages (using gh-pages)

Errors

[Error: ENOENT: no such file or directory, open 'public/website-gatsby/sitemap.xml'] {
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: 'public/website-gatsby/sitemap.xml'
}

[Error: ENOENT: no such file or directory, open 'public/website-gatsby/sitemap-pages.xml'] {
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: 'public/website-gatsby/sitemap-pages.xml'
}

To Reproduce

  1. add a pathPrefix key/value to gatsby-config.js
  2. gatsby build --prefix-paths

Any other info e.g. Why do you consider this to be a bug? What did you expect to happen instead?

Technical details:

  • Gatsby Version: 2.10.0
  • Node Version: 12.10.0
  • OS: Mac OSX Mojave
@jbuffin
Copy link

jbuffin commented Nov 13, 2019

I'm having the same issue

@dimileeh
Copy link

I'm a novice in nodejs, so bear with me.
I also get this error. When I run gatsby build --prefix-paths, right when it starts creating HTML files, I run mkdir public/<PREFIX_PATH> and that's it, no errors :)

So, there are two ways to fix this issue.

  1. Figure out why yarn (or npm) doesn't create the prefix-path folder in public for the given sitemap.xml automatically.
  2. Make the sitemap ignore the prefix-path folder for the ouput of sitemap files, but leave the prefix-path in the src attribute of a given sitemap.
  3. Give user a choice in the config on which option to choose.

The easiest would be to implement the first option and then let the user put sitemap files where appropriate through the postbuild config.

@dimileeh
Copy link

For now, I've selected the second option and simply removed pathPrefix from indexSitemapFile and resourcesSitemapFile in the src/gatsby-node.js file and re-added the module through yarn add. And it all works.

It's a shame I'm not that experienced in nodejs to contribute with the third option :(

@alexthewilde
Copy link

@dimileeh your quick fix works.

What I don't understand: why is pathPrefix being used here in the first place?

const indexSitemapFile = path.join(PUBLICPATH, pathPrefix, INDEXFILE)

@aileen aileen added bug Something isn't working help wanted Extra attention is needed labels Feb 11, 2020
@MansoorMajeed
Copy link

Since I didn't need the advanced features, I ended up using the basic sitemap plugin https://www.gatsbyjs.org/packages/gatsby-plugin-sitemap/ which works fine

@srivastavarnav
Copy link

any update on this bug?

@Kumail786
Copy link

Any update on this ? facing same issue while using gatsby-plugin-advanced-sitemap

@yogeshkotadiya
Copy link
Collaborator

yogeshkotadiya commented Jan 28, 2021

I've not tested fully but hopefully, this should solve #126

@aileen aileen closed this as completed in f55466f Feb 2, 2021
@generalpiston
Copy link
Contributor

generalpiston commented Feb 22, 2021

@yogeshkotadiya not entirely. It still doesn't generate sitemap-(part).xml because the nested directory doesn't exist. You might need to make any parent directories if they don't exist.

For reference, I had to add "prebuild": "mkdir -p ./public/(directory)", to the scripts section of my package.json.

@generalpiston
Copy link
Contributor

@yogeshkotadiya another problem is the relative location of sitemap.xsl. The sitemap files are prefixed with pathPrefix, but the sitemap.xsl is not.

@anicioalexandre
Copy link

I'm still getting this "file or directory not found" using gatsby-plugin-advanced-sitemap with pathPrefix :(

@generalpiston
Copy link
Contributor

@yogeshkotadiya the offending line for sitemap.xsl is here:

`<?xml-stylesheet type="text/xsl" href="sitemap.xsl"?>`;
.

export const sitemapsUtils = {
    getDeclarations: function () {
        return `<?xml version="1.0" encoding="UTF-8"?>` +
            `<?xml-stylesheet type="text/xsl" href="sitemap.xsl"?>`;
    }
};

Basically, if sitemaps are generated under pathPrefix, then the xsl needs to be in the same directory or referenced to correctly.

Why not move it under pathPrefix?

@mrseanbaines
Copy link

I am facing the same issue when using assetPrefix since sitemap.xsl doesn't get prefixed but the other files do.

image

Would be nice if there was an option to exclude styling altogether, then I could at least get around the issue. Although should sitemaps get prefixed anyway? I guess you'd always/usually want it at the root, e.g. example.com/sitemap.xml

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests