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

NuGet directives will get error #106

Closed
gaba-xyz opened this issue Dec 2, 2016 · 18 comments
Closed

NuGet directives will get error #106

gaba-xyz opened this issue Dec 2, 2016 · 18 comments

Comments

@gaba-xyz
Copy link

gaba-xyz commented Dec 2, 2016

Have tried both on Azure Notebooks and running the latest docker image locally.

Steps to reproduce

In a new cell:
#N "Newtonsoft.Json"

Results

NuGet error: Unable to find package 'Newtonsoft.Json'.

@cgravill
Copy link
Member

cgravill commented Dec 2, 2016

I'm not sure what's wrong with the NuGet functionality (I'll look into it)

In the meantime, you can use Paket to do this:

#load "Paket.fsx"
Paket.Version ["Newtonsoft.Json", "~> 9.0.1"]

then:

#r @"packages\Newtonsoft.Json\lib\net45\Newtonsoft.Json.dll"

@dsyme
Copy link
Contributor

dsyme commented Dec 2, 2016

@cgravill
Copy link
Member

cgravill commented Dec 2, 2016

I've just updated the documentation to use Paket, for example you can do this now:

#load "Paket.fsx"
Paket.Package ["Newtonsoft.Json"; "FSharp.Compiler.Service"]

#r @"packages\Newtonsoft.Json\lib\net45\Newtonsoft.Json.dll"
#r @"packages\FSharp.Compiler.Service\lib\net45\FSharp.Compiler.Service.dll"

@OverlyExcessive do you have a specific need for the NuGet client? It's implemented using a very old NuGet binary. We could try to update that and fix this in the process. There is some discussion of updating in #77 but nothing came of it so far.

Personally I'd recommend completely switching to Paket, that's what I've done in my notebooks.

@cgravill
Copy link
Member

cgravill commented Dec 2, 2016

@dsyme I get an Access Denied on that link:

image

It might not be possible to share links like this to Azure Notebooks.

@forki
Copy link
Member

forki commented Dec 2, 2016

@cgravill this is really interesting (and awesome!).
Is it also possible to reference a lock file? For production use we should not resolve packages in the script, but use a pinned resolution. This one of the major things why we created paket.

@cgravill
Copy link
Member

cgravill commented Dec 2, 2016

@forki we very much appreciate pinning, and Paket in general. I think because we're creating the .lock file then even without specifying a version we're going to be stable which makes this strictly better than the previous raw NuGet (though that could specify a version as well).

When implementing this we had a few discussions of if you should do all the dependencies externally. However, it's really nice to have your dependencies stated at the top of your notebook as it lets our scientists reliably share notebooks (if you specify versions).

@forki
Copy link
Member

forki commented Dec 2, 2016 via email

@cgravill
Copy link
Member

cgravill commented Dec 2, 2016

The lock file we install is: https://github.com/fsprojects/IfSharp/blob/4c7a387d5d38c44283a06619dc6df95e42ba1f51/src/IfSharp.Kernel/helpers/paket.lock which is now empty at install time. We previously took a more batteries included approach and installed fslab etc. Now we do it on-demand.

One thing I really like is that it's done (by @sylvanc and @npmurphy) with .fsx and intended to be user serviceable. It's also fairly shallow wrappers around Paket.Core.dll which people can call into directly. It would be great to have your input on how best to interact with Paket.

@sylvanc
Copy link
Collaborator

sylvanc commented Dec 2, 2016

The current approach also allows:

Paket.Version
  [ "Some.Thing", "~> 3.4.5"
    "Other.Thing", "~> 0.1.2"
  ]

It's not a .lock file, of course :) But it does allow explicit versioning. As @cgravill said, we would of course be super keen on any ideas you have to improve this.

@gaba-xyz
Copy link
Author

gaba-xyz commented Dec 2, 2016

@cgravill I wasn't aware that paket was included. That will work fine for me. Although it would have been nice if it would have added the references to the assemblies like the #N directive did.

@cgravill
Copy link
Member

cgravill commented Dec 2, 2016

Excellent, Paket really is a much nicer way to go about adding dependencies.

We might be able to bring back automatic references, I can see how it's useful and it's actually quite separate from how you acquire the nugets. @sylvanc what do you think about this and the #107 pull request?

It would be really nice if we could automatically figure out the ordering of dlls, that's been hassle before with fsi for me.

@cgravill
Copy link
Member

cgravill commented Dec 2, 2016

Looks like @forki is way ahead on this one:
https://twitter.com/chrsteinert/status/804675768974446592

@dsyme
Copy link
Contributor

dsyme commented Dec 3, 2016

@cgravill @forki As an aside I'm really keen on using generated load scripts where possible. The API is a bit clunky but the path is much better in the long term than referencing DLLs under packages directly:

e.g.

#load "Paket.fsx"

Paket.Dependencies.Install """
frameworks: net45
source https://nuget.org/api/v2
nuget FSharp.Data
nuget XPlot.Plotly
"""

Paket.LoadingScripts.ScriptGeneration.generateScriptsForRootFolder Paket.LoadingScripts.ScriptGeneration.FSharp (Paket.FrameworkIdentifier.DotNetFramework Paket.FrameworkVersion.V4_5)  (System.IO.DirectoryInfo __SOURCE_DIRECTORY__)

then

#load "paket-files/include-scripts/net45/include.main.group.fsx"

One reason is that this path is fully tested in Paket and scales to all Paket features, without creating new API surface area.

I'm not using Paket.Package yet in the Azure notebook samples. That's partly because there's an issue over which directory the packages get placed in, and whether that directory is independent of other notebooks. Right now every notebook sharing the same docker instance uses the shared /home/nbuser directory (when using Paket.Dependencies.Install) and some shared ...bin directory when using Paket.Package. Both are incorrect because these directories are shared between multiple notebook instances

Note that in Azure Notebooks the SOURCE_DIRECTORY value is currently /home/nbuser.

For Azure notebooks let's get this sorted out on Monday

@dsyme
Copy link
Contributor

dsyme commented Dec 3, 2016

@cgravill Correct link is https://notebooks.azure.com/library/fsharp-templates/html/fsharp-data-usa-states-example.ipynb, thanks. The tables don't display properly in the preview, I've told the Azure Notebooks team about that

@dsyme
Copy link
Contributor

dsyme commented Dec 3, 2016

Added #112 for the SOURCE_DIRECTORY issue

@hanpari
Copy link

hanpari commented Dec 17, 2016

What about to cancel "#N" directive if it is not working?
It is confusing. I wanted to try this one:

http://numerics.mathdotnet.com/IFSharpNotebook.html

And then (after error) I found this issue.

@cgravill
Copy link
Member

Hi @hanpari yes, we've actually removed this with #107 where I also provide some conversion support. This is merged to master. Next time we do a release it'll be included.

The example there will need several updates to be current with what we have now.

@sylvanc
Copy link
Collaborator

sylvanc commented Jan 9, 2017

Closing, as #107 provides conversion support.

@sylvanc sylvanc closed this as completed Jan 9, 2017
cgravill added a commit that referenced this issue Feb 9, 2017
NuGet stopped working at some point #106 and everyone who might fix it
had already moved to Paket #107. Simplify the leftover code and very old
NuGet dll.
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

6 participants