hyperledger / cacti

Hyperledger Cacti is a new approach to the blockchain interoperability problem
https://wiki.hyperledger.org/display/cactus
Apache License 2.0
338 stars 278 forks source link

docs(examples/supply-chain): fix yarn --no-lockfile #2721

Closed ArchanaArige closed 7 months ago

ArchanaArige commented 11 months ago

Describe the bug Facing the below error while trying to run supply chain example locally. Reference https://github.com/hyperledger/cacti/tree/main/examples/supply-chain-app A clear and concise description of what the bug is. The issue is at step : yarn start:example-supply-chain. The issue is observed at the last step i.e "yarn start"

image

To Reproduce clone the repository cd cactus from the root of the repository run the below commands: npm run enable-corepack npm run configure yarn start:example-supply-chain

Steps to reproduce the behavior on a successfully deployed Hyperledger Cactus cluster.

Expected behavior The application should be build successfully without any errors A clear and concise description of what you expected to happen.

Logs/Stack traces

Can help maintainers identify root causes

Screenshots YN0000: │ Some peer dependencies are incorrectly met; run yarn explain peer-requirements for details, where is the six-letter p-prefixed code image

If applicable, add screenshots to help explain your problem.

Cloud provider or hardware configuration: Are you running the software on a dev machine or somewhere in the cloud? cloud Operating system name, version, build:

Use this command: printf "$(uname -srm)\n$(cat /etc/os-release)\n"

For example

$ printf "$(uname -srm)\n$(cat /etc/os-release)\n"
 Icon name: computer-vm
 Chassis: vm
Virtualization: xen
Operating System: Ubuntu 22.04.1 LTS
 Kernel: Linux 5.15.20-051520-generic
 Architecture: x86-64
 Hardware Vendor: Xen
  Hardware Model: HVM domU

Hyperledger Cactus release version or commit (git rev-parse --short HEAD):

Either a semantic version of the release you are using such as 1.0.0 or a git commit hash if you are directly working with code from the git repository.

Hyperledger Cactus Plugins/Connectors Used

Additional context node version: v16.20.1 npm version: v8.5.0 yarn version: v3.6.0 with yarn 3.6 , there is no flag suppport ("--no-lockfile"). So just ran yarn install. Prior to this step created yarn.lock file.

Add any other context about the problem here.

ArchanaArige commented 11 months ago

I have tried with the recommended node version too 16.14.2. Below is the error. [2/4] Fetching packages... error @lerna-lite/cli@2.5.1: The engine "node" is incompatible with this module. Expected version ">=16.15.0". Got "16.14.2" error Found incompatible module. info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

ArchanaArige commented 11 months ago

Facing the issue also while trying the below method: [Debugging the Example Application Locally]

