vscode: cannot access built in declaration.
See original GitHub issueI am starting to learn kotlin language and decided to use vscode instead of IntellJ IDEA to better learn stuff by doing things manually.
On the very first variable program, Code is showing me following error:
Cannot access built-in declaration 'kotlin.String'. Ensure that you have a dependency on the Kotlin standard librarykotlin(MISSING_BUILT_IN_DECLARATION)
However the code is actually not wrong. I can compile it and run it without any issue.
fun main() {
val name: String = "Abhinav001"
println(name)
}
Terminal :
abhinav@abhinav-sol ~/Projects/kotlin-lang $ kotlinc Variable.kt
abhinav@abhinav-sol ~/Projects/kotlin-lang $ kotlin VariableKt
Abhinav001
I even tried importing kotlin.String
on top but still language-server is showing errors, despite code being correct.
Am I missing some configuration step for kotlin-language-server? I do not want to use IntellJ IDE for learning kotlin.
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Cannot access built-in declaration Ensure that you have a ...
"In order to use coroutines [...], you need to add a dependency on kotlinx-coroutines-core module as explained in the project README." – ...
Read more >Cannot access built-in declaration 'kotlin.Array'. Ensure that ...
Error:(9, 16) Kotlin: Cannot access built-in declaration 'kotlin.Array'. Ensure that you have a dependency on the Kotlin standard library. Caused by 1.
Read more >Variables reference - Visual Studio Code
Variables Reference. Visual Studio Code supports variable substitution in Debugging and Task configuration files as well as some select settings.
Read more >Official support for Visual Studio Code - Kotlin Discussions
In my book, “lock-in” means “you have to pay a single vendor or you can't use the tool”. You seem to be defining...
Read more >Using Visual Studio Code | Manual - Deno
By default, vscode comes with a built-in TypeScript/JavaScript language service ... The most direct way to do this is to use the Deno:...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
That is correct, the next release should be able to find
kotlinc
’s standard library without having to install Gradle or Maven. The language server previously just searched in the local Gradle repository, which is why it worked for you after installing Gradle (and presumably opening kotlin-quick-start or any other project which depends on Kotlin‘s stdlib and thus downloads it).A funny discovery,
Since code itself is not erroneous I thought using kotlin-quick-start to create a project which the language-server can use to lint my code, and still use
kotlinc
to compile and run single files. Many thanks for that by the way. I never used gradle before.Turns out as soon as I installed gradle, using
sdk install gradle
, language-server suddenly started functioning as expected. Without adding a gradle project in the directory.Maybe its just me? or maybe it automatically finds gradle libs. In any case, gradle is a dependency of this language-server to work on single files. Haven;t tried with maven yet.