Skip to content

Update to Fable 2.1 - #378

Merged
forki merged 4 commits into
masterfrom
fable21
Nov 30, 2018
Merged

forki merged 4 commits into
masterfrom
fable21

Conversation

@forki

@forki forki commented Nov 29, 2018

Copy link
Copy Markdown
Member

No description provided.

@forki

forki commented Nov 29, 2018

Copy link
Copy Markdown
Member Author

ok seems it fails for some restore reason @alfonsogarciacaro any ideas?

@alfonsogarciacaro

Copy link
Copy Markdown
Collaborator

Fable automatically restores the F# project (this happens since Fable 2, not new in Fable 2.1). It's weird it gives the "Cannot find restore info" error when trying to restore the project 😕 Maybe because it's invoking a "global" dotnet and FAKE uses a local version?

image

@forki

forki commented Nov 29, 2018

Copy link
Copy Markdown
Member Author

in my production app it fails on ci even weirder:

/usr/bin/yarn webpack-cli --config src/Client/webpack.config.js -p
yarn run v1.12.3
$ /home/gitlab-runner/builds/d5cd2d2a/0/products/eCarApp/node_modules/.bin/webpack-cli --config src/Client/webpack.config.js -p
Bundling for production...
fable-compiler 2.1.0
events.js:183
throw er; // Unhandled 'error' event
^

Error: read ECONNRESET
at _errnoException (util.js:992:11)
at Pipe.onread (net.js:618:25)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Running build failed.

@alfonsogarciacaro

Copy link
Copy Markdown
Collaborator

Yes, it seems in the previous build it was just skipping the command and now Appveyor has 2.1.500 so it conflicts with the local install for some reason.

image

Is this FAKE command always installing the sdk locally? Cannot use the global "dotnet" if it matches the desired version?

@alfonsogarciacaro

Copy link
Copy Markdown
Collaborator

@forki Maybe try to use webpack instead of webpack-cli in your production app?

@forki

forki commented Nov 29, 2018

Copy link
Copy Markdown
Member Author

webpack and webpack-cli give same error.

I think the problem is that fable assumes there is a globally installed dotnet.

@forki

forki commented Nov 29, 2018

Copy link
Copy Markdown
Member Author

I mean we definetly don't want to patch dotnet version every month on all our CI servers, Therefore it's always installed locally - AFAIK we don't have any dotnet installed globally on CI

@alfonsogarciacaro

Copy link
Copy Markdown
Collaborator

I mentioned FAKE and the blame has quickly moved somewhere else ;)

In any case, this is just a convenience, I didn't want the compilation to stop if the restore failed. I'm wrapping the dotnet restore command execution in a try ... with so I don't know why it stops the compilation. Am I doing something wrong?

@alfonsogarciacaro

Copy link
Copy Markdown
Collaborator

AFAIK Dotnet.ProjInfo (which Fable uses to parse the .fsproj file) also uses "dotnet" globally. Is that right @enricosada?

@forki

forki commented Nov 29, 2018

Copy link
Copy Markdown
Member Author

it's not about blame. We just need to find a way that works on usual CI setups. I mean we knew that moving things back to webpack will introduce new edge cases. so it's just about polishing them out

@forki

forki commented Nov 29, 2018 •

Copy link
Copy Markdown
Member Author

ok for testing purposes I do the dotnet restore before calling webpack. but it still fails. I can't really tell if it fails during restore or one step later.

