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

[Cosmetic] When I by mistake #load the main script, it says something about a path being too long #1263

Closed
0x53A opened this issue Jun 5, 2016 · 3 comments

Comments

@0x53A
Copy link
Contributor

0x53A commented Jun 5, 2016

Description

1.fsx

#r @"packages\fake\tools\fakelib.dll"
open Fake

#load "1.fsx" // note that it loads itself.
              // this was a typo, I wanted to load 2.fsx


Target "T1" DoNothing

RunTargetOrDefault "T2"

Expected behavior

FSI actually executes the script twice:
image
The second run fails with a fake exception, if that hadn't happened, it would probably have executed forever (or until a stackoverflowexception)

Including yourself is probably always an error, so I don't really care about that, but it should atleast print a helpful error message.

I hit this by accident with a typo and searched for about an hour what was wrong with my script.

Actual behavior

image

Build failed.
Error:
The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.

Related information

  • Operating system: Win10
  • Version: 4.28.0
  • .NET Runtime: latest Full .Net Framework, I think 4.6.1
@0x53A
Copy link
Contributor Author

0x53A commented Jun 5, 2016

I tested the FSI behaviour again:

#r @"packages\fake\tools\fakelib.dll"
open Fake

#load "1.fsx"

printfn "HELLO"
C:\Users\lr\Source\Repos\FakeCrashTest>"C:\Program Files (x86)\Microsoft SDKs\F#\3.1\Framework\v4.0\fsi.exe" 1.fsx
HELLO
HELLO

C:\Users\lr\Source\Repos\FakeCrashTest>

There is also another difference between FSI and FAKE:

with these 4 scripts:

1.fsx

#load "2.fsx"
#load "3.fsx"

printfn "HELLO FROM 1"

2.fsx

#load "4.fsx"

printfn "HELLO FROM 2"

3.fsx

#load "4.fsx"

printfn "HELLO FROM 3"

4.fsx

printfn "HELLO FROM 4"

C:\Users\lr\Source\Repos\FakeCrashTest>"C:\Program Files (x86)\Microsoft SDKs\F#\3.1\Framework\v4.0\fsi.exe" 1.fsx
HELLO FROM 4
HELLO FROM 2
HELLO FROM 4
HELLO FROM 3
HELLO FROM 1

C:\Users\lr\Source\Repos\FakeCrashTest>packages\fake\tools\fake.exe 1.fsx
HELLO FROM 2
HELLO FROM 4
HELLO FROM 3
HELLO FROM 1

C:\Users\lr\Source\Repos\FakeCrashTest>

In this case I actually like the FAKE behaviour better, because it only executes the side effects once,
BUT the order is wrong: 2 loads 4, but is executed before it.

@matthid
Copy link
Member

matthid commented Jun 9, 2016

Interesting, This looks like a FSharp.Compiler.Service bug. Nice find.
In fact: If you add a type T = T to 4.fsx and change the printfn to printfn "%A" ``4``.T it will crash.

$ /c/Program\ Files\ \(x86\)/Microsoft\ SDKs/F#/4.0/Framework/v4.0/Fsi.exe 1.fsx
HELLO FROM 4
HELLO FROM 2 T
HELLO FROM 4
HELLO FROM 3 T
HELLO FROM 1


$ /c/PROJ/Yaaf.AdvancedBuilding/packages/FAKE/tools/FAKE.exe 1.fsx
FsiEvaluationException:

Error:

        2.fsx(3,27): error FS0039: The namespace or module '4' is not defined


Output: [Loading C:\Test\2.fsx
         Loading C:\Test\4.fsx
         Loading C:\Test\3.fsx
         Loading C:\Test\1.fsx]


Input: C:\Test\1.fsx

Exception: Yaaf.FSharp.Scripting.FsiEvaluationException: Error while compiling or executing fsharp snippet. ---> System.Exception: Operation failed. The error text has been print the error stream. To return the corresponding FSharpErrorInfo use the EvalInteractionNonThrowing, EvalScriptNonThrowing or EvalExpressionNonThrowing
   at Microsoft.FSharp.Compiler.Interactive.Shell.FsiEvaluationSession.commitResult[a,b](FSharpChoice`2 res)
   at Microsoft.FSharp.Compiler.Interactive.Shell.FsiEvaluationSession.EvalScript(String filePath)
   at Yaaf.FSharp.Scripting.Helper.evalScript@1097.Invoke(String arg00) in C:\code\fake\paket-files\matthid\Yaaf.FSharp.Scripting\src\source\Yaaf.FSharp.Scripting\YaafFSharpScripting.fs:line 1097
   at Yaaf.FSharp.Scripting.Helper.save_@1072-2.Invoke(Unit unitVar0) in C:\code\fake\paket-files\matthid\Yaaf.FSharp.Scripting\src\source\Yaaf.FSharp.Scripting\YaafFSharpScripting.fs:line 1073
   at Yaaf.FSharp.Scripting.Helper.consoleCapture[a](TextWriter out, TextWriter err, FSharpFunc`2 f) in C:\code\fake\paket-files\matthid\Yaaf.FSharp.Scripting\src\source\Yaaf.FSharp.Scripting\YaafFSharpScripting.fs:line 1018
   at Yaaf.FSharp.Scripting.Helper.redirectOut@1044[a](Boolean preventStdOut, OutStreamHelper out, OutStreamHelper err, FSharpFunc`2 f) in C:\code\fake\paket-files\matthid\Yaaf.FSharp.Scripting\src\source\Yaaf.FSharp.Scripting\YaafFSharpScripting.fs:line 1051
   at Yaaf.FSharp.Scripting.Helper.save_@1071-1.Invoke(String text) in C:\code\fake\paket-files\matthid\Yaaf.FSharp.Scripting\src\source\Yaaf.FSharp.Scripting\YaafFSharpScripting.fs:line 1072
   --- End of inner exception stack trace ---
   at Yaaf.FSharp.Scripting.Helper.save_@1071-1.Invoke(String text) in C:\code\fake\paket-files\matthid\Yaaf.FSharp.Scripting\src\source\Yaaf.FSharp.Scripting\YaafFSharpScripting.fs:line 1080
   at Yaaf.FSharp.Scripting.Helper.session@1100.Yaaf-FSharp-Scripting-IFsiSession-EvalScriptWithOutput(String ) in C:\code\fake\paket-files\matthid\Yaaf.FSharp.Scripting\src\source\Yaaf.FSharp.Scripting\YaafFSharpScripting.fs:line 1102
   at Fake.FSIHelper.runScriptUncached(Boolean useCache, String scriptPath, IEnumerable`1 fsiOptions, Boolean printDetails, CacheInfo cacheInfo, TextWriter out, TextWriter err) in C:\code\fake\src\app\FakeLib\FSIHelper.fs:line 468
2.fsx(3,27): error FS0039: The namespace or module '4' is not defined

I might send a test case to FSharp.Compiler.Service and then eventually try to fix it. But this might take a good while :). (Really) quickly looking at the source it seems like they revert the order somewhere and then maybe call distinct on the reverted list? Need to test if this happens on the latest visualfsharp code as well, then it might be a regression.

/cc @dsyme

@matthid
Copy link
Member

matthid commented May 6, 2017

I think this has since been fixed up-stream.

@matthid matthid closed this as completed May 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants