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 patching es3.js with GNU patch version 2.7.5 #126

Open
JohanBaskovec opened this issue Jun 5, 2019 · 1 comment
Open

Error when patching es3.js with GNU patch version 2.7.5 #126

JohanBaskovec opened this issue Jun 5, 2019 · 1 comment

Comments

@JohanBaskovec
Copy link

Hi

I tried using elemental2 with j2cl. My BUILD file contains this config :

load("@com_google_j2cl//build_defs:rules.bzl", "j2cl_library")

j2cl_library(
    name = "javafrontendlib",
    srcs = glob([
        "*.java",
        "*.js",
    ]),
    deps = [
        "//src/main/java/j2clhelloworld/common",
        "@com_google_elemental2//:elemental2-core-j2cl",
    ],
)

When building the project, an error occured during the execution of java/elemental2/core:es3_patched:

bazel build //src/main/java/j2clhelloworld/javafrontend:javafrontendlib --incompatible_depset_union=false
WARNING: /home/johan/.cache/bazel/_bazel_johan/378033271060b971d17254500543d94e/external/bazel_tools/tools/jdk/BUILD:121:1: in alias rule @bazel_tools//tools/jdk:jar: target '@bazel_tools//tools/jdk:jar' depends on deprecated target '@local_jdk//:jar': Don't depend on targets in the JDK workspace; use @bazel_tools//tools/jdk:current_java_runtime instead (see https://github.com/bazelbuild/bazel/issues/5594)
WARNING: /home/johan/.cache/bazel/_bazel_johan/378033271060b971d17254500543d94e/external/com_google_jsinterop_generator/third_party/BUILD:62:1: in alias rule @com_google_jsinterop_generator//third_party:jar: target '@com_google_jsinterop_generator//third_party:jar' depends on deprecated target '@local_jdk//:jar': Don't depend on targets in the JDK workspace; use @bazel_tools//tools/jdk:current_java_runtime instead (see https://github.com/bazelbuild/bazel/issues/5594)
WARNING: /home/johan/.cache/bazel/_bazel_johan/378033271060b971d17254500543d94e/external/com_google_elemental2/java/elemental2/core/BUILD:38:1: in _jsinterop_generator rule @com_google_elemental2//java/elemental2/core:core__internal_src_generated: target '@com_google_elemental2//java/elemental2/core:core__internal_src_generated' depends on deprecated target '@local_jdk//:jar': Don't depend on targets in the JDK workspace; use @bazel_tools//tools/jdk:current_java_runtime instead (see https://github.com/bazelbuild/bazel/issues/5594)
INFO: Analyzed target //src/main/java/j2clhelloworld/javafrontend:javafrontendlib (107 packages loaded, 1860 targets configured).
INFO: Found 1 target...
INFO: From Executing genrule @com_google_elemental2//java/elemental2/core:es3_patched:
patching file bazel-out/k8-fastbuild/bin/external/com_google_elemental2/java/elemental2/core/es3_patched.js (read from external/com_google_closure_compiler/externs/es3.js)
Hunk #1 failed at 2052
Hunk #2 failed at 2063
Hunk #3 failed at 2071

I was able to fix the error by updating GNU patch to 2.7.6 (I downloaded it and built it from ftp://ftp.gnu.org/gnu/patch because it's not in Linux Mint 18.2 repository).

The error was caused by patch 2.7.5 apparently not supporting patching files in a different folder. This failed:

patch src/main/java/j2clhelloworld/pathellxternalfiletest/es3.js -i src/main/java/j2clhelloworld/pathexternalfiletest/es3.js.diff -o bazel-out/k8-fastbuild/bin/src/main/java/j2clhelloworld/pathexternalfiletest/es3_patched.js
patching file bazel-out/k8-fastbuild/bin/src/main/java/j2clhelloworld/pathexternalfiletest/es3_patched.js (read from src/main/java/j2clhelloworld/pathellxternalfiletest/es3.js)
Hunk #1 FAILED at 2053.
Hunk #2 FAILED at 2064.
Hunk #3 FAILED at 2072.
3 out of 3 hunks FAILED -- saving rejects to file bazel-out/k8-fastbuild/bin/src/main/java/j2clhelloworld/pathexternalfiletest/es3_patched.js.rej

When removing the -o option, it says the file name is invalid:

patch src/main/java/j2clhelloworld/pathellxternalfiletest/es3.js -i src/main/java/j2clhelloworld/pathexternalfiletest/es3.js.diff
Invalid file name src/main/java/j2clhelloworld/pathellxternalfiletest/es3.js -- skipping patch

but this worked :

patch es3.js -i src/main/java/j2clhelloworld/pathexternalfiletest/es3.js.diff
patching file es3.js
Hunk #1 succeeded at 2052 (offset -1 lines).
Hunk #2 succeeded at 2063 (offset -1 lines).
Hunk #3 succeeded at 2071 (offset -1 lines).

After upgrading to 2.7.6, they both work, and I'm able to build my j2cs project.

@jDramaix
Copy link
Member

jDramaix commented Jun 7, 2019

This kind of error can happen when there is a synchronization issue between extern files (that are not provided by this repository) and the diff file.

That being said, after reading your logs when you tried to patch manually the files, it seems there is an error in the path to the js file:
src/main/java/j2clhelloworld/pathellxternalfiletest/es3.js instead of src/main/java/j2clhelloworld/pathexternalfiletest/es3.js
Could you confirm is not an error?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants