ionide / ionide-vscode-fsharp

VS Code plugin for F# development
http://ionide.io
MIT License
857 stars 278 forks source link

ionide creates an .ionide directory when not loading F# projects or files #1041

Closed TheGoddessInari closed 3 years ago

TheGoddessInari commented 5 years ago

Problem

If you open a folder, an .ionide directory is required for the symbol cache, even if there's no F# files, no project files, no intent to use F# , and hence no symbols to save. I'm not certain what triggers this, I'm seeing this on some things but not others. I always get an .ionide folder with https://github.com/servo/servo.

Steps to reproduce

  1. Open VS Code
  2. Open a folder.
  3. An .ionide folder is created because of symbol cache.

Machine infos

TheGoddessInari commented 5 years ago

Looks like it's related to background caching unconditionally invoking FsAutoComplete.

Examining FsAutoComplete, it seems to create the directory unconditionally when starting its persistent state, so probably the error is possibly invoking FsAutoComplete in situations with no F# projects or data.

Source code probably needs to be combed over to ensure that nothing will start up FsAutoComplete inappropriately or unconditionally.

Krzysztof-Cieslak commented 5 years ago

Can't reproduce on latest Ionide and VSCode.

rpus commented 5 years ago

I've (very recently, since you closed this, and, I think, for the first time) started getting this unwanted behaviour too, seemingly on all my projects, none of which have anything to do with F#. I'm on VS Code 1.35.1 and Ionide-fsharp 4.0.0, so I'm guessing the latter has (re-)introduced this behaviour. Hope that helps...

jaredswarts55 commented 5 years ago

This is happening to me as well, I wonder if this should be reopened.

fogzot commented 5 years ago

Happening here too. Ionide 4.0.5 on VS Code 1.36.1.

Adohk commented 5 years ago

Same here I've had to disable ionide when not using F#

vbfox commented 5 years ago

I've seen it quite a few times in projects without any F# or .Net but I don't have a good repro, need ot investigate.

There's clearly something fishy.

mairaw commented 5 years ago

I also get this all the time when working on .NET documentation such as https://github.com/dotnet/docs

Krzysztof-Cieslak commented 5 years ago

We have following activation events (https://github.com/ionide/ionide-vscode-fsharp/blob/master/release/package.json#L1596-L1607):

    "activationEvents": [
        "workspaceContains:**/*.fs",
        "workspaceContains:**/*.fsx",
        "workspaceContains:**/*.fsproj",
        "workspaceContains:**/*.sln",
        "onLanguage:fsharp",
        "onCommand:fsi.Start",
        "onCommand:fsharp.NewProject",
        "onCommand:fsharp.NewProjectNoFake",
        "onCommand:fsharp.NewProjectScaffold",
        "onCommand:fsharp.RefreshProjectTemplates"
    ],

As far as I understand - if neither of that is hit, the extension shouldn't start. We create .ionide folder on startup of FSAC - so it shouldn't be created if the extension doesn't start. TBF, I'm bit confused how it may happen on non-.Net repositories.


Hey @Tyriar could you point me at someone from Team who could help us with that?

mairaw commented 5 years ago

We do have fsharp snippets inside the content. Maybe that triggers this?

Krzysztof-Cieslak commented 5 years ago

@mairaw, if snippets are in separate .fs or .fsx files, then yes, that would trigger extension activation. If snippets are just inlined in markdown, I wouldn't expect it to trigger activation.

rpus commented 5 years ago

@Krzysztof-Cieslak Are you saying that if any of those conditions are met, then .ionide/ is created?

If so, then surely any VS-style solution (for, say a C# solution/project) will create the folder... and indeed I have noticed that any VS-style (C#, non-F#) solution (with a .sln file) will trigger the behaviour.

PS I'd suggest (anyway) not using file extensions as indicators of anything; a given sequence of a couple of characters could have many meanings! Much better to rely on explicit setting of language mode etc., as you do later on in your array of events...

mairaw commented 5 years ago

@Krzysztof-Cieslak nope, no solution files, no .fs, .fsx or .fsproj files. Just inline snippets inside Markdown.

Krzysztof-Cieslak commented 5 years ago

Much better to rely on explicit setting of language mode etc., as you do later on in your array of events...

This is not acceptable as only activation condition in project file based IDE.

rpus commented 5 years ago

@Krzysztof-Cieslak Sure understood (and I expect the .fs* extensions are actually sane/safe choices anyway).

... but please do consider removing the *.sln line in your snippet above; at the moment it seems you categorise any VS solution as an F# project, which is obviously not right anyway (and does explain a lot of the 'false positives' I've seen in my projects). I doubt that would adversely affect your F# detection, and would hugely reduce the number of false positives. Many thanks!

Tyriar commented 5 years ago

Hey @Tyriar could you point me at someone from Team who could help us with that?

Your understanding is right, it shouldn't run code unless one of the activation events is hit.

@mjbvz do markdown snippets activate language extensions?

but please do consider removing the *.sln line in your snippet above; at the moment it seems you categorise any VS solution as an F# project, which is obviously not right anyway

This seems like a good idea, ionide would activate for any C# or VB.NET project otherwise, no?

Krzysztof-Cieslak commented 5 years ago

Fair enough, *.sln may be problematic for C#/VB.NET. But it still doesn't explain why it's happening on, for example, Rust project - as in original bug report from @TheGoddessInari

Krzysztof-Cieslak commented 5 years ago

Or in @mairaw case with https://github.com/dotnet/docs

TheGoddessInari commented 5 years ago

As previously mentioned (back in March), FsAutoComplete creates an .ionide directory unconditionally as part of making a symbol cache. It happens inappropriately, and why this has remained unaddressed, I don't know.

It's really bad to potentially get an .ionide directory anywhere that you open vscode to.

It's happening in places where there exist none of the files cited for activation.

It probably comes down to needing a specific case to start creating files instead of assuming the user wants them. Even if F# language support is getting activated more often than it should, it's still making these folders in arbitrary projects/directories that have little or nothing to do with F#.

The approach Visual Studio and others seem to use is making the cache per-user rather than per-directory.

jasondown commented 4 years ago

I am also getting this behaviour for C# projects that contain a solution file (.Sln). I've been adding .ionide/ to the .gitignore file for now as a workaround to ensure I don't accidentally commit it to the repository since I'm the only person who uses F# (for personal stuff). It's a little invasive, but my coworkers prefer the entry in the ignore file over the folder in the repository.

nightroman commented 4 years ago

It seems to be difficult to reproduce, right?

May I suggest a work around, if it is relevant and the design permits? As I mentioned in #1278 the produced SQLite table is empty. Is it possible to check for "no symbols" before creating this table and avoid its creation?

TheGoddessInari commented 4 years ago

That's a great idea, although it seems to be odd that it could be difficult to reproduce. It happens 100% of the time here, in every directory regardless of contents. In the code, that's exactly how it's written.

ehdevries commented 4 years ago

At one point, I was experiencing this issue 100% of the time, like @TheGoddessInari reports. Now it seems to happen only occasionally. However, the following reliably causes the issue for me:

Steps to reproduce

  1. In VS Code, disable the Ionide extension globally
  2. Close VS Code
  3. Create a new empty directory
  4. Open VS Code from that empty directory
  5. Enable the Ionide extension globally

I've tried this on two machines. In both cases, the .ionide folder is created, even though the directory is empty.

Machine 1

Machine 2

nightroman commented 4 years ago

I have found a workspace with stable reproduction of the issue on my two machines.

As a result the directory .ionide is created. (The workspace does not have any F# related files.)

Krzysztof-Cieslak commented 4 years ago

It’s .Net project so I assume it has .sln file. As stated before in the thread presence of .sln file is one of the activation events of the plugin

nightroman commented 4 years ago

I see, it is by design that .sln triggers Ionide activation and creation of ionide temp files even if .sln is not related to F#.

Jopie64 commented 4 years ago

I have the same problem. Since it triggers on .fs* extensions, could it be that it triggers on this too?

node_modules\karma\node_modules\core-js\library\modules\es7.math.fscale.js

(note .fscale.js here)

vbfox commented 4 years ago

BTW one common source for me of that is updates, vscode seem to run extensions after they update (Maybe also after it update itself) and ionide take that as a signal that it should create the directory in the current workspace... not always a good idea.

onionhammer commented 4 years ago

Disabling this extension until this is fixed :(

johnendev commented 4 years ago

If the extension loads because of the presence of .sln files, then it should also check that there is at least 1 .fs* file before doing anything else. sln files are common for C# projects etc so the extension should not be doing unnecessary work.

fourpastmidnight commented 4 years ago

I opened an empty folder to start a brand new, from scratch ReactJS project! And an .ionide folder was created with the aforementioned symbolCache.db file inside. Again, an empty folder.

I agree with many other commenters here (even though this is not the cause in the case of an empty folder): the presences of a .sln file should not cause this directory to get created. Now, the presence of a .fs* file in the vscode folder hierarchy....sure. That makes sense.

Missed the annotation directly above my comment that the .sln issue has been resolved. But still, the .ionide folder is created even when opening an otherwise empty directory in vscode.

fourpastmidnight commented 4 years ago

BTW, I've been seeing this behavior ever since I installed this extension including this functionality. Every single folder--100% of the time. It doesn't matter what I'm working on. This folder is created.

jamesbayley commented 3 years ago

I'm still facing this problem. Opening C# .NET Core project in vscode regularly creates the .ionide folder and loads the ionide extension. I have to manually delete the .ionide folder.

Is there any update on potential fix? Tempted to disable extension, but would prefer not to have to. Cheers!

travv0 commented 3 years ago

Those who are waiting for a fix to the extension activating and creating files on non-F# .NET projects shouldn't hold their breath, the maintainer seems unwilling to correct this behavior as seen in #1401 and #1439 despite calling it "problematic" earlier in this thread.

yakryder commented 3 years ago

@olivercoad ^^Yes please to a fix that will resolve this issue! Consider me an F# interloper, but if Ionide is active it puts this directory in strange places. Off the top of my head, this has included a Ruby project.

Richard-Payne commented 3 years ago

I'm also seeing this on C# solutions using the latest ionide and vs code. The thing with sln files being included in the activation criteria was mentioned over a year ago and yet it is still there. The presence of an sln file is not a positive indicator of an F# project. When can we get that removed?

dzmitry-lahoda commented 3 years ago

C:\Users\dz.vscode\extensions\ionide.ionide-fsharp-4.17.0 remove .sln here or on similar path on windows.

Fi1osof commented 3 years ago

Still have this problem on react-project

olivercoad commented 3 years ago

@Fi1osof Do you have steps to repro?

Fi1osof commented 3 years ago

@olivercoad , sorry, no. I got this again, but after close and reopen VSCODE all fine again...