Fable: locked fs files more often during watch recompilation

Created on 20 Nov 2017  Â·  10Comments  Â·  Source: fable-compiler/Fable

Description

When working on ts2fabel, I run dotnet fable yarn-watch from the src directory a lot. Since upgrading to Fable 1.3.0, I appear to run into a .fs file being locked much more often:

fable: Compilation started at 11:51:03
Parsing ./ts2fable.fs...
ERROR: The process cannot access the file 'C:\Users\camer\fs\ts2fable\src\ts2fable.fs' because it is being used by another process.
   at System.IO.FileStream.OpenHandle(FileMode mode, FileShare share, FileOptions options)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
   at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize)
   at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks)
   at System.IO.File.InternalReadAllText(String path, Encoding encoding)
   at System.IO.File.ReadAllText(String path)
   at [email protected](String dirtyFile)
   at Microsoft.FSharp.Collections.ArrayModule.Fold[T,TState](FSharpFunc`2 folder, TState state, T[] array)
   at Fable.CLI.StateUtil.createProject(FSharpChecker checker, String[] dirtyFiles, FSharpOption`1 prevProject, Message msg, String projFile)
   at Fable.CLI.StateUtil.checkWatchCompilation@143(FSharpChecker checker, Message msg, FSharpMap`2 state, Project project, String sourceFile)
   at [email protected](String _arg1, Project project)
   at Fable.CLI.StateUtil.updateState(FSharpChecker checker, FSharpMap`2 state, Message msg)
   at [email protected](Tuple`2 _arg1)
ERROR: The process cannot access the file 'C:\Users\camer\fs\ts2fable\src\ts2fable.fs' because it is being used by another process.

I simply stop the watch with a ctrl+c and rerun.

Related information

  • Fable version (dotnet fable --version): 1.3.0
  • Operating system: Windows 10
waiting-feedback

Most helpful comment

Mhm no idea, but ionide locks files now. @Krzysztof-Cieslak

Am 25.11.2017 12:02 schrieb "Alfonso Garcia-Caro" <[email protected]

:

Hmm, I haven't been able to reproduce it yet. I guess it only affects
Windows. I tried 1.3.2 on Windows but just very quickly and with a small
project. Someone else is seeing this? Any ideas? @MangelMaxime
https://github.com/mangelmaxime @inosik https://github.com/inosik
@forki https://github.com/forki

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/fable-compiler/Fable/issues/1240#issuecomment-346933680,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AADgNP2T_O4oXS5V9_VTnqilq5HOJsAZks5s5_PhgaJpZM4QkZCQ
.

All 10 comments

Hmm, this doesn't happen with Webpack, but the fable-splitter file watcher is more rudimentary. I wonder how can we fix, supposedly this was introduced to avoid those problems 😕

Is this problem related? (got it since 1.3 I think. I'm on 1.3.2 and exact same problem)

image

I simply stop the watch with a ctrl+c and rerun.

Saving the file again after the error was raised also works

Hmm, I haven't been able to reproduce it yet. I guess it only affects Windows. I tried 1.3.2 on Windows but just very quickly and with a small project. Someone else is seeing this? Any ideas? @MangelMaxime @inosik @forki

Mhm no idea, but ionide locks files now. @Krzysztof-Cieslak

Am 25.11.2017 12:02 schrieb "Alfonso Garcia-Caro" <[email protected]

:

Hmm, I haven't been able to reproduce it yet. I guess it only affects
Windows. I tried 1.3.2 on Windows but just very quickly and with a small
project. Someone else is seeing this? Any ideas? @MangelMaxime
https://github.com/mangelmaxime @inosik https://github.com/inosik
@forki https://github.com/forki

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/fable-compiler/Fable/issues/1240#issuecomment-346933680,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AADgNP2T_O4oXS5V9_VTnqilq5HOJsAZks5s5_PhgaJpZM4QkZCQ
.

A little expreience:
The vscode will automaticlly lock file while it is saving
So just wait a while may get it worked

                    let rec read() =
                        try 
                            File.readAsString(change.FullPath)
                        with ex ->
                            Thread.Sleep(100)
                            read()
                    read()

Still happens on my side from time to time. So maybe you found the reason @humhei. Will try that!

What version are you using @humhei? In principle files shouldn't be locked while reading now.

Maybe have been fixed..... I didn't test it.. (- -)
I just encounted the some issue in my use case (A binding to vscode file and excel cell value)
image

Let's close the issue, please reopen if you still have problems.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nozzlegear picture nozzlegear  Â·  3Comments

stkb picture stkb  Â·  3Comments

MangelMaxime picture MangelMaxime  Â·  3Comments

forki picture forki  Â·  3Comments

alfonsogarciacaro picture alfonsogarciacaro  Â·  3Comments