Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception when running as .NET Core 3 local tool #2406

Closed
nojaf opened this issue Oct 16, 2019 · 12 comments
Closed

Exception when running as .NET Core 3 local tool #2406

nojaf opened this issue Oct 16, 2019 · 12 comments
Labels
needs-repro This issue needs a way to reproduce in order to fix it

Comments

@nojaf
Copy link
Contributor

nojaf commented Oct 16, 2019

Description

When install fake as local tool, every command seems to end with an argument exception.

Repro steps

Please provide the steps required to reproduce the problem

dotnet new tool-manifest

dotnet tool instal fake-cli

touch script.fsx

dotnet fake run script.fsx

Expected behavior

Restores packages and runs empty script.

Actual behavior

PS C:\temp\foo> dotnet fake run .\script.fsx
Consider adding your dependencies via `#r` dependencies, for example add '#r "paket: nuget FSharp.Core //"'.
See https://fake.build/fake-fake5-modules.html for details.
If you know what you are doing you can silence this warning by setting the environment variable 'FAKE_ALLOW_NO_DEPENDENCIES' to 'true'
Updating group Main in C:\temp\foo\.fake\script.fsx\paket.dependencies
Resolving packages for group Main:
 - FSharp.Core 4.7.0
Locked version resolution written to C:\temp\foo\.fake\script.fsx\paket.lock
Extracted Paket.Restore.targets to: C:\temp\foo\.fake\script.fsx\.paket\Paket.Restore.targets (Can be disabled with PAKET_SKIP_RESTORE_TARGETS=true)
Starting full restore process.
C:\temp\foo\script.fsx (1,0)-(1,0): Warning FS0988: Main module of program is empty: nothing will happen when it is run
Performance:
 - Cli parsing: 200 milliseconds
 - Packages: 2 seconds
   - Resolver: 1 second (1 runs)
      - Runtime: 80 milliseconds
      - Blocked (retrieving package details): 596 milliseconds (1 times)
      - Blocked (retrieving package versions): 1 second (1 times)
   - Average Request Time: 403 milliseconds
   - Number of Requests: 3
   - Creating Runtime Graph: 2 milliseconds
   - Retrieve Assembly List: 238 milliseconds
 - Script compiling: 1 second
 - Script analyzing: 36 milliseconds
 - Script running: 0 milliseconds
 - Script cleanup: 0 milliseconds
 - Runtime: 4 seconds

Unhandled Exception: System.IO.IOException: The parameter is incorrect
   at System.ConsolePal.SetConsoleOutputEncoding(Encoding enc)
   at System.Console.set_OutputEncoding(Encoding value)
   at Program.main(String[] args) in d:\a\1\s\src\app\Fake.netcore\Program.fs:line 331

Related information

  • Operating system 10
  • .NET Core 3.0.100
  • Version of FAKE 5.X
@matthid
Copy link
Member

matthid commented Oct 16, 2019

Thanks for the report, it looks like some encoding restore at the very end fails on netcore 3.0. No idea why, maybe some breaking change in netcore?

I guess we can disable that code in netcore v3 if we cannot figure out the root cause

@matthid
Copy link
Member

matthid commented Oct 16, 2019

Note: this is right at the end, argument parsing and running the script already finished successfully

@nojaf
Copy link
Contributor Author

nojaf commented Oct 16, 2019

Yep, I noticed everything does work. It is only somewhat confusing to end with an error.
Could it have something to do with calling commands with dotnet instead of globally using fake run script.fsx?

@matthid
Copy link
Member

matthid commented Oct 16, 2019

It has to do with https://github.com/fsharp/FAKE/blob/e7f52f93018182273a802c4c7c873e57d1d7bcad/src/app/Fake.netcore/Program.fs#L329

Which was the fix for #1461

So I guess we add either a try catch like we do on other places or we find the root case

@matthid
Copy link
Member

matthid commented Oct 19, 2019

@nojaf Interestingly I cannot reproduce this issue, which terminal, shell and language settings are you using on your system?

@matthid
Copy link
Member

matthid commented Oct 19, 2019

Next version will no longer fail but print a warning, but there is still some issue on your system which probably needs fixing

@matthid matthid reopened this Oct 19, 2019
@matthid
Copy link
Member

matthid commented Oct 19, 2019

I assume you can easily reproduce with:

$ dotnet fsi
> open System
> Console.OutputEncoding <- Console.OutputEncoding;;

@nojaf
Copy link
Contributor Author

nojaf commented Oct 19, 2019

I was using hyper on Windows 10

@matthid
Copy link
Member

matthid commented Oct 19, 2019

@nojaf Can you try the dotnet fsi sample from above (ie if it fails with the same error) and tell me what Console.OutputEncoding returns in your shell?

@matthid matthid added the needs-repro This issue needs a way to reproduce in order to fix it label Oct 20, 2019
@nojaf
Copy link
Contributor Author

nojaf commented Oct 21, 2019

image

@matthid
Copy link
Member

matthid commented Oct 21, 2019

And I guess it fails with the line above (encoding<-encoding)?
This looks seriously strange

@github-actions
Copy link
Contributor

There has not been any activity in this issue for the last 3 months so it will be closed in 14 days if there is no activity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-repro This issue needs a way to reproduce in order to fix it
Projects
None yet
Development

No branches or pull requests

2 participants