decaporg / one-click-hugo-cms

Hugo template with Decap CMS
https://master-template-one-click-hugo-cms.netlify.app
MIT License
499 stars 298 forks source link

Newly created Git repository with does not deploy to Netlify (error: spawn EACCES) #111

Closed DotTech closed 5 years ago

DotTech commented 5 years ago

I have deployed a clone of this repository to Netlify and it worked fine.
Then I decided I wanted to start a fresh Git repository, so I created a new one, placed all the code from the cloned repo into the newly created repo and tried to deploy; it fails.

During the build, Netlify returns an error while trying to execute Hugo:

10:03:37 PM: Starting 'hugo'...
10:03:37 PM: [21:03:37]
10:03:37 PM: 'hugo' errored after 14 ms
10:03:37 PM: [21:03:37]
10:03:37 PM: Error: spawn EACCES
10:03:37 PM:     at ChildProcess.spawn (internal/child_process.js:313:11)
10:03:37 PM:     at Object.exports.spawn (child_process.js:508:9)
10:03:37 PM:     at buildSite (/opt/build/repo/gulpfile.babel.js:81:13)
10:03:37 PM:     at Gulp.<anonymous> (/opt/build/repo/gulpfile.babel.js:23:27)
10:03:37 PM:     at module.exports (/opt/build/repo/node_modules/orchestrator/lib/runTask.js:34:7)
10:03:37 PM:     at Gulp.Orchestrator._runTask (/opt/build/repo/node_modules/orchestrator/index.js:273:3)
10:03:37 PM:     at Gulp.Orchestrator._runStep (/opt/build/repo/node_modules/orchestrator/index.js:214:10)
10:03:37 PM:     at Gulp.Orchestrator.start (/opt/build/repo/node_modules/orchestrator/index.js:134:8)
10:03:37 PM:     at /opt/build/repo/node_modules/gulp/bin/gulp.js:129:20
10:03:37 PM:     at _combinedTickCallback (internal/process/next_tick.js:132:7)

I have compared the code from the 2 repositories (cloned and new) and it's 100% the same.
The clone is found here: https://github.com/DotTech/one-click-hugo-cms
The created repo here: https://github.com/DotTech/hugo-test

Googling for the spawn EACCES error didn't give me any results (at least not in the context of Netlify or Hugo).
Hope that someone here can point me in the right direction?

The "solution" for now is to just clone the repository and continue to work on that, but I would like to start fresh with one single commit and not have all the history.

talves commented 5 years ago

@DotTech I personally remove the hugo bin folder and this is one of the reasons why I would do so. You will have to run your own local version of Hugo to have the command work for development.

See my answer on StackOverflow.

DotTech commented 5 years ago

Thank you @talves! Removing the bin folder solves the build issue. I still don't understand why it does work with the cloned repository... But at least I have a way of getting it to work now :)

talves commented 5 years ago

It does sound a little odd to me also.

DotTech commented 5 years ago

I have found a solution that allows Hugo to stay in the repo without interfering with the Netlify build:

// Replace this line:
// const hugoBin = `./bin/hugo.${process.platform === "win32" ? "exe" : process.platform}`;

// With this:
var hugoBin = `./bin/hugo.${process.platform === "win32" ? "exe" : process.platform}`;
if (process.env.HUGO_VERSION) {
  hugoBin = 'hugo'
}

That way the bin folder Hugo will be used locally and ignored during a Netlify build.
I'll try to create a pull request for this.

talves commented 5 years ago

This is a good way to handle it. Keeps a unique version of Hugo in each project for local and targets the correct version of Hugo for Netlify. Would allow for multiple versions to run on your local machine, when needed.

Gives me an idea to run diff versions local out of a global scope (install dir). hugo/root/location/0.45/hugo.exe

if (process.env.HUGO_VERSION) {
  if (process.env.NODE_ENV === 'development') {
    hugoBin = path.resolve(HugoRootLocation, process.env.HUGO_VERSION, 'hugo')
  } else {
    hugoBin = 'hugo'
  }
}