:~/cactus/examples/supply-chain-app$ cd /home/ubuntu/cactus/examples/supply-chain-app/ ; /usr/bin/env TS_NODE_PROJECT=/home/ubuntu/cactus/tsconfig.json 'NODE_OPTIONS=--require /home/ubuntu/.vscode-server/bin/2ccd690cbff1569e4a83d7c43d45101f817401dc/extensions/ms-vscode.js-debug/src/bootloader.js --inspect-publish-uid=http' 'VSCODE_INSPECTOR_OPTIONS={"inspectorIpc":"/tmp/node-cdp.574342-9feaa5b1-19.sock","deferredMode":false,"waitForDebugger":"","execPath":"/home/ubuntu/.nvm/versions/node/v12.22.12/bin/node","onlyEntrypoint":false,"autoAttachMode":"always","mandatePortTracking":true,"fileCallback":"/tmp/node-debug-callback-d5884d3b970a9c31"}' /home/ubuntu/.nvm/versions/node/v12.22.12/bin/node -r ts-node/register -r dotenv/config ../cactus-example-supply-chain-backend/src/main/typescript/supply-chain-app-cli.ts dotenv_config_path=process.env Debugger attached. /home/ubuntu/cactus/packages/cactus-plugin-ledger-connector-fabric/node_modules/fabric-network/lib/gateway.js:362 if (!this.options?.wallet) { ^

SyntaxError: Unexpected token '.' at compileFunction () at wrapSafe (internal/modules/cjs/loader.js:915:16) at Module._compile (internal/modules/cjs/loader.js:963:27) at Module._extensions..js (internal/modules/cjs/loader.js:1027:10) at Object.require.extensions. [as .js] (/home/ubuntu/cactus/node_modules/ts-node/src/index.ts:1608:43) at Module.load (internal/modules/cjs/loader.js:863:32) at Function.Module._load (internal/modules/cjs/loader.js:708:14) at Module.require (internal/modules/cjs/loader.js:887:19) at require (internal/modules/cjs/helpers.js:74:18) at Object. (/home/ubuntu/cactus/packages/cactus-plugin-ledger-connector-fabric/node_modules/fabric-network/index.js:281:26) at Module._compile (internal/modules/cjs/loader.js:999:30) at Module._extensions..js (internal/modules/cjs/loader.js:1027:10) at Object.require.extensions. [as .js] (/home/ubuntu/cactus/node_modules/ts-node/src/index.ts:1608:43) at Module.load (internal/modules/cjs/loader.js:863:32) at Function.Module._load (internal/modules/cjs/loader.js:708:14) at Module.require (internal/modules/cjs/loader.js:887:19) at require (internal/modules/cjs/helpers.js:74:18) at Object. (/home/ubuntu/cactus/packages/cactus-plugin-ledger-connector-fabric/src/main/typescript/plugin-ledger-connector-fabric.ts:15:1) at Module._compile (internal/modules/cjs/loader.js:999:30) at Module._extensions..js (internal/modules/cjs/loader.js:1027:10) at Object.require.extensions. [as .js] (/home/ubuntu/cactus/node_modules/ts-node/src/index.ts:1608:43) at Module.load (internal/modules/cjs/loader.js:863:32) Waiting for the debugger to disconnect...

image
petermetz commented 11 months ago

@ArchanaArige Thank you for reporting this! I managed to reproduce it just now and hopefully we can fix it soon!

petermetz commented 11 months ago

@aldousalvarez Acceptance Criteria and some notes to (potentially) help with the fix:

  1. The container image versions that the example is using are quite old. We should try to make them work with the newer ones, especially to upgrade to Fabric 2.x from 1.x which is very old and not supported anymore.
  2. The --no-lockfile option no longer exists in the newer versions of Yarn that we are using nowadays so that has to be removed completely from the docs and the scripts as well.
  3. The current setup is quite brittle (this is easily the 10th time that we have some bug in the supply chain app example) so to make it more easy to work with and also to satisfy 2) in a way that does not need us to fight the package manager (yarn) on principles; I would completely refactor the instructions in a way that the examples/supply-chain-app/package.json is deleted and the other files are moved to examples/cactus-example-supply-chain-backend/ and the README.md of the examples/supply-chain-app/ is merged into the readme of examples/cactus-example-supply-chain-backend/ as well. Finally when it's basically empty, just delete the old folder of examples/supply-chain-app (and again make sure to update the docs everywhere about this and the scripts in the examples/cactus-example-supply-chain-backend/package.json are there so that people can launch the example with a single command still but they don't have to do an out-of-bounds yarn install anymore (e.g. the steps are just npm run enable-corepack && npm run configure && yarn start:example-supply-chain and the last script calls directly into the package.json of examples/cactus-example-supply-chain-backend/

Update 2023-11-29: @aldousalvarez Very sorry about my silly typos! I've refactored it just now to have cactus-example-supply-chain-* everywhere and no mention of the carbon accounting example in this context

ArchanaArige commented 11 months ago

Thanks alot @petermetz .

Meanwhile, I have also tried bringing up the supply chain example using docker.The application is up but I am unable to post the data on submit.

bamboo_harvest_1

continued to the next step by tried checking in "bookshelf details". since the data wasnt posted, i couldnt able to get the list of bamboo harvest id.

bookshelf

Followed https://github.com/hyperledger/cacti/blob/main/examples/supply-chain-app/README.md. Is there anything am i missing in execution?

petermetz commented 11 months ago

Thanks alot @petermetz .

Meanwhile, I have also tried bringing up the supply chain example using docker.The application is up but I am unable to post the data on submit. bamboo_harvest_1 continued to the next step by tried checking in "bookshelf details". since the data wasnt posted, i couldnt able to get the list of bamboo harvest id.

bookshelf

Followed https://github.com/hyperledger/cacti/blob/main/examples/supply-chain-app/README.md. Is there anything am i missing in execution?

@ArchanaArige Last time I've seen that issue it was because I was using the 0.0.0.0 IP in the URL instead of 127.0.0.1 (it's a browser security feature to block the requests coming from the 0.0.0.0 host.

Could you double check if you used the exact URL that is in the docs or did you take the one that the CLI prints? (the latter is wrong, we have that tracked here: https://github.com/hyperledger/cacti/issues/2390)

ArchanaArige commented 11 months ago

Thanks alot @petermetz . Meanwhile, I have also tried bringing up the supply chain example using docker.The application is up but I am unable to post the data on submit. bamboo_harvest_1 continued to the next step by tried checking in "bookshelf details". since the data wasnt posted, i couldnt able to get the list of bamboo harvest id.

bookshelf

Followed https://github.com/hyperledger/cacti/blob/main/examples/supply-chain-app/README.md. Is there anything am i missing in execution?

@ArchanaArige Last time I've seen that issue it was because I was using the 0.0.0.0 IP in the URL instead of 127.0.0.1 (it's a browser security feature to block the requests coming from the 0.0.0.0 host.

Could you double check if you used the exact URL that is in the docs or did you take the one that the CLI prints? (the latter is wrong, we have that tracked here: #2390)

I am running the supply chain example on AWS-ec2 instance. I have enabled the port 3200 in AWS(security group) and trying to access it from my local machine using instance-public-ip:port. I have enabled the javascript in the browser too.

petermetz commented 11 months ago

Thanks alot @petermetz . Meanwhile, I have also tried bringing up the supply chain example using docker.The application is up but I am unable to post the data on submit. bamboo_harvest_1 continued to the next step by tried checking in "bookshelf details". since the data wasnt posted, i couldnt able to get the list of bamboo harvest id.

bookshelf

Followed https://github.com/hyperledger/cacti/blob/main/examples/supply-chain-app/README.md. Is there anything am i missing in execution?

@ArchanaArige Last time I've seen that issue it was because I was using the 0.0.0.0 IP in the URL instead of 127.0.0.1 (it's a browser security feature to block the requests coming from the 0.0.0.0 host. Could you double check if you used the exact URL that is in the docs or did you take the one that the CLI prints? (the latter is wrong, we have that tracked here: #2390)

I am running the supply chain example on AWS-ec2 instance. I have enabled the port 3200 in AWS(security group) and trying to access it from my local machine using instance-public-ip:port. I have enabled the javascript in the browser too.

@ArchanaArige No worries, thank you for explaining your setup! Could you please also open the dev tools of the browser and see what (if any) error logs are there on the Javascript console/network tab? That might help us narrow it down further.

ArchanaArige commented 11 months ago

Thanks alot @petermetz . Meanwhile, I have also tried bringing up the supply chain example using docker.The application is up but I am unable to post the data on submit. bamboo_harvest_1 continued to the next step by tried checking in "bookshelf details". since the data wasnt posted, i couldnt able to get the list of bamboo harvest id.

bookshelf

Followed https://github.com/hyperledger/cacti/blob/main/examples/supply-chain-app/README.md. Is there anything am i missing in execution?

@ArchanaArige Last time I've seen that issue it was because I was using the 0.0.0.0 IP in the URL instead of 127.0.0.1 (it's a browser security feature to block the requests coming from the 0.0.0.0 host. Could you double check if you used the exact URL that is in the docs or did you take the one that the CLI prints? (the latter is wrong, we have that tracked here: #2390)

I am running the supply chain example on AWS-ec2 instance. I have enabled the port 3200 in AWS(security group) and trying to access it from my local machine using instance-public-ip:port. I have enabled the javascript in the browser too.

@ArchanaArige No worries, thank you for explaining your setup! Could you please also open the dev tools of the browser and see what (if any) error logs are there on the Javascript console/network tab? That might help us narrow it down further.

Hi @petermetz Please find the logs below: In the request URL , I see "localhost", but ideally it should be the "Instance IP ", however the referer is pointing to instance IP.Please note that i have mapped 3200 port to 3201. image

image

screenshot from console tab:

image

petermetz commented 11 months ago

@ArchanaArige Oh, okay, new theory: You are running the app on one machine and the browser on another, but the web app isn't robust enough to deal with that (it always hits localhost). So my idea would be to work around it is to do an SSH tunnel to your server from your localhost so that the remote IP is not in play at all. If you use VSCode port mapping [1] maybe this can be done just by clicking around on the VSCode UI, but if not, then you should be able to do it via vanilla SSH [2]

[1] https://code.visualstudio.com/docs/remote/ssh#_forwarding-a-port-creating-ssh-tunnel [2] https://serverfault.com/a/1004531