NativeScript / NativeScript/nativescript-cli

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

オープン
#5,368 コメント 7 件 リアクション 2 件 担当者 1 名 GitHub で見る

@rigor789 がすでに取り組んでいます。

2020年9月4日 から。

主要言語
JavaScript
スター
1.1k
フォーク
204
平均マージ
1日 9時間
マージ済み PR(30日)
8

説明

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;
        }
    });
}

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。