This guide provides a clean, repeatable setup flow, verification steps, and common pitfalls to avoid in real environments.
Problem description:
We want a predictable Gradle installation on Ubuntu so local shells and build tools resolve the intended Gradle version.
What we are solving actually:
We are solving environment consistency and version clarity. Most Gradle setup issues come from PATH conflicts, shell reload confusion, or mixing global installation with project-wrapper expectations.
What we are doing actually:
- Install Gradle into a known tools directory.
- Export
GRADLE_HOMEand add itsbindirectory toPATH. - Verify the active binary and prefer the Gradle Wrapper for project builds.
1. Download and Extract
Download Gradle and extract it to your tools directory, for example:
/data/dev/tools/gradle-8.7
If this is only for one project, prefer using the Gradle Wrapper (./gradlew) committed with that project instead of relying on global installation.
2. Set GRADLE_HOME and PATH
Edit profile:
sudo nano /etc/profile
Add:
GRADLE_HOME=/data/dev/tools/gradle-8.7
PATH=$PATH:$GRADLE_HOME/bin
export GRADLE_HOME
export PATH
Reload shell config:
source /etc/profile
Better Practice: /etc/profile.d File
For system-wide setup, create a dedicated file:
sudo nano /etc/profile.d/gradle.sh
export GRADLE_HOME=/data/dev/tools/gradle-8.7
export PATH=$PATH:$GRADLE_HOME/bin
Then load it:
source /etc/profile.d/gradle.sh
This avoids modifying /etc/profile directly.
3. Verify
echo $GRADLE_HOME
gradle -v
4. Optional: Set GRADLE_USER_HOME
Set custom Gradle cache/repository location:
export GRADLE_USER_HOME=/data/dev/repository/gradle
Add this line in profile to make it persistent.
Team-Friendly Recommendation: Use Gradle Wrapper
Even if Gradle is globally installed, execute builds using wrapper:
./gradlew clean test
Benefits:
- consistent Gradle version per repo
- fewer CI/local mismatch issues
- easier onboarding
Common Troubleshooting
gradle: command not found: PATH not reloaded, runsourceagain.- Wrong Gradle version: check
which gradlefor conflicting binaries. - Permission issues in cache: verify ownership of
GRADLE_USER_HOME. - Corporate proxy failures: configure proxy in
~/.gradle/gradle.properties.
Example proxy config:
systemProp.http.proxyHost=proxy.company.com
systemProp.http.proxyPort=8080
systemProp.https.proxyHost=proxy.company.com
systemProp.https.proxyPort=8080
Debug steps:
- run
which gradleto verify the binary that shells actually resolve - confirm
gradle -vreports the version you intended to install - prefer
./gradlewfor repo builds even after global installation succeeds - separate global tool setup from project-specific cache or proxy issues
Key Takeaways
- Keep configuration explicit and environment-specific.
- Verify setup with version and env checks immediately after changes.
- Automate these steps in shell profiles or project docs to avoid drift.
- Prefer
./gradlewfor reproducible builds across machines and CI.
Practical Checkpoint
A short but valuable final check for install gradle on ubuntu is to write down the one misuse pattern most likely to appear during maintenance. That small note makes the article more useful when someone revisits it months later under pressure.
Final Practical Note
Even for a small setup guide, the valuable habit is to capture one verification command and one rollback step next to the instructions. That tiny addition turns a one-time note into something safer to reuse when the environment is slightly different months later.
Comments