web3j icon indicating copy to clipboard operation
web3j copied to clipboard

Looks like there was an error while trying to download web3j source

Open noob-programmer1 opened this issue 10 months ago • 7 comments

Issue Description

I am trying to install and use Web3j CLI, but I am encountering multiple issues: When running: curl -L get.web3j.io | sh && source ~/.web3j/source.sh I get the error:

Looks like there was an error while trying to download web3j
source: no such file or directory: /Users/Abhi/.web3j/source.sh

After manually downloading Web3j CLI and attempting to generate code using:

web3j generate solidity \
  -a contract/build/X.abi \
  -b contract/build/X.bin \
  -o contract/generated \
  -p com.example.contract

I receive the following error:

Exception in thread "main" java.lang.IllegalArgumentException: version must not be null
    at com.github.zafarkhaja.semver.Version$Validators.nonNullOrThrow(Version.java:1383)
    at com.github.zafarkhaja.semver.Version$Validators.nonNull(Version.java:1357)
    at com.github.zafarkhaja.semver.Version.parse(Version.java:410)

Issue Context

Web3j Version: 1.6.3 OS: macOS Installation Attempted: Both automatic (curl) and manual Expected Behavior: Web3j should install properly and allow code generation Actual Behavior: Installation fails, and code generation throws an error

Would appreciate any guidance on resolving this. 🚀

noob-programmer1 avatar Mar 17 '25 16:03 noob-programmer1

I have same problem, windows 11 + WSL2(ubuntu 22.04) + jdk 17

problem 1:

curl -L get.web3j.io | sh && source ~/.web3j/source.sh

may should be

curl -L get.web3j.io | bash && source ~/.web3j/source.sh

problem 2:

Checksum verification passed!
Your current java version is 17.0.14
Your Java version is compatible with Web3j CLI.
Downloading Web3j ...
Looks like there was an error while trying to download web3j
-bash: /root/.web3j/source.sh: No such file or directory

formingform avatar Mar 26 '25 09:03 formingform

Hello,

Same problem in GitHub Action :

Run curl -L get.web3j.io | sh && source ~/.web3j/source.sh
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100   167  100   167    0     0   1545      0 --:--:-- --:--:-- --:--:--  1560

