hashgraph / hedera-sdk-js

Hedera™ Hashgraph SDK for JavaScript/TypeScript
https://docs.hedera.com/guides/docs/sdks
Apache License 2.0
274 stars 145 forks source link

Build operation does not work as expected #2143

Open Neurone opened 8 months ago

Neurone commented 8 months ago

Description

When running task build the process stop when searching for src/proto/mirror/basic_types.proto. That files is actually not in that folder, and it is instead in src/proto/serivces/basic_types.proto. I assume the problem is with the import done by src/proto/mirror/consensus_service.proto.

Steps to reproduce

❯ git clone https://github.com/hashgraph/hedera-sdk-js.git
Cloning into 'hedera-sdk-js'...
remote: Enumerating objects: 48355, done.
remote: Counting objects: 100% (2585/2585), done.
remote: Compressing objects: 100% (1182/1182), done.
remote: Total 48355 (delta 1822), reused 2032 (delta 1395), pack-reused 45770
Receiving objects: 100% (48355/48355), 32.49 MiB | 2.69 MiB/s, done.
Resolving deltas: 100% (41558/41558), done.

❯ cd hedera-sdk-js

❯ git checkout v2.41.0
Note: switching to 'v2.41.0'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

  git switch -c <new-branch-name>

Or undo this operation with:

  git switch -

Turn off this advice by setting config variable advice.detachedHead to false

HEAD is now at 72a0f1cd address books update

❯ task build
Submodule 'packages/proto/src/proto' (https://github.com/hashgraph/hedera-protobufs.git) registered for path 'src/proto'
Cloning into '/Users/giuseppebertone/workspace/hedera/hedera-sdk-js/packages/proto/src/proto'...
Submodule path 'src/proto': checked out '6eea2ef2c9a15bb99b0e717da31a7cf6a0f3e475'
/Users/giuseppebertone/workspace/hedera/hedera-sdk-js/packages/proto/node_modules/.pnpm/protobufjs-cli@1.1.2_protobufjs@7.2.6/node_modules/protobufjs-cli/pbjs.js:254
            throw err;
            ^                  ./packages/proto/src/proto/mirror/consensus_service.proto

Error: ENOENT: no such file or directory, open 'src/proto/mirror/basic_types.proto'
    at Object.openSync (node:fs:596:3)
    at Object.readFileSync (node:fs:464:35)
    at fetch (/Users/giuseppebertone/workspace/hedera/hedera-sdk-js/packages/proto/node_modules/.pnpm/protobufjs@7.2.6/node_modules/protobufjs/src/root.js:173:34)
    at process (/Users/giuseppebertone/workspace/hedera/hedera-sdk-js/packages/proto/node_modules/.pnpm/protobufjs@7.2.6/node_modules/protobufjs/src/root.js:133:29)
    at fetch (/Users/giuseppebertone/workspace/hedera/hedera-sdk-js/packages/proto/node_modules/.pnpm/protobufjs@7.2.6/node_modules/protobufjs/src/root.js:179:13)
    at Root.load (/Users/giuseppebertone/workspace/hedera/hedera-sdk-js/packages/proto/node_modules/.pnpm/protobufjs@7.2.6/node_modules/protobufjs/src/root.js:207:13)
    at Root.loadSync (/Users/giuseppebertone/workspace/hedera/hedera-sdk-js/packages/proto/node_modules/.pnpm/protobufjs@7.2.6/node_modules/protobufjs/src/root.js:248:17)
    at Object.main (/Users/giuseppebertone/workspace/hedera/hedera-sdk-js/packages/proto/node_modules/.pnpm/protobufjs-cli@1.1.2_protobufjs@7.2.6/node_modules/protobufjs-cli/pbjs.js:245:18)
    at Object.<anonymous> (/Users/giuseppebertone/workspace/hedera/hedera-sdk-js/packages/proto/node_modules/.pnpm/protobufjs-cli@1.1.2_protobufjs@7.2.6/node_modules/protobufjs-cli/bin/pbjs:4:16)
    at Module._compile (node:internal/modules/cjs/loader:1356:14) {
  errno: -2,
  syscall: 'open',
  code: 'ENOENT',
  path: 'src/proto/mirror/basic_types.proto'
}

Node.js v18.19.1
task: Failed to run task "build": exit status 1

Additional context

❯ nvm --version
0.39.1

❯ npm --version
10.2.4

❯ node --version
v18.19.1

❯ task --version
Task version: v3.34.1 (h1:yAAxUM54zoaHv+OtDnGgkWSVeiRuaOCn1lPUXPQQA0o=)

❯ uname -a
Darwin mcfly.local 23.3.0 Darwin Kernel Version 23.3.0: Wed Dec 20 21:30:27 PST 2023; root:xnu-10002.81.5~7/RELEASE_ARM64_T8103 arm64

Hedera network

other

Version

v2.41.0

Operating system

macOS

agadzhalov commented 8 months ago

Hi @Neurone. Me and @svetoslav-nikol0v both tried to reproduce the problem but for our cases the problem doesn't occur. Can you give us more context on what exactly are you trying to do and why. Also a step by step guide would be very useful.

From my side what I did

  1. git fetch --all --tags
  2. git checkout v2.41.0
  3. task build
  4. Successful image

❯ npm --version 9.5.1 ❯ node --version v18.15.0 ❯ task --version Task version: v3.33.1 (h1:JJSRANHH7RQrr5Z2CTvSnTH7iWlfBlKV2W2O0JiZoLk=)

Neurone commented 8 months ago

Hi @agadzhalov I'm trying to build the SDK. The steps I followed and the error are in the description. I think the problem is in the import to the proto files.

Did you try from a clean repo?

Neurone commented 8 months ago

I found the problem and probably the reason you don't see it if you are on Linux. I suspect this is also the reason behind some strange behaviors we are experiencing recently (i.e., https://github.com/hashgraph/hedera-sdk-js/issues/2140 or https://github.com/hashgraph/hedera-sdk-js/issues/2138).

agadzhalov commented 8 months ago

From what I understood it works for you on Ubuntu, but it fails with macOS? Is that correct? Also I've tried to reproduce it on macOS, but still couldn't. Following these steps can you tell me if I am missing something to reproduce it?

  1. Using macOS 12.6.3
  2. git clone git@github.com:hashgraph/hedera-sdk-js.git
  3. git checkout v2.41.0
  4. Checked the dependency in package.json is protobufjs@7.2.5
  5. pnpm install protobufjs@7.2.6
  6. task build -> still successful
Neurone commented 8 months ago

Yes, I can build on Ubuntu if I use protobufjs@7.2.5, but I cannot build on Ubuntu nor MacOS if I update to protobufjs@7.2.6. If I move back to protobufjs@7.2.5 I can build also on MacOS, and that means we are building the protobufs not correctly.

To apply the change, it you need to install the dependency from the ./packages/proto folder, not the root folder.

agadzhalov commented 8 months ago

Thank you for the detailed explanation, we managed to reproduce it. Soon we will start investigating it