question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Since NS7 update, some plugins fail building with "Error: spawn ./gradlew EACCES"

See original GitHub issue

I personally haven’t tested it on Windows, so there might not be any problems on that platform because the build scripts are handled separately.

Since the update to NS7 a few days ago, there have been multiple people on the NSCommunity Slack reporting this. I personally have encountered the problem in relation to nativescript-socket.io, but it’s not specific to it, as it actually boils down to an issue in the CLI.

The problem is two-fold: first, the EACCES error is caused by the gradlew file not being being marked as executable. Once this is fixed, errors relating to the carriage return character start popping up. The issue now is that the gradlew file uses windows style newline (\r\n) instead of *nix style newline (\n). I’ve implemented a quick and dirty fix, but this only solves the symptoms, it doesn’t solve the problem at the root cause as I’m not familiar enough with NS to know which part of the tooling generates the gradlew file when building plugins.

The temporary fix involves editing a file in the NS CLI:

  1. in the global node_modules folder (unless NS is locally installed under the project’s devDependencies), find nativescript/lib/services/android-plugin-build-service.js
  2. anywhere at the top of the file (maybe between lines 19-24 for consistency’s sake) add const fs = require("fs");
  3. at line 413 (formerly 412 before the above addition) add:
if (!this.$hostInfo.isWindows) {
    const gradleFile = path.join(pluginBuildSettings.pluginDir, gradlew);
    let content = fs.readFileSync(gradleFile, {encoding:'utf8', flag:'r'});
    content = content.replace(/\r/g, '');
    fs.writeFileSync(gradleFile, content);
    fs.chmodSync(gradleFile, 0o755, (err) => {
        if (err) {
            console.log("Error changing setting gradlew as executable");
            throw err;
        }
    });
}

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:2
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
rigor789commented, Sep 8, 2020

Yep, fixes have been merged to master, and will release a regular version very soon - until then, feel free to use the next tag, or the full version mentioned above.

0reactions
rigor789commented, Sep 8, 2020

I’m not sure the latest pr #5382 is really necessary after adjusting the repo’s .gitattributes the line endings and file attributes should remain intact regardless of the OS the repo is checked out from. But I guess it doesn’t hurt as an extra precaution.

Read more comments on GitHub >

github_iconTop Results From Across the Web

163 - Stack Overflow
I fixed this problem with: chmod 755 android/gradlew. the chmod command sets the permissions of files or directories.
Read more >
Gradle Enterprise Gradle Plugin User Manual
Failed background build scan uploads; Slow resolution of host name; Late application ... The Gradle Enterprise Gradle plugin enables integration with Gradle ...
Read more >
Gradle 7.6 Release Notes
The Gradle team is excited to announce Gradle 7.6. This release includes building and running code with Java 19, a flag to rerun...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found