fsprojects / fsprojects/Paket

generate-load-scripts does not load transitive dependency Newtonsoft.Json

Open
#3,872 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
F#
Stars
2.1k
Forks
528
Avg merge
1d 12m
Merged PRs (30d)
54

Description

Description

I have an fsx script that uses paket generate-load-scripts output in order to load Nuget dependencies.

In particular:

nuget Thoth.Json
nuget Thoth.Json.Net

However, when I run my script, I get the error:

error FS0074: The type referenced through 'Newtonsoft.Json.Linq.JToken' is defined in an assembly that is not referenced. You must add a reference to assembly 'Newtonsoft.Json'.
Repro steps

Please provide the steps required to reproduce the problem

paket.dependencies

source https://api.nuget.org/v3/index.json

generate_load_scripts: true
storage: none
framework: netcore3.1, netstandard2.0, netstandard2.1
nuget DotNet.Glob 3.0.9
nuget FsToolkit.ErrorHandling 1.4.1
nuget Thoth.Json
nuget Thoth.Json.Net

paket.references

FSharp.Core
FsToolkit.ErrorHandling
Thoth.Json
Thoth.Json.Net
DotNet.Glob

My script (check-data.fsx):

#load @".paket/load/netcoreapp3.1/main.group.fsx"

#load @"components/Types.fs" // This file uses Thoth.Json.Net

Steps:

dotnet restore
dotnet paket install
dotnet paket generate-load-scripts
dotnet fsi ./check-data.fsx
Expected behavior

I would expect the script to run.

Actual behavior

I get this error:

error FS0074: The type referenced through 'Newtonsoft.Json.Linq.JToken' is defined in an assembly that is not referenced. You must add a reference to assembly 'Newtonsoft.Json'.
Known workarounds

I can workaround the error by loading Newtonsoft.Json before the main group:

#load @".paket/load/netcoreapp3.1/Newtonsoft.Json.fsx"
#load @".paket/load/netcoreapp3.1/main.group.fsx"

#load @"components/Types.fs"
Versions etc.
$ dotnet --version
3.1.300

$ dotnet paket --version
Paket version 5.245.2

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the generate-load-scripts entry point and compare paket.dependencies with .paket/load/netcoreapp3.1/main.group.fsx and Newtonsoft.Json.fsx. Reproduce with the listed dotnet and Paket commands, then verify that loading main.group.fsx brings in the transitive Newtonsoft.Json dependency so check-data.fsx runs without the workaround.

Written by the indexing model from the issue text.

Assessment

Tech stack
fsharp
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.