段振东
段振东

Reputation: 21

VSCode: Issue installing Gradle distribution

I am following this tutorial about building Java web applications in VSCode.

After I pressed F5 to debug my code, I received the error message Could not install Gradle distribution from 'https://services.gradle.org/distributions/gradle-4.6-bin.zip'..

Screenshot:

VSCode Gradle Error

Can anyone help me figure out why this error message is appearing?

Upvotes: 2

Views: 7700

Answers (2)

Simon Pickup
Simon Pickup

Reputation: 892

If you want to download Gradle manually and use that you can configure some VS Code settings to reference your Gradle distribution:

  1. set java.import.gradle.wrapper.enabled to false
  2. keep java.import.gradle.version empty
  3. point java.import.gradle.home to your unzip folder

Thanks to https://github.com/microsoft/vscode-gradle/issues/1125#issuecomment-996441654

Upvotes: 1

Thomas Hügel
Thomas Hügel

Reputation: 300

I encounter the same problem on Linux. My understanding is that VS Code wants to use the directory /usr/share/java/gradle/ (which is contained in the environment variable GRADLE_HOME), whereas it should use ~/.gradle instead. I tried to fix it through the configuration files (such as gradle-wrapper.properties, .vscode/settings.json or .settings/org.eclipse.buildship.core.prefs) but without success. The only workaround I found was to set the environment variable:

  • if you want to do it for all your sessions (with the risk that it might break some other applications), put the following line into your ~/.bash_profile and reboot:
export GRADLE_HOME=~/.gradle
  • a less intrusive solution is to set the variable when launching VS Code:
env GRADLE_HOME=~/.gradle code

If you use a desktop entry, customize the relevant file. In my case (Arch Linux), this file is /usr/share/applications/visual-studio-code.desktop; so put the following line into it:

Exec=env GRADLE_HOME=~/.gradle code %f

and restart VS Code (twice if necessary).

I opened an issue on Github.

Upvotes: 2

Related Questions