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

Very hard to start using FAKE 5 on linux #1675

Closed
oscarvarto opened this issue Sep 23, 2017 · 11 comments
Closed

Very hard to start using FAKE 5 on linux #1675

oscarvarto opened this issue Sep 23, 2017 · 11 comments

Comments

@oscarvarto
Copy link

I spent several hours trying to use FAKE 5 on Ubuntu Linux 16.04 LTS, following (scarce) guidance from https://fake.build/fake-commandline.html

I am willing to contribute with development to the F# ecosystem on Unix (specially Linux), but need help to get started.
I am willing to contribute to FAKE 5 development, but need help.

Help please!

@matthid
Copy link
Member

matthid commented Sep 23, 2017

I'd really like to help but usually you would just download & extract the linux binary release, write a script and execute 'fake run script.fsx'.

Can you be more specific about the errors you are encountering? Our error messages might not be the most user friendly ones of the world but we are still in alpha phase...

@oscarvarto
Copy link
Author

oscarvarto commented Sep 23, 2017

@matthid I usually write more specific error information on the issues I find, but this time I was in a rush, sorry about that.

I am not at my computer at this moment, but will try to describe what I remember:

I started a Dotnet Core 2.0 F# console project with:

$ dotnet new console -lang "F#" -o HelloFake

By the way, dotnet cli chokes on the hash in F#. I think it has to do with zsh (that's what I use instead of bash).

I had already downloaded Fake and added to my $PATH using
https://github.com/fsharp/FAKE/blob/master/.travis.yml#L14-L18

Then I created a build.fsx with

(* -- Fake Dependencies paket-inline
source https://nuget.org/api/v2

nuget Fake.Core.Targets prerelease
nuget FSharp.Core prerelease
-- Fake Dependencies -- *)

open Fake.Core // Errors start from this line on
open Fake.Core.Target // I think the guide mispelled this by adding an trailing `s`

Target "Clean" (fun () ->  trace " --- Cleaning stuff --- ")

Target "Build" (fun () ->  trace " --- Building the app --- ")

Target "Deploy" (fun () -> trace " --- Deploying app --- ")

"Clean"
  ==> "Build"
  ==> "Deploy"

RunTargetOrDefault "Deploy"

Then, after running $ fake run build.fsx I get errors because it cannot see the my new paket.dependencies

I had to add environment variables:
$ export APPDATA=$HOME AppLocalData=$HOME

It starts downloading stuff, and I added

#I ".paket/inner-dir-to-Fake.Core.Targets.dll"
#r "Fake.Core.Targets.dll"

Now Ionide does not complain about not being able to find

Open Fake.Core // Still not finding this
Open Fake.Core.Targets // this is ok

And more erroors in every Target below

I don't know if I am supposed to manually write down the path for my still not found dlls neither which ones I am missing.

Also the originall post here:
https://fake.build/fake-commandline.html

adds this at the paket-inline source ../../../nuget/dotnetcore

I think that is hardcoding something that is particular to someone else's setup.

What am I missing?

@matthid
Copy link
Member

matthid commented Sep 23, 2017

No problem. Yes you did in fact run into a couple of issues, which are already fixed (but not yet released).

  1. The docs are outdated, the API for "Targets" changed slightly: https://fake.build/core-targets.html
    Note that is will probably change again soon, but we hopefully will update all docs this time. Sorry for that

  2. Now Ionide does not complain about not being able to find

    I'm on that one, I'm still trying to find a good way to provide tooling support, but netcore scripts are not supported anywhere at the moment. I hope we can provide a workaround soonish, see How to support FAKE 5 script files? ionide/ionide-vscode-fsharp#558 (comment)

    The only workaround to get tooling to work is to download the FAKE-5 (old-style FAKE) nuget package as well and reference it conditionally, like:

    #if !FAKE
    #r "packages/build/FAKE/tools/FakeLib.dll"
    #endif
    

    But this is really really ugly.

  3. https://fake.build/fake-commandline.html source ../../../nuget/dotnetcore

    Yes we probably should remove that line from the docs, thanks.

Thanks for testing and reporting back!

@oscarvarto
Copy link
Author

I kept trying for some more moments. I keep getting error after error.
I will come back to stuff like this when I can read proper documentation or get a build that works.

I feel like I am wasting too much time debugging stuff.

@matthid
Copy link
Member

matthid commented Sep 23, 2017

I keep getting error after error.

Please keep reporting them, otherwise nobody can fix anything...

@oscarvarto
Copy link
Author

oscarvarto commented Sep 23, 2017

@matthid I got frustrated, sorry. I will keep going, though.

Current contents of build.fsx:

(* -- Fake Dependencies paket-inline
source https://nuget.org/api/v2

nuget Fake prerelease
nuget FSharp.Core ~> 4.2.3 redirects: force
group Main
-- Fake Dependencies -- *)

#I ".fake/build.fsx/packages/FAKE/tools"
#r "FakeLib.dll"