100  7522  100  7522    0     0  50709      0 --:--:-- --:--:-- --:--:-- 50709
Running in-memory execution
sh: 12: [[: not found
Checksum verification passed!
Your current java version is 17.0.14
Your Java version is compatible with Web3j CLI.
Downloading Web3j ...
Looks like there was an error while trying to download web3j
/home/runner/work/_temp/f34d943d-2129-4bfa-8345-0dde788119f5.sh: line 1: /home/runner/.web3j/source.sh: No such file or directory
Error: Process completed with exit code 1.

stephane-mori avatar Mar 29 '25 23:03 stephane-mori

At this address : get.web3j.io, we can find the install script. It contains this block :

install_web3j() {
  echo "Downloading Web3j ..."
  mkdir -p "$HOME/.web3j"
  if [ "$(curl --write-out "%{http_code}" --silent --output /dev/null "https://github.com/hyperledger-web3j/web3j-cli/releases/download/v${web3j_version}/web3j-cli-shadow-${web3j_version}.tar")" -eq 302 ]; then
    curl -# -L -o "$HOME/.web3j/web3j-cli-shadow-${web3j_version}.tar" "https://github.com/hyperledger-web3j/web3j-cli/releases/download/v${web3j_version}/web3j-cli-shadow-${web3j_version}.tar"
    echo "Installing Web3j..."
    echo "https://github.com/hyperledger-web3j/web3j-cli/releases/download/v${web3j_version}/web3j-cli-shadow-${web3j_version}.tar"
    tar -xf "$HOME/.web3j/web3j-cli-shadow-${web3j_version}.tar" -C "$HOME/.web3j"
    echo "export PATH=\$PATH:$HOME/.web3j" >"$HOME/.web3j/source.sh"
    chmod +x "$HOME/.web3j/source.sh"
    echo "Removing downloaded archive..."
    rm "$HOME/.web3j/web3j-cli-shadow-${web3j_version}.tar"
  else
    echo "Looks like there was an error while trying to download web3j"
    exit 0
  fi
}

If I test curl --write-out "%{http_code}" --silent --output /dev/null "https://github.com/hyperledger-web3j/web3j-cli/releases/download/v${web3j_version}/web3j-cli-shadow-${web3j_version}.tar" with version 1.6.2 or 1.6.3, I obtain 301 (Moved Permanently). Script expect 302 (Found)

stephane-mori avatar Mar 29 '25 23:03 stephane-mori

I made a fix : https://github.com/LFDT-web3j/web3j-installer/pull/22

stephane-mori avatar Mar 30 '25 00:03 stephane-mori

Until the merge of the fix, you can use this command : curl -L get.web3j.io | sed 's/hyperledger/LFDT/g' | sh && source ~/.web3j/source.sh

stephane-mori avatar Mar 30 '25 00:03 stephane-mori

Now fixed : https://github.com/LFDT-web3j/web3j-installer/pull/22. Issue can be closed.

stephane-mori avatar Apr 12 '25 16:04 stephane-mori

I still see this issue:

└>curl -L get.web3j.io | sh && source ~/.web3j/source.sh
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   167  100   167    0     0   4859      0 --:--:-- --:--:-- --:--:--  4911
100  7487  100  7487    0     0  97838      0 --:--:-- --:--:-- --:--:-- 97838
Running in-memory execution
Checksum verification passed!
Your current java version is 24.0.1
Your Java version is compatible with Web3j CLI.
Downloading Web3j ...
######################################################################## 100.0%
Installing Web3j...
https://github.com/LFDT-web3j/web3j-cli/releases/download/v1.7.0/web3j-cli-shadow-1.7.0.tar
Removing downloaded archive...
Skipped update of /home/xxx/.bashrc (source string already present)
Skipped update of /home/xxx/.bash_profile (source string already present)
Skipped update of /home/xxx/.profile (source string already present)
Skipped update of /home/xxx/.zshrc (source string already present)

Web3j was successfully installed.
To use web3j in your current shell run:
source $HOME/.web3j/source.sh
When you open a new shell this will be performed automatically.
To see what Web3j's CLI can do you can check the documentation bellow.
https://docs.web3j.io/latest/command_line_tools/

└>web3j --version
              _      _____ _ 
             | |    |____ (_)
__      _____| |__      / /_ 
\ \ /\ / / _ \ '_ \     \ \ |
 \ V  V /  __/ |_) |.___/ / |
  \_/\_/ \___|_.__/ \____/| |
                         _/ |
                        |__/ 
by Web3Labs
Exception in thread "main" java.lang.IllegalArgumentException: version must not be null
	at com.github.zafarkhaja.semver.Version$Validators.nonNullOrThrow(Version.java:1383)
	at com.github.zafarkhaja.semver.Version$Validators.nonNull(Version.java:1357)
	at com.github.zafarkhaja.semver.Version.parse(Version.java:410)
	at com.github.zafarkhaja.semver.Version.parse(Version.java:392)
	at com.github.zafarkhaja.semver.Version.valueOf(Version.java:1437)
	at org.web3j.console.services.Updater.promptIfUpdateAvailable(Updater.java:35)
	at org.web3j.console.Web3jCommand.parse(Web3jCommand.java:108)
	at org.web3j.console.Web3j.main(Web3j.java:18)

└>java --version
openjdk 24.0.1 2025-03-18
OpenJDK Runtime Environment (build 24.0.1)
OpenJDK 64-Bit Server VM (build 24.0.1, mixed mode, sharing)

I also tried it with java 17 but same issue:

└>java --version
openjdk 17.0.14 2025-01-21
OpenJDK Runtime Environment (build 17.0.14+7)
OpenJDK 64-Bit Server VM (build 17.0.14+7, mixed mode, sharing)

sschueller avatar Apr 20 '25 18:04 sschueller

We appreciate you reporting this issue! We've attempted to reproduce it on several different machines, but unfortunately, we haven't been able to replicate the error on our end.

Given this, we suspect the problem might be related to your JAVA_HOME environment variable, especially since you mentioned having multiple Java versions installed. Could you please double-check your JAVA_HOME setting to ensure it's pointing to the correct Java installation? Sometimes, having various versions can lead to conflicts or unexpected behavior.

Let us know what you find, and thanks again for your help!

bodyhedia44 avatar Jun 28 '25 11:06 bodyhedia44

closing this for now, feel free to reopen is issue persists

gtebrean avatar Jun 30 '25 13:06 gtebrean

Issue shows up again: .gradle % web3j --version
_ _____ _ | | |____ () __ _| | / / \ \ /\ / / _ \ ' \ \ \ | \ V V / __/ |) |./ / | _/_/ _|./ _/| | _/ | |_/ by Web3Labs Exception in thread "main" java.lang.IllegalArgumentException: version must not be null at com.github.zafarkhaja.semver.Version$Validators.nonNullOrThrow(Version.java:1383) at com.github.zafarkhaja.semver.Version$Validators.nonNull(Version.java:1357) at com.github.zafarkhaja.semver.Version.parse(Version.java:410) at com.github.zafarkhaja.semver.Version.parse(Version.java:392) at com.github.zafarkhaja.semver.Version.valueOf(Version.java:1437) at org.web3j.console.services.Updater.promptIfUpdateAvailable(Updater.java:35) at org.web3j.console.Web3jCommand.parse(Web3jCommand.java:108) at org.web3j.console.Web3j.main(Web3j.java:18)

gtebrean avatar Aug 01 '25 15:08 gtebrean

fixed with version 1.7.0, if persists try to reinstall the cli

gtebrean avatar Aug 05 '25 14:08 gtebrean

@gtebrean I installed version 1.7.0, and I found a situation.

It happens when run web3j in the directory that have file gradle.properties, such as java/kotlin project root.

I ran web3j cli on the root of my kotlin project, and it seems that the web3j-xxx.jar look for gradle.properties in CWD first.

hayarobi avatar Aug 11 '25 15:08 hayarobi