Coder Social home page Coder Social logo

Comments (28)

tgodzik avatar tgodzik commented on July 26, 2024 2

@virtualdvid Och, I think when it timeouts looking for pattern it activates the extension by default? :O

"activationEvent":"workspaceContainsTimeout:**/scala/**"

from metals-vscode.

gabro avatar gabro commented on July 26, 2024 2

Nice catch, this is indeed a vscode issue. See microsoft/vscode#73656

I'm not sure of what's the best workaround

from metals-vscode.

tgodzik avatar tgodzik commented on July 26, 2024 1

@virtualdvid I think that is the best option for now without regressing in the behavior. I believe this should really be fixed on the VS Code side.

from metals-vscode.

gabro avatar gabro commented on July 26, 2024

Hi @DieBauer, thanks for reporting!

The activation events for the extension are specified here:

"activationEvents": [
"onLanguage:scala",
"workspaceContains:build.sbt",
"workspaceContains:build.sc",
"workspaceContains:project/build.properties",
"workspaceContains:**/scala/**"

Is it possible that you're matching some of these?

If not, it would be really helpful if you could provide a minimal reproduction, so that I can try and reproduce the issue.

from metals-vscode.

DieBauer avatar DieBauer commented on July 26, 2024

I tried to reproduce the observed behaviour on new / empty folders, but I cannot. If this happens again, I'll re-open this issue.

from metals-vscode.

virtualdvid avatar virtualdvid commented on July 26, 2024

I got this issue and now I have a .metals folder in my python projects.

from metals-vscode.

tgodzik avatar tgodzik commented on July 26, 2024

Do you have anything that matches any of the activation events like shown by @gabro ?

The activation events for the extension are specified here:

"activationEvents": [
"onLanguage:scala",
"workspaceContains:build.sbt",
"workspaceContains:build.sc",
"workspaceContains:project/build.properties",
"workspaceContains:**/scala/**"

from metals-vscode.

virtualdvid avatar virtualdvid commented on July 26, 2024

yes I have configured by default that file with that list. I also isolated an independent folder for scala projects. and the folder .metals stills there on each of my projects.

from metals-vscode.

tgodzik avatar tgodzik commented on July 26, 2024

yes I have configured by default that file with that list. I also isolated an independent folder for scala projects. and the folder .metals stills there on each of my projects.

Not sure I understand. VS Code will activate the extension only if a workspace contains any of the prerequisites that I pasted above. If any of those are matching then .metals will be present.

Do those Python projects contain any of those files or directories?

from metals-vscode.

virtualdvid avatar virtualdvid commented on July 26, 2024

Hi @tgodzik, I have my Scala and Python projects totally isolated in their own folders. I also verified the Python projects and they don't have anything related with Scala.

from metals-vscode.

tgodzik avatar tgodzik commented on July 26, 2024

If so then it's a bug with VS Code, because Metals is only activated if you have either build.sbt. build.sc, project/build.properties, any scala directory or anything that identifies as language Scala.

Are you sure there is nothing from above? Do you have any open source repo or minimal example that you can reproduce the behavior?

from metals-vscode.

DieBauer avatar DieBauer commented on July 26, 2024

I ran into the same scenario, only 1 python file was created in that directory, but metals started.

metals.log in vscode Output

Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home
logging to file /Users/DieBauer/Development/py-scripts/.metals/metals.log
time: initialize in 0.31s
no build tool detected in workspace '/Users/DieBauer/Development/py-scripts'. The most common cause for this problem is that the editor was opened in the wrong working directory, for example if you use sbt then the workspace directory should contain build.sbt. 

When trying to reproduce, open new folder, create python file, and wait, I can't reproduce it...

No idea what triggered the start of metals. I am certain that there is no match on any of the files listed in the activationEvents

from metals-vscode.

tgodzik avatar tgodzik commented on July 26, 2024

The problem is that if nothing actually matches the activation events then it's not a Metals issue but VS Code one.

And without reproduction we cannot even exactly fix anything. I will close this issue until we have a reproduction.

from metals-vscode.

JamezMercier avatar JamezMercier commented on July 26, 2024

Yes it is related if you have a "metals.sbtScript": "C:\\Program Files (x86)\\sbt" changing it to "metals.sbtScript": "" fixed the problem for me. It is more related to that.

from metals-vscode.

lqhuang avatar lqhuang commented on July 26, 2024

@gabro @tgodzik I'm using the metals in vscode, and it works great in my Scala / SBT projects. Thanks a lot!
The same, when I switched to a Python project, metals starts then creates a .metals directory.

Here is my tree structure of project:

.
├── bert_client.py
├── db_models.py
├── difference.py
├── get_new_data.py
├── .git
| ..........
├── .gitignore
├── logs
│   ├── new_model.2020-01-13.log
│   ├── new_model.2020-01-20.log
│   ├── stream_tweet_prediction.2019-12-31.log
│   ├── stream_tweet_prediction.2020-01-06.log
│   ├── stream_tweet_prediction.2020-01-13.log
│   ├── stream_tweet_prediction.2020-01-20.log
│   └── stream_tweet_prediction.txt
├── .metals
│   ├── metals.h2.db
│   └── metals.log
├── pred_rel_sent.py
├── README.md
├── recalc.py
├── requirements.txt
├── run_script_pred.py
├── run_script_pred.sh
├── scripts
│   ├── migrate_prediction.py
│   └── missing_time_distribution.py
├── select_new_user.py
├── sent2sent
├── sent_pred.service
├── src
├── tree.txt
└── .vscode
    └── settings.json

111 directories, 190 files

VS Code version:

> code --version
1.41.1
26076a4de974ead31f97692a0d32f90d735645c0
x64

Metal version: 1.7.2

Content of metals.log:

INFO  started: Metals version 0.8.0 in workspace '/home/lqhuang/Git/bert-sa-2steps'
INFO  time: initialize in 1.45s
WARN  no build tool detected in workspace '/home/lqhuang/Git/bert-sa-2steps'. The most common cause for this problem is that the editor was opened in the wrong working directory, for example if you use sbt then the workspace directory should contain build.sbt. 
INFO  shutting down Metals

I thought my project does't match patterns of activationEvents.

And what other information would you need to find problems? I could supply them later.

Thanks for your efforts:)
Regards.

from metals-vscode.

tgodzik avatar tgodzik commented on July 26, 2024

@lqhuang does this happen all the time even if you remove the .metals directory and reload?

The extension should not really be activated since I see nothing that matches the activationEvents.
It would nice to maybe try to copy dir and try deleting parts of it to locate the issue? Delete-> reload window.

from metals-vscode.

virtualdvid avatar virtualdvid commented on July 26, 2024

@lqhuang I got the same problem. In my personal and job laptops. I ended up putting that folder in .gitignore. It's not a elegant solution but...

from metals-vscode.

tgodzik avatar tgodzik commented on July 26, 2024

@virtualdvid is it only on python projects that this happens? Do you have any open source repo that you can reproduce it with?

from metals-vscode.

virtualdvid avatar virtualdvid commented on July 26, 2024

I just started a new workspace to learn go and I only have the "hello world" file there and got the .metals folder:

Code_fQlEpjd3B6

from metals-vscode.

tgodzik avatar tgodzik commented on July 26, 2024

@virtualdvid I cannot reproduce unfortunately, but there should be more info in the VS Code logs

You need to go into output and then Log (Extension Host):

image

Is there anything indicating why Metals was activated?

from metals-vscode.

virtualdvid avatar virtualdvid commented on July 26, 2024

Sure, The only log I got with metals was on Saturday but I was working on my python project I didn't even touch the Scala one. Actually I'm using eclipse for scala (sadly).

[2020-02-01 11:46:03.691] [exthost] [info] ExtensionService#_doActivateExtension scalameta.metals {"startup":true,"extensionId":{"value":"scalameta.metals","_lower":"scalameta.metals"},"activationEvent":"workspaceContainsTimeout:**/scala/**"}
[2020-02-01 11:46:03.692] [exthost] [info] ExtensionService#loadCommonJSModule file:///c:/Users/myuser/.vscode/extensions/scalameta.metals-1.7.2/out/extension

from metals-vscode.

tgodzik avatar tgodzik commented on July 26, 2024

We might need to remove that pattern, VS code is not dealing well with it - but it will not be a good experience for gradle/maven, since people will need to open Scala files.

from metals-vscode.

lqhuang avatar lqhuang commented on July 26, 2024

@tgodzik It's interesting and very strange that I can't reproduce now after I deleted .metals and begin to find why by removing some files. It doesn't appear again. But I'm quite sure it was always happen in the past. So I must do something different.

Then I remembered that at that time, I just installed Metals extension and do not open any scala project yet, which means Metals probably has not initialized correctly. Once, I use vscode to open my scala project, Metals download its required packages, initialize itself, then most importantly, works normally in my scala project. After that, .metals doesn't appear again in other projects. I guess this is the reason make the difference.

So, base on previously mentioned, I agree with your thought that this is a timeout issue. Maybe you can use a clean installed Metals extension to reproduce problems?

from metals-vscode.

tgodzik avatar tgodzik commented on July 26, 2024

@tgodzik It's interesting and very strange that I can't reproduce now after I deleted .metals and begin to find why by removing some files. It doesn't appear again. But I'm quite sure It's always happen in the past. So I must do something different.

Then I remembered that at that time, I just installed Metals extension and do not open any scala project yet, which means Metals probably has not initialized correctly. Once, I use vscode to open my scala project, Metals download its required packages, initialize itself, then most importantly, works normally in my scala project. After that, .metals doesn't appear again in other projects. I guess this is the reason make the difference.

So, base on previously mentioned, I agree with your thought that this is a timeout issue. Maybe you can use a clean installed Metals extension to reproduce problems?

Sounds like a good idea! But most likely we need to make the pattern smarter.

from metals-vscode.

tgodzik avatar tgodzik commented on July 26, 2024

We might try a couple of easier patterns that don't look so deep into the file tree like:
*/scala/**
*/*/scala/**
etc.

But timeouts might still happen.

from metals-vscode.

gabro avatar gabro commented on July 26, 2024

It's probably a dumb question, but there's no other indication that a project is a Maven/Gradle Scala project?

from metals-vscode.

tgodzik avatar tgodzik commented on July 26, 2024

It's probably a dumb question, but there's no other indication that a project is a Maven/Gradle Scala project?

It's all defined either in build.gradle or pom.xml, but unfortunately we can't check what is contained in a file. And with those files it could also just be a java project.

from metals-vscode.

virtualdvid avatar virtualdvid commented on July 26, 2024

Out of the solution you are trying to implement I just realized I can enable or disable extensions in vscode. I don't know why I wasn't doing that before. I just disabled Metals ext on my python workspaces.

from metals-vscode.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.