(*
#I "/home/oscarvarto/bin/fake-dotnetcore"
#r "mscorlib.dll"
*)

open Fake.Core
open Fake.Core.TargetOperators
open Fake.Core.Trace

Target.Create "Clean" (fun _ -> trace "--- Cleaning project ---")

Target.Create "Build" (fun _ -> trace "--- Building project ---")

"Clean"
    ==> "Build"

Target.RunOrDefault "Clean"

Trying again:

$ fake run build.fsx -t Clean
Last restore is still up 2 date.
Build failed.
Error:
Compilation failed:
unknown (1,0)-(1,0): Error FS0074: The type referenced through 'System.Collections.IComparer' is defined in an assembly that is not referenced. You must add a reference to assembly 'mscorlib'.

If I try referencing mscorlib.dll from my /home/bin/fake-dotnetcore:

(* -- Fake Dependencies paket-inline
source https://nuget.org/api/v2

nuget Fake prerelease
nuget FSharp.Core ~> 4.2.3 redirects: force
group Main
-- Fake Dependencies -- *)

#I ".fake/build.fsx/packages/FAKE/tools"
#r "FakeLib.dll"

#I "/home/oscarvarto/bin/fake-dotnetcore"
#r "mscorlib.dll"

// rest elided...

Then I get:

$ fake run build.fsx -t Clean
Last restore is still up 2 date.
Build failed.
Error:
Compilation failed:
/home/oscarvarto/gitRepos/dotnetWork/HelloFake/build.fsx (13,0)-(13,17): Error FS1108: The type 'IComparer' is required here and is unavailable. You must add a reference
 to assembly 'System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'.

So, it seems like I would have to keep referencing missing stuff...

I must say that I also had (previously added) this to my .zshrenv (see dotnet/docs#3180 (comment)):

export FrameworkPathOverride=/Library/Frameworks/Mono.framework/Versions/5.2.0/lib/mono/4.6.2-api

@matthid
Copy link
Member

matthid commented Sep 23, 2017

Definitely something I have not seen before, thanks.

Can you remove nuget Fake prerelease ? Sorry I shouldn't have started with the regular Fake package as it is quite complicated, usually only the new "modules" should be used (like nuget Fake.Core.Targets prerelease)

It is really interesting that you run into so many issues. Currently I released alpha016 but it somehow is broken as well so please stay on alpha015 for now.

So to reiterate is the following working for you?

(* -- Fake Dependencies paket-inline
source https://nuget.org/api/v2
storage: none
nuget Fake.Core.Targets prerelease
group Main
-- Fake Dependencies -- *)
printfn "test"

Note that you might want to delete the .fake folder just to be sure to start from a clean state.
If that works you should be able to add targets. Once that works you should be able to add further modules and code (whenever you add new modules you need to delete .fake or .fake/scriptname.fsx/paket.lock such that fake picks-up the new dependencies)...

Note that manual #r or #I lines are not (or should not be) required.

@matthid
Copy link
Member

matthid commented Sep 23, 2017

storage: none is not actually required but it will speed up the process a bit and make the size of the .fake folder smaller.

@oscarvarto
Copy link
Author

After starting from scratch with $ dotnet new console -lang "F#" -o BuildingStuff, then:

oscarvarto@lap ~/gitRepos/dotnetWork/BuildingStuff$ fake run build.fsx
Updating group Main in .fake/build.fsx/paket.dependencies
Resolving packages for group Main:
 - Fake.Core.Targets 5.0.0-alpha016
 - Fake.Core.BuildServer 5.0.0-alpha016
 - Fake.Core.Context 5.0.0-alpha016
 - Fake.Core.Environment 5.0.0-alpha016
 - Fake.Core.String 5.0.0-alpha016
 - Fake.Core.Tracing 5.0.0-alpha016
 - FSharp.Core 4.2.3
 - NETStandard.Library 2.0.0
 - System.Net.Http 4.3.3
 - Microsoft.Win32.Primitives 4.3.0
 - System.AppContext 4.3.0
 - System.Collections 4.3.0
 - System.Collections.Concurrent 4.3.0
 - System.Console 4.3.0
 - System.Diagnostics.Debug 4.3.0
 - System.Diagnostics.Tools 4.3.0
 - System.Diagnostics.Tracing 4.3.0
 - System.Globalization 4.3.0
 - System.Globalization.Calendars 4.3.0
 - System.IO 4.3.0
 - System.IO.Compression 4.3.0
 - System.IO.Compression.ZipFile 4.3.0
 - System.IO.FileSystem 4.3.0
 - System.IO.FileSystem.Primitives 4.3.0
 - System.Linq 4.3.0
 - System.Linq.Expressions 4.3.0
 - System.Net.Primitives 4.3.0
 - System.Net.Sockets 4.3.0
 - System.ObjectModel 4.3.0
 - System.Reflection 4.3.0
 - System.Reflection.Extensions 4.3.0
 - System.Reflection.Primitives 4.3.0
 - System.Resources.ResourceManager 4.3.0
 - System.Runtime 4.3.0
 - System.Runtime.Extensions 4.3.0
 - System.Runtime.Handles 4.3.0
 - System.Runtime.InteropServices 4.3.0
 - System.Runtime.InteropServices.RuntimeInformation 4.3.0
 - System.Runtime.Numerics 4.3.0
 - System.Security.Cryptography.Algorithms 4.3.0
 - System.Security.Cryptography.Encoding 4.3.0
 - System.Security.Cryptography.Primitives 4.3.0
 - System.Security.Cryptography.X509Certificates 4.3.1
 - System.Text.Encoding 4.3.0
 - System.Text.Encoding.Extensions 4.3.0
 - System.Text.RegularExpressions 4.3.0
 - System.Threading 4.3.0
 - System.Threading.Tasks 4.3.0
 - System.Threading.Timer 4.3.0
 - System.Xml.ReaderWriter 4.3.0
 - System.Xml.XDocument 4.3.0
 - System.Net.Requests 4.3.0
 - System.Threading.ThreadPool 4.3.0
 - System.Linq.Queryable 4.3.0
 - System.Threading.Tasks.Parallel 4.3.0
 - System.Threading.Thread 4.3.0
 - Microsoft.NETCore.Platforms 2.0.0
 - runtime.native.System.Security.Cryptography.OpenSsl 4.3.2
 - runtime.native.System 4.3.0
 - runtime.native.System.IO.Compression 4.3.1
 - System.Buffers 4.4.0
 - System.Reflection.Emit 4.3.0
 - System.Reflection.Emit.ILGeneration 4.3.0
 - System.Reflection.Emit.Lightweight 4.3.0
 - System.Reflection.TypeExtensions 4.4.0
 - runtime.native.System.Net.Http 4.3.0
 - System.Diagnostics.DiagnosticSource 4.4.1
 - System.Globalization.Extensions 4.3.0
 - System.Security.Cryptography.OpenSsl 4.4.0
 - System.Net.WebHeaderCollection 4.3.0
 - runtime.native.System.Security.Cryptography.Apple 4.3.1
 - System.Security.Cryptography.Cng 4.4.0
 - System.Security.Cryptography.Csp 4.3.0
 - System.Threading.Tasks.Extensions 4.4.0
 - Microsoft.NETCore.Targets 2.0.0
 - runtime.debian.8-x64.runtime.native.System.Security.Cryptography.OpenSsl 4.3.2
 - runtime.fedora.23-x64.runtime.native.System.Security.Cryptography.OpenSsl 4.3.2
 - runtime.fedora.24-x64.runtime.native.System.Security.Cryptography.OpenSsl 4.3.2
 - runtime.opensuse.13.2-x64.runtime.native.System.Security.Cryptography.OpenSsl 4.3.2
 - runtime.opensuse.42.1-x64.runtime.native.System.Security.Cryptography.OpenSsl 4.3.2
 - runtime.osx.10.10-x64.runtime.native.System.Security.Cryptography.OpenSsl 4.3.2
 - runtime.rhel.7-x64.runtime.native.System.Security.Cryptography.OpenSsl 4.3.2
 - runtime.ubuntu.14.04-x64.runtime.native.System.Security.Cryptography.OpenSsl 4.3.2
 - runtime.ubuntu.16.04-x64.runtime.native.System.Security.Cryptography.OpenSsl 4.3.2
 - runtime.ubuntu.16.10-x64.runtime.native.System.Security.Cryptography.OpenSsl 4.3.2
 - runtime.osx.10.10-x64.runtime.native.System.Security.Cryptography.Apple 4.3.1
Locked version resolution written to /home/oscarvarto/gitRepos/dotnetWork/BuildingStuff/.fake/build.fsx/paket.lock
Downloading Fake.Core.BuildServer 5.0.0-alpha016
Downloading Fake.Core.Environment 5.0.0-alpha016
Downloading Fake.Core.String 5.0.0-alpha016
Downloading Fake.Core.Context 5.0.0-alpha016
Downloading Fake.Core.Tracing 5.0.0-alpha016
Downloading Fake.Core.Targets 5.0.0-alpha016
test

It is working!

@matthid
Copy link
Member

matthid commented Sep 23, 2017

Also note that a netcore project is not actually required to use FAKE. (but you most likely want to use FAKE to build the project I guess)

Also please feel free to ping me on gitter slack or here on github if you encounter issues. Even if it is already explained somewhere at least it helps to understand where issues for new users are and where we need to improve docs or error messages

matthid added a commit that referenced this issue Sep 25, 2017
@matthid
Copy link
Member

matthid commented Feb 4, 2018

I think this point has been addressed. Additionally we now have a getting started guide: https://fake.build/fake-gettingstarted.html

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

No branches or pull requests

2 participants