C:\Program Files (x86)\Yarn\bin\yarn.cmd webpack --config src/Client/webpack.config.js -p
yarn run v1.9.4
$ C:\projects\safe-bookstore\node_modules\.bin\webpack --config src/Client/webpack.config.js -p
Bundling for production...
fable-compiler 2.1.0
CWD: C:\projects\safe-bookstore\src\Client
cmd /C "dotnet" restore Client.fsproj
ERROR: MSBuild failed with exitCode -2147450735 Working Directory: 'C:\projects\safe-bookstore\src\Client' Exe Path: 'dotnet' Args: 'msbuild C:\projects\safe-bookstore\src\Client\Client.fsproj /p:SkipCompilerExecution=true /p:ProvideCommandLineArgs=true /p:CopyBuildOutputToOutputDirectory=false /p:UseCommonOutputDirectory=true /t:_Inspect_FscArgs /p:_Inspect_FscArgs_OutFile=C:\Users\appveyor\AppData\Local\Temp\1\tmp7FFA.tmp.FscArgs.txt /p:DesignTimeBuild=true /t:_Inspect_GetResolvedProjectReferences /p:_Inspect_GetResolvedProjectReferences_OutFile=C:\Users\appveyor\AppData\Local\Temp\1\tmp7FFB.tmp.GetResolvedProjectReferences.txt /t:_Inspect_GetProperties /p:_Inspect_GetProperties_OutFile=C:\Users\appveyor\AppData\Local\Temp\1\tmp800B.tmp.GetProperties.txt /p:CustomAfterMicrosoftCommonTargets=C:\Users\appveyor\AppData\Local\Temp\1\tmp801C.tmp.proj-info.hook.targets /nologo /verbosity:quiet'
   at Fable.CLI.ProjectCoreCracker.projInfo(FSharpList`1 additionalMSBuildProps, String file) in /Users/alfonsogarciacaronunez/dev/fable/src/dotnet/Fable.Compiler/CLI/ProjectCoreCracker.fs:line 103
   at Fable.CLI.ProjectCracker.fullCrack(String projFile) in /Users/alfonsogarciacaronunez/dev/fable/src/dotnet/Fable.Compiler/CLI/ProjectCracker.fs:line 199
   at Fable.CLI.ProjectCracker.getCrackedProjectsFromMainFsproj(String projFile) in /Users/alfonsogarciacaronunez/dev/fable/src/dotnet/Fable.Compiler/CLI/ProjectCracker.fs:line 274
   at Fable.CLI.ProjectCracker.retry@295(FSharpChecker checker, String projFile, DateTime retryUntil, Unit unitVar0) in /Users/alfonsogarciacaronunez/dev/fable/src/dotnet/Fable.Compiler/CLI/ProjectCracker.fs:line 297
   at Fable.CLI.ProjectCracker.getFullProjectOpts(FSharpChecker checker, String[] define, String rootDir, String projFile) in /Users/alfonsogarciacaronunez/dev/fable/src/dotnet/Fable.Compiler/CLI/ProjectCracker.fs:line 359
   at Fable.CLI.Agent.createProject(FSharpChecker checker, String[] dirtyFiles, FSharpOption`1 prevProject, Message msg, String projFile) in /Users/alfonsogarciacaronunez/dev/fable/src/dotnet/Fable.Compiler/CLI/Agent.fs:line 57
   at Fable.CLI.Agent.updateState(FSharpChecker checker, FSharpMap`2 state, Message msg) in /Users/alfonsogarciacaronunez/dev/fable/src/dotnet/Fable.Compiler/CLI/Agent.fs:line 190
   at Fable.CLI.Agent.loop@260-7.Invoke(Unit unitVar) in /Users/alfonsogarciacaronunez/dev/fable/src/dotnet/Fable.Compiler/CLI/Agent.fs:line 262
   at Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvoke[T,TResult](AsyncActivation`1 ctxt, TResult result1, FSharpFunc`2 part2)
   at <StartupCode$FSharp-Core>.$Mailbox.processFirstArrival@344-8.Invoke(AsyncActivation`1 ctxt)
   at Microsoft.FSharp.Control.Trampoline.Execute(FSharpFunc`2 firstAction)
Hash: 97d09228b17b55a632bd
Version: webpack 4.26.0
Time: 5261ms
Built at: 11/29/2018 2:30:52 PM
 2 assets
Entrypoint main = vendors.js main.js
[110] multi whatwg-fetch @babel/polyfill ./src/Client/Client.fsproj 52 bytes {0} [built]
[113] (webpack)/buildin/global.js 489 bytes {1} [built]
[279] ./src/Client/Client.fsproj 1.18 KiB {0} [built] [failed] [1 error]
    + 277 hidden modules
ERROR in ./src/Client/Client.fsproj
Module build failed (from ./node_modules/fable-loader/index.js):
Error: MSBuild failed with exitCode -2147450735 Working Directory: 'C:\projects\safe-bookstore\src\Client' Exe Path: 'dotnet' Args: 'msbuild C:\projects\safe-bookstore\src\Client\Client.fsproj /p:SkipCompilerExecution=true /p:ProvideCommandLineArgs=true /p:CopyBuildOutputToOutputDirectory=false /p:UseCommonOutputDirectory=true /t:_Inspect_FscArgs /p:_Inspect_FscArgs_OutFile=C:\Users\appveyor\AppData\Local\Temp\1\tmp7FFA.tmp.FscArgs.txt /p:DesignTimeBuild=true /t:_Inspect_GetResolvedProjectReferences /p:_Inspect_GetResolvedProjectReferences_OutFile=C:\Users\appveyor\AppData\Local\Temp\1\tmp7FFB.tmp.GetResolvedProjectReferences.txt /t:_Inspect_GetProperties /p:_Inspect_GetProperties_OutFile=C:\Users\appveyor\AppData\Local\Temp\1\tmp800B.tmp.GetProperties.txt /p:CustomAfterMicrosoftCommonTargets=C:\Users\appveyor\AppData\Local\Temp\1\tmp801C.tmp.proj-info.hook.targets /nologo /verbosity:quiet'
    at Loader.getCompiler.send.then.err (C:\projects\safe-bookstore\node_modules\fable-loader\index.js:77:22)
    at process._tickCallback (internal/process/next_tick.js:109:7)
 @ multi whatwg-fetch @babel/polyfill ./src/Client/Client.fsproj main[2]
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Running build failed.
Error:
System.Exception: Error while running 'C:\Program Files (x86)\Yarn\bin\yarn.cmd' with args: webpack --config src/Client/webpack.config.js -p
   at FSI_0005.Build.run@41.Invoke(String message) in C:\projects\safe-bookstore\build.fsx:line 41
   at FSI_0005.Build.run(String cmd, String args, String dir) in C:\projects\safe-bookstore\build.fsx:line 41
   at FSI_0005.Build.clo@128-8.Invoke(Unit _arg6) in C:\projects\safe-bookstore\build.fsx:line 129
   at Fake.TargetHelper.runSingleTarget(TargetTemplate`1 target) in D:\code\fake\src\app\FakeLib\TargetHelper.fs:line 626

@alfonsogarciacaro

alfonsogarciacaro commented Nov 29, 2018 •

Copy link
Copy Markdown
Collaborator

Looks like the restore wasn't done properly. I've pushed fable-compiler 2.1.1 trying to ignore the error when calling dotnet restore (not sure if it will work here). But in any case, if CI is installing a local version of the dotnet SDK, it should add the executable to the environment PATH (in fact, I've seen some FAKE scripts do that). There are other places that call dotnet globally (DotnetProj.Info, fable-compiler when running the assembly) and I cannot control them all.

@forki

forki commented Nov 29, 2018

Copy link
Copy Markdown
Member Author

, it should add the executable to the environment PATH

we can certainly do that. Let me update the fable and then we see

@forki

forki commented Nov 29, 2018

Copy link
Copy Markdown
Member Author

"A compatible SDK version for global.json version: [2.1.500] from [C:\projects\safe-bookstore\global.json] was not found"

OK that is now a much better error message. Thanks!

@forki

forki commented Nov 29, 2018

Copy link
Copy Markdown
Member Author

Alternative Idea: would it be possible to set the dotnet path as command line argument to yarn webpack command? Would that make sense?

@MangelMaxime what do you think?

@alfonsogarciacaro

Copy link
Copy Markdown
Collaborator

Well, you first convince @enricosada and then we talk ;)

@MangelMaxime

Copy link
Copy Markdown
Contributor

TBH I don't understand much about global.json so I can't help/advice much. ^^

@forki

forki commented Nov 29, 2018 via email

Copy link
Copy Markdown
Member Author

@forki

forki commented Nov 29, 2018

Copy link
Copy Markdown
Member Author

The global.json is like a lock file for the .NET sdk. I have a hard time making this clear to everyone ;-)
Folks like @isaacabraham always come and advocate against pinning the sdk ;-)

@MangelMaxime

Copy link
Copy Markdown
Contributor

@forki I do understand that this is a lock files.

But what I find frustrating is that if you have on your system:

  • v2.402
  • v2.403
  • v2.500

Because you installed each version one by one. Then it will never found the earlier version.
Perhaps it is erasing them which is kind of stupid :)

For me it should allow different version and be able to find the one you wants. Because when working with OSS project which have different version in the end I just upgrade all of them to the newest version. Which is fine if I own the repo, but when working with Elmish or Fable repo for example then either I upgrade the global.json version and need to remember to not commit that change or I wait 10min that FAKE install the expected version which is just too long and it will do that over and over...

@forki

forki commented Nov 29, 2018 via email

Copy link
Copy Markdown
Member Author

@MangelMaxime

Copy link
Copy Markdown
Contributor

So for libs I should remove it ? 🤔

Sorry to go out of the initial subject ^^

@forki

forki commented Nov 30, 2018 via email

Copy link
Copy Markdown
Member Author

@MangelMaxime

Copy link
Copy Markdown
Contributor

No please don't. It's still making things more explicit

And making people crazy 😂

But ok, I will not then.

@forki

forki commented Nov 30, 2018 via email

Copy link
Copy Markdown
Member Author

@forki

forki commented Nov 30, 2018

Copy link
Copy Markdown
Member Author

ok that fixes the appveyor. but for some reason the UI tests on travis do not work?
can someone with Linux/Mac try to run locally? something wrong with the app on linux!?

@forki

forki commented Nov 30, 2018

Copy link
Copy Markdown
Member Author

screenshot_20181130-095329

So it's not the UI tests. It's still the fable call. I don't really understand what's happening here.

@alfonsogarciacaro shouldn't it at least give different exit code?

@alfonsogarciacaro

Copy link
Copy Markdown
Collaborator

Yes, Fable should display a better error message. I've build this branch locally on my macOS and it run fine. It's and ENOENT problem (No such directory entry) so Travis is still not finding "dotnet", not sure why... and not sure why it worked before 😕

@forki

forki commented Nov 30, 2018 via email

Copy link
Copy Markdown
Member Author

@alfonsogarciacaro

Copy link
Copy Markdown
Collaborator

Hmm, but before Fable was also calling dotnet restore globally and it worked...

@forki

forki commented Nov 30, 2018

Copy link
Copy Markdown
Member Author

mhm dunno.

@alfonsogarciacaro

Copy link
Copy Markdown
Collaborator

Oh, f*ck. After a lot of trial and error I found the issue, PATH separators are different in Windows and Unix 😡 Please use this:

Target "InstallDotNetCore" (fun _ ->
    dotnetExePath <- DotNetCli.InstallDotNetSDK dotnetcliVersion
    let fi = FileInfo dotnetExePath
    let SEPARATOR = if isWindows then ";" else ":"
    Environment.SetEnvironmentVariable(
        "PATH",
        fi.Directory.FullName + SEPARATOR + System.Environment.GetEnvironmentVariable "PATH",
        EnvironmentVariableTarget.Process)
)

It would probably be a good idea to add this as a FAKE helper

@forki

forki commented Nov 30, 2018 via email

Copy link
Copy Markdown
Member Author

@forki
forki merged commit 807ab20 into master Nov 30, 2018
@forki
forki deleted the fable21 branch November 30, 2018 20:48
@forki

forki commented Nov 30, 2018

Copy link
Copy Markdown
Member Author

Ok it's green. Now let's discuss if we really like that approach. Tbh I'm currently very confused about it. I'm not saying it's bad, but I'm also not really amazed about it. There must be a more elegant solution.

@forki

forki commented Dec 1, 2018

Copy link
Copy Markdown
Member Author

Ok cool. https://safebookstore.azurewebsites.net is now proper fable 2.1 app and so is my production app. Thanks a lot!

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

Successfully merging this pull request may close these issues.

3 participants