question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

vscode: cannot access built in declaration.

See original GitHub issue

I 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:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
fwcdcommented, Aug 27, 2019

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).

0reactions
Abhinav1217commented, Aug 27, 2019

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found