fsprojects / fsharp-language-server

Other
219 stars 37 forks source link

No .fsproj or .fsx file references #49

Closed AntonioL closed 2 years ago

AntonioL commented 5 years ago

I am trying to play around with FSharp on VSCode, using dotnetcore3 preview (the latest one released on the 6th of March, https://dotnet.microsoft.com/download/dotnet-core/3.0)

I have created a new project by running: dotnet new console -lang F# which generated the below fsproj file:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp3.0</TargetFramework>
    <RootNamespace>bir_sharp</RootNamespace>
  </PropertyGroup>

  <ItemGroup>
    <Compile Include="Program.fs" />
  </ItemGroup>

</Project>

But sadly I am getting this error:

{
    "resource": "/home/tato/Projects/bir-sharp/Program.fs",
    "owner": "_generated_diagnostic_collection_name_#1",
    "severity": 8,
    "message": "No .fsproj or .fsx file references /home/tato/Projects/bir-sharp/Program.fs",
    "startLineNumber": 1,
    "startColumn": 1,
    "endLineNumber": 1,
    "endColumn": 2
}

It really does not make sense because the Program.fs file is definitely reference in the project file. Can you advise?

georgewfraser commented 5 years ago

That is very odd. Could you attach the entire log? There may be messages from the project cracking phase that will help.

AntonioL commented 5 years ago

The above is the only error I get.

Can you elaborate on how can I obtain the logs you need? Not super familiar with VS Code.

AntonioL commented 5 years ago
Listening on stdin
Add workspace root /home/tato/Projects/bir-sharp
New configuration {settings = {
  "fsharp": {
    "trace": {
      "server": "off"
    }
  }
};}
No cracked project references Program.fs, looking at uncracked projects...
The text of bir-sharp.fsproj contains the string 'Program.fs', cracking
Analyzing bir-sharp.fsproj
Failed to build bir-sharp.fsproj: The imported project "/home/tato/dotnet/sdk/3.0.100-preview3-010431/15.0/Microsoft.Common.props" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.  /home/tato/dotnet/sdk/3.0.100-preview3-010431/Sdks/Microsoft.NET.Sdk/Sdk/Sdk.props
/home/tato/Projects/bir-sharp/bir-sharp.fsproj: 
  ProjectFileName: "/home/tato/Projects/bir-sharp/bir-sharp.fsproj"
  SourceFiles: [||]
  ReferencedProjects: []
  OtherOptions: [|"--noframework"|]
  LoadTime: 3/25/19 9:41:32 PM
  ExtraProjectInfo: <null>
  IsIncompleteTypeCheckEnvironment: false
  OriginalLoadReferences: []
  ExtraProjectInfo: <null>
  Stamp: <null>
  UnresolvedReferences: <null>
  UseScriptResolutionRules: false
No cracked project references Program.fs, looking at uncracked projects...
No cracked project references Program.fs, looking at uncracked projects...
Failed to create code lens because project options failed to load: [{range = {start = {line = 0;
                    character = 0;};
           end = {line = 0;
                  character = 1;};};
  severity = Some Error;
  code = None;
  source = None;
  message =
   "No .fsproj or .fsx file references /home/tato/Projects/bir-sharp/Program.fs";}]
No cracked project references Program.fs, looking at uncracked projects...
Check failed, ignored 1 errors
Autocompleting at /home/tato/Projects/bir-sharp/Program.fs(7,5)
No cracked project references Program.fs, looking at uncracked projects...
Finished typecheck, looking for completions...
Check failed, ignored 1 errors
No cracked project references Program.fs, looking at uncracked projects...
Failed to create code lens because project options failed to load: [{range = {start = {line = 0;
                    character = 0;};
           end = {line = 0;
                  character = 1;};};
  severity = Some Error;
  code = None;
  source = None;
  message =
   "No .fsproj or .fsx file references /home/tato/Projects/bir-sharp/Program.fs";}]
No cracked project references Program.fs, looking at uncracked projects...
Failed to create code lens because project options failed to load: [{range = {start = {line = 0;
                    character = 0;};
           end = {line = 0;
                  character = 1;};};
  severity = Some Error;
  code = None;
  source = None;
  message =
   "No .fsproj or .fsx file references /home/tato/Projects/bir-sharp/Program.fs";}]
No cracked project references Program.fs, looking at uncracked projects...
Failed to create code lens because project options failed to load: [{range = {start = {line = 0;
                    character = 0;};
           end = {line = 0;
                  character = 1;};};
  severity = Some Error;
  code = None;
  source = None;
  message =
   "No .fsproj or .fsx file references /home/tato/Projects/bir-sharp/Program.fs";}]
No cracked project references Program.fs, looking at uncracked projects...
No cracked project references Program.fs, looking at uncracked projects...
georgewfraser commented 5 years ago

Hmm, dotnet 3 preview seems to have a slightly different output format, the project-cracking code will need to be updated.

AntonioL commented 5 years ago

Do you have any plan to do that?

I think it is likely that the next official version of .net core should follow the same covention

georgewfraser commented 5 years ago

Yes. If you're interested in taking a crack at it, just run

./scripts/restore.sh
dotnet test ./tests/ProjectCracker.Tests

using dotnet 3. The code that inspects the project is all in src/ProjectCracker/ProjectCracker.fs. It's long but pretty simple and well-commented.

Looking at your error log, it might be as simple as recompiling against dotnet 3, or updating the dependency on Buildalyzer.

mrbech commented 5 years ago

After pulling the newest microsoft/dotnet:2.2-sdk docker image I am getting a similar error (The imported project "/usr/share/dotnet/sdk/2.2.203/15.0/Microsoft.Common.props" was not found).

Symlinking ln -s /usr/share/dotnet/sdk/2.2.203/Current /usr/share/dotnet/sdk/2.2.203/15.0 seems to fix it. Not sure if this is a problem with the ProjectCracker or something else?

cannorin commented 5 years ago

I'm having the same problem in dotnet 2.2.203 and @mrbech 's workaround worked for me too.

YoEight commented 5 years ago

Greetings,

Like others, I'm having that issue with dotnet 2.2.203 however, I only got it on my Ubuntu computer. I don't have that issue on my Mac, while still having the same dotnet version.

Ubuntu 18.04.02 LTS OSX 10.14.4 Visual Studio Code: 1.33 on both computers. .NET Core: 2.2.203 on both computers

rudihorn commented 5 years ago

Had the same issue on Windows, with a similar workaround of copying C:\Program Files\dotnet\sdk\2.2.203\Current to C:\Program Files\dotnet\sdk\2.2.203\15.0 fixing it.

rudihorn commented 5 years ago

This issue seems to also occur when opening multiple project folders in a single workspace.

jdobbin-hsahealthplan commented 5 years ago

I fixed it in Ubuntu 19.04, .net core 2.203 by completely removing all mono packages and rebooting.

The removal scripts I used were:

sudo apt-get purge libmono* cli-common mono-runtime
sudo apt-get autoremove

I had to run the first command twice for some reason. After a reboot the omnisharp intellisense worked in vscode again.

georgewfraser commented 5 years ago

The appveyor build is broken on this issue since the upgrade 2.2.103 => 2.2.203, so at least we have a repro now.

AntonioL commented 5 years ago

I fixed it in Ubuntu 19.04, .net core 2.203 by completely removing all mono packages and rebooting.

The removal scripts I used were:

sudo apt-get purge libmono* cli-common mono-runtime
sudo apt-get autoremove

I had to run the first command twice for some reason. After a reboot the omnisharp intellisense worked in vscode again.

In my case it did not work. Had not any of these libraries looks like.

stijnherreman commented 5 years ago

Possibly related to https://github.com/daveaglick/Buildalyzer/issues/107.

yatli commented 5 years ago

hey,

this is fixed in my fork: https://github.com/yatli/coc-fsharp/tree/master/src

The F# part is mostly compatible. Feel free to backport it :)

evanricard commented 5 years ago

I'm having this issue as well on Windows using the SDK for .NET Core 3...can't quite wrap my head around what to do.

georgewfraser commented 5 years ago

@yatli Would you mind making a PR backporting the fix?

mktange commented 5 years ago

@georgewfraser I just tried recompiling the extension locally with 2.2.401, and that made it work again for me.

iskandersierra commented 4 years ago

Had the same issue on Windows, with a similar workaround of copying C:\Program Files\dotnet\sdk\2.2.203\Current to C:\Program Files\dotnet\sdk\2.2.203\15.0 fixing it.

This same trick worked for me for sdk 3.0.100: copy C:\Program Files\dotnet\sdk\3.0.100\Current C:\Program Files\dotnet\sdk\3.0.100\15.0 And the error is gone

MelisWillem commented 4 years ago

I had same problem and the solution from @iskandersierra worked! thanks a lot @iskandersierra

lukethenuke commented 4 years ago

This commit https://github.com/fsprojects/fsharp-language-server/commit/60dd3383c9bb4b353f8477956e0f4d6f9343bfca fixes the issue for me

akdor1154 commented 4 years ago

Saw this with dotnet 3.1.101, symlinking Current -> 15.0 gives me a different error:

Cracked 2020-01_fstest.fsproj in 1915ms
Parsing /home/jarrad/src/ow/fa/analyses/2020-01_fstest/obj/project.assets.json
Failed to build 2020-01_fstest.fsproj: Object reference not set to an instance of an object.
/home/jarrad/src/ow/fa/analyses/2020-01_fstest/2020-01_fstest.fsproj: 
  ProjectFileName: "/home/jarrad/src/ow/fa/analyses/2020-01_fstest/2020-01_fstest.fsproj"
  SourceFiles: [||]
  ReferencedProjects: []
  OtherOptions: [|"--noframework"|]
  LoadTime: 7/2/20 5:12:44 pm
  ExtraProjectInfo: <null>
  IsIncompleteTypeCheckEnvironment: false
  OriginalLoadReferences: []
  ExtraProjectInfo: <null>
  Stamp: <null>
  UnresolvedReferences: <null>
  UseScriptResolutionRules: false
faldor20 commented 4 years ago

I'm having the same problem as @akdor1154 copying or symlinking just causes that error instea. Also on 3.1.100

yatli commented 4 years ago

@georgewfraser I've got a PR up for prerequisites (see https://github.com/fsprojects/fsharp-language-server/pull/58), but I'm not sure how the tests have failed.

I'll open a new PR with the latest coc-fsharp changes:

adelarsq commented 4 years ago

Just a side note. I was having this error with a new F# project on .NET Core 3.1.301. Just cleaning and recompiling did solve the problem.

I am using asdf and setting the env variables with:

function dotnet-set-vars {
    DOTNET_BASE=$(dotnet --info | grep "Base Path" | awk '{print $3}')
    # echo "DOTNET_BASE: ${DOTNET_BASE}"

    DOTNET_ROOT=$(echo $DOTNET_BASE | sed -E "s/^(.*)(\/sdk\/[^\/]+\/)$/\1/")
    # echo "DOTNET_ROOT: ${DOTNET_ROOT}"

    export MSBuildSDKsPath=${DOTNET_BASE}Sdks/
    export DOTNET_ROOT=$DOTNET_ROOT
    export PATH=$DOTNET_ROOT:$PATH

    # dotnet tools dir
    export PATH=~/.dotnet/tools:$PATH
}
faldor20 commented 2 years ago

This should be sorted now that we support up to dotnet 6.0 see: #101

toraritte commented 10 months ago

This issue still happening, unfortunately... Checked everything, dotnet build also shows no errors whatsoever.

Version: 1.84.2 (Universal) Commit: 1a5daa3a0231a0fbba4f14db7ec463cf99d7768e Date: 2023-11-09T10:52:33.687Z Electron: 25.9.2 ElectronBuildId: 24603566 Chromium: 114.0.5735.289 Node.js: 18.15.0 V8: 11.4.183.29-electron.0 OS: Darwin arm64 23.1.0

olstakh commented 9 months ago

Same as @toraritte . Building from command line works, ui shows the message that OP posted. Tried updated version of this (like mentioned in the readme) - worked for me