Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connecting with the SQLDelight plugin failed: try building from the command line. #3420

Closed
madisp opened this issue Aug 7, 2022 · 12 comments · Fixed by #3925
Closed

Connecting with the SQLDelight plugin failed: try building from the command line. #3420

madisp opened this issue Aug 7, 2022 · 12 comments · Fixed by #3925

Comments

@madisp
Copy link
Contributor

madisp commented Aug 7, 2022

SQLDelight Version

2.0.0-alpha03

IDE Version

IntelliJ 2022.2

Dialect

PostgreSQL

Describe the Bug

Opening *.sq files in the IDE always prints this header, source inspections don't seem to work.

Gradle plugin and IDE plugin are both 2.0.0-alpha03. Project is a pure-JVM Kotlin project.

Stacktrace

None

Description

IDEA log is full of lines at 100ms interval like

2022-08-07 12:16:47,353 [ 397641]   INFO - SQLDelight[warp-speed] - Fetching SQLDelight models
2022-08-07 12:16:47,456 [ 397744]   INFO - SQLDelight[warp-speed] - Fetching SQLDelight models
2022-08-07 12:16:47,562 [ 397850]   INFO - SQLDelight[warp-speed] - Fetching SQLDelight models
2022-08-07 12:16:47,665 [ 397953]   INFO - SQLDelight[warp-speed] - Fetching SQLDelight models
2022-08-07 12:16:47,772 [ 398060]   INFO - SQLDelight[warp-speed] - Fetching SQLDelight models
2022-08-07 12:16:47,863 [ 398151]   INFO - SQLDelight[warp-speed] - Fetching SQLDelight models

but not noticing any error lines

@madisp
Copy link
Contributor Author

madisp commented Aug 7, 2022

did some digging and debugging, this seems to be a JAVA_HOME issue, SqlDelight plugin uses JAVA_HOME to invoke Gradle. I'm using asdf to manage my installations and some reason the asdf shims from .zshrc aren't picked up.

Did a workaround of adding an export JAVA_HOME=... just before invoking the shims so that there's some env variable for the IDE to pick up.

My side is solved and I'm not sure whether the issue is with SqlDelight here, looks like a compat issue between asdf and IDEA instead. OTOH would be nice to get a better error message ("JAVA_HOME missing" or the like).

@AlecKazakova
Copy link
Collaborator

yea, we explicitly use java home for the gradle connector, though its surprising that it just continues to try even if its not working. I can try reproducing

@AlecKazakova
Copy link
Collaborator

and also agreed, it would be much better if the error just said java home was missing

@VitKap
Copy link

VitKap commented Oct 4, 2022

@madisp Can you please describe where did you add export JAVA_HOME=... and what value may it has? When I type java in my Android Studio terminal, it looks OK - java is found but I'm getting the same error as you. No idea how to repair it...

@madisp
Copy link
Contributor Author

madisp commented Oct 4, 2022

@VitKap are you also using asdf? I ended up adding the following to my .zshrc:

. ~/.asdf/plugins/java/set-java-home.zsh

@VitKap
Copy link

VitKap commented Oct 5, 2022

@madisp No, I'm not using asdf - I've never heard of this tool before. Do you have an idea how to make SQLDelight plugin work?

@morki
Copy link
Contributor

morki commented Oct 11, 2022

I have the same problem with 2.0.0-alpha04, can't find how to solve it.
Is it possible to use project SDK instead?

@brinsche
Copy link

I had the same issue, with Android Studio Dolphin | 2021.3.1 Patch 1 on a macOS 13 M1 Mac in case that helps, but thanks to:

yea, we explicitly use java home for the gradle connector, though its surprising that it just continues to try even if its not working. I can try reproducing

I built myself a version of the plugin with a hardcoded java home and it works now.

@burntcookie90
Copy link
Contributor

I seem to have found myself running into this issue. I have JAVA_HOME set in my .zshrc which later gets set by jenv. I am launching Intellij via Jetbrains Toolbox. Unfortunately no luck with the sqldelight plugin.

IntelliJ IDEA 2022.3.1 (Community Edition)
Build #IC-223.8214.52, built on December 20, 2022
Runtime version: 17.0.5+1-b653.23 aarch64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
macOS 13.1
GC: G1 Young Generation, G1 Old Generation
Memory: 2048M
Cores: 10
Metal Rendering is ON
Registry:
    debugger.new.tool.window.layout=true
    ide.experimental.ui=true

Non-Bundled Plugins:
    Docker (223.8214.52)
    IdeaVIM (2.0.0)
    DBN (3.3.5889.0)
    org.jetbrains.kotlin-js-inspection-pack-plugin (0.0.12)
    com.squareup.sqldelight (2.0.0-alpha05)

Kotlin: 223-1.7.21-release-272-IJ8214.52

@kansson
Copy link

kansson commented Feb 3, 2023

Also had this issue when starting android studio from the toolbox app on macos. My solution was to set the java home env variable and launching android studio from the command line.

aperfilyev added a commit to aperfilyev/sqldelight that referenced this issue Feb 25, 2023
aperfilyev added a commit to aperfilyev/sqldelight that referenced this issue Feb 25, 2023
@lnhrdt
Copy link
Contributor

lnhrdt commented Mar 6, 2023

yea, we explicitly use java home for the gradle connector, though its surprising that it just continues to try even if its not working. I can try reproducing

@AlecStrong is there a reason to use JAVA_HOME here within the IntelliJ plugin rather than the SDK configured in IntelliJ's project settings? I bumped into this trying out an 2.0.0 alpha version, coming from 1.x. Setting JAVA_HOME on a development machine does solve this issue, but it seems like an unnecessary complication in our team's development environment setup when the rest of our tooling seems to fall in line under IntellliJ's project settings.

@saket
Copy link
Contributor

saket commented Jul 29, 2023

Running into this as well. SQLDelight is trying to use JAVA_HOME which points to Java 11. Is it not expected to use the Gradle JDK path set in IDE settings?

Caused by: com.android.builder.errors.EvalIssueException: Android Gradle plugin requires Java 17 to run. You are currently using Java 11.
 Your current JDK is located in /Library/Java/JavaVirtualMachines/zulu-11.jdk/Contents/Home
 You can try some of the following options:
  - changing the IDE settings.
  - changing the JAVA_HOME environment variable.
  - changing `org.gradle.java.home` in `gradle.properties`.
Screenshot 2023-07-29 at 12 21 36 PM 2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants