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

Gatsby build fails on shared hosting where listing of folder content (e.g /home) is not allowed #14962

Closed
andrejpavlovic opened this issue Jun 20, 2019 · 6 comments · Fixed by #15876
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 type: upstream Issues outside of Gatsby's control, caused by dependencies

Comments

@andrejpavlovic
Copy link

andrejpavlovic commented Jun 20, 2019

Description

I've tried running gatsby build on my shared hosting, but the build failed. More specifically, it seems to fail due to the fact that one of the parent directories (in this case /home) does not permit listing of files. The true-case-path library, used by gatsby, throws an error because it is unable to scandir a component path's parent folder (in this case the component path is /home/myusername/gatsby-site/src/pages/404.js). I think the build should proceed in this case, and handle this error silently.

Steps to reproduce

cd /home/myusername
npm install -g gatsby
gatsby new gatsby-site
cd gatsby-site
npm run build

Expected result

Build should complete successfully. If parent directories do not allow files to be listed, the build should still proceed.

Actual result

[myusername@server gatsby-site]$ npm run build

> gatsby-starter-default@0.1.0 build /home/myusername/gatsby-site
> gatsby build

success open and validate gatsby-configs - 0.011 s
success load plugins - 0.491 s
success onPreInit - 0.010 s
success delete html and css files from previous builds - 0.010 s
success initialize cache - 0.021 s
success copy gatsby files - 0.043 s
success onPreBootstrap - 0.012 s
success source and transform nodes - 0.073 s
success building schema - 0.312 s
success createPages - 0.002 s
/home/myusername/gatsby-site/src/pages/404.js
error UNHANDLED REJECTION


  Error: EACCES: permission denied, scandir '/home'

  - sync.js:288 GlobSync._readdir
    [gatsby-site]/[glob]/sync.js:288:41

  - sync.js:137 GlobSync._processReaddir
    [gatsby-site]/[glob]/sync.js:137:22

  - sync.js:132 GlobSync._process
    [gatsby-site]/[glob]/sync.js:132:10

  - sync.js:207 GlobSync._processReaddir
    [gatsby-site]/[glob]/sync.js:207:10

  - sync.js:132 GlobSync._process
    [gatsby-site]/[glob]/sync.js:132:10

  - sync.js:48 new GlobSync
    [gatsby-site]/[glob]/sync.js:48:10

  - sync.js:26 Function.globSync [as sync]
    [gatsby-site]/[glob]/sync.js:26:10

  - index.js:29 trueCasePathSync
    [gatsby-site]/[true-case-path]/index.js:29:15

  - public.js:198 actions.createPage
    [gatsby-site]/[gatsby]/dist/redux/actions/public.js:198:41

  - redux.js:468
    [gatsby-site]/[redux]/lib/redux.js:468:35

  - api-runner-node.js:68 doubleBoundActionCreators.(anonymous function).args
    [gatsby-site]/[gatsby]/dist/utils/api-runner-node.js:68:20

  - gatsby-node.js:141 _createPage
    [gatsby-site]/[gatsby-plugin-page-creator]/gatsby-node.js:141:3

  - gatsby-node.js:76
    [gatsby-site]/[gatsby-plugin-page-creator]/gatsby-node.js:76:22

  - Array.forEach

  - gatsby-node.js:75 Object._callee$
    [gatsby-site]/[gatsby-plugin-page-creator]/gatsby-node.js:75:19

Environment

  System:
    OS: Linux 3.10 CentOS Linux 7 (Core)
    CPU: (48) x64 Intel(R) Xeon(R) CPU E5-2650 v4 @ 2.20GHz
    Shell: 4.2.46 - /bin/bash
  Binaries:
    Node: 10.15.1 - ~/webapps/nodejs/bin/node
    npm: 6.4.1 - ~/webapps/nodejs/bin/npm
  Languages:
    Python: 2.7.5 - /usr/local/bin/python
  npmPackages:
    gatsby: ^2.9.11 => 2.9.11
    gatsby-image: ^2.1.4 => 2.1.4
    gatsby-plugin-manifest: ^2.1.1 => 2.1.1
    gatsby-plugin-offline: ^2.1.3 => 2.1.3
    gatsby-plugin-react-helmet: ^3.0.12 => 3.0.12
    gatsby-plugin-sharp: ^2.1.9 => 2.1.9
    gatsby-source-filesystem: ^2.0.43 => 2.0.43
    gatsby-transformer-sharp: ^2.1.21 => 2.1.21
  npmGlobalPackages:
    gatsby: 2.10.0
@andrejpavlovic
Copy link
Author

The workaround for now for me was to directly edit gatsby-site/node_modules/gatsby/dist/redux/actions/public.js and replace the following code:

const trueComponentPath = slash(truePath(page.component))

with

        let trueComponentPath = page.component;
        try {
          trueComponentPath = slash(truePath(page.component));
        } catch (e) {}

@waltercruz
Copy link
Contributor

I'm facing this problem too!

@waltercruz
Copy link
Contributor

maybe this issue should be handled on true-case-path? There's a issue opened, from a long time ago:

barsh/true-case-path#2

waltercruz added a commit to waltercruz/gatsby that referenced this issue Jul 18, 2019
@moonmeister moonmeister added 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 type: upstream Issues outside of Gatsby's control, caused by dependencies labels Jul 20, 2019
waltercruz added a commit to waltercruz/gatsby that referenced this issue Jul 26, 2019
waltercruz added a commit to waltercruz/gatsby that referenced this issue Jul 26, 2019
@gatsbot
Copy link

gatsbot bot commented Aug 10, 2019

Hiya!

This issue has gone quiet. Spooky quiet. 👻

We get a lot of issues, so we currently close issues after 30 days of inactivity. It’s been at least 20 days since the last update here.

If we missed this issue or if you want to keep it open, please reply here. You can also add the label "not stale" to keep this issue open!

As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contributefor more information about opening PRs, triaging issues, and contributing!

Thanks for being a part of the Gatsby community! 💪💜

@gatsbot gatsbot bot added the stale? Issue that may be closed soon due to the original author not responding any more. label Aug 10, 2019
@andrejpavlovic
Copy link
Author

not stale

@m-allanson m-allanson added not stale and removed stale? Issue that may be closed soon due to the original author not responding any more. labels Aug 12, 2019
@sidharthachatterjee
Copy link
Contributor

Published in gatsby@2.13.66

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 type: upstream Issues outside of Gatsby's control, caused by dependencies
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants