<p>As mentioned by @Erik De Castro Lopo in the comments, this issue was resolved by adding the same index-state line in my cabal.project file as that of cardano-node.</p>

CC BY-SA 4.0
2022-07-31T02:53:13.257Z
2022-07-31T02:53:13.257Z
Attilah
<p>I have included cardano-prelude as a dependency in my project's cabal.project file: <a href="https://github.com/omefire/api-server/blob/main/cabal.project" rel="nofollow noreferrer">https://github.com/omefire/api-server/blob/main/cabal.project</a></p>
<p>However, when I try to build the project with cabal build, I always end up getting this error:</p>
<pre><code>...
[ 7 of 14] Compiling Cardano.Prelude.GHC.Heap ( src/Cardano/Prelude/GHC/Heap.hs, dist/build/Cardano/Prelude/GHC/Heap.o, dist/build/Cardano/Prelude/GHC/Heap.dyn_o )
[ 8 of 14] Compiling Cardano.Prelude.HeapWords ( src/Cardano/Prelude/HeapWords.hs, dist/build/Cardano/Prelude/HeapWords.o, dist/build/Cardano/Prelude/HeapWords.dyn_o )
[ 9 of 14] Compiling Cardano.Prelude.Json.Parse ( src/Cardano/Prelude/Json/Parse.hs, dist/build/Cardano/Prelude/Json/Parse.o, dist/build/Cardano/Prelude/Json/Parse.dyn_o )
[10 of 14] Compiling Cardano.Prelude.Json.Canonical ( src/Cardano/Prelude/Json/Canonical.hs, dist/build/Cardano/Prelude/Json/Canonical.o, dist/build/Cardano/Prelude/Json/Canonical.dyn_o )

src/Cardano/Prelude/Json/Canonical.hs:110:14: error:
    • Could not deduce (Buildable e2)
        arising from a use of ‘parseJSString’
      from the context: ReportSchemaErrors m
        bound by the instance declaration
        at src/Cardano/Prelude/Json/Canonical.hs:109:10-50
      The type variable ‘e2’ is ambiguous
      These potential instances exist:
        instance Buildable Void -- Defined in ‘Formatting.Buildable’
        instance Buildable IntPtr -- Defined in ‘Formatting.Buildable’
        instance Buildable WordPtr -- Defined in ‘Formatting.Buildable’
        ...plus 24 others
        ...plus 12 instances involving out-of-scope types
        (use -fprint-potential-instances to see them all)
    • In the expression: parseJSString (readEither . toS)
      In an equation for ‘fromJSON’:
          fromJSON = parseJSString (readEither . toS)
      In the instance declaration for ‘FromJSON m Word64’
    |
110 |   fromJSON = parseJSString (readEither . toS)
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

src/Cardano/Prelude/Json/Canonical.hs:110:29: error:
    • Could not deduce (Protolude.Conv.StringConv e2 GHC.Base.String)
        arising from a use of ‘readEither’
      from the context: ReportSchemaErrors m
        bound by the instance declaration
        at src/Cardano/Prelude/Json/Canonical.hs:109:10-50
      The type variable ‘e2’ is ambiguous
      These potential instances exist:
        instance Protolude.Conv.StringConv ByteString GHC.Base.String
          -- Defined in ‘Protolude.Conv’
        instance Protolude.Conv.StringConv LB.ByteString GHC.Base.String
          -- Defined in ‘Protolude.Conv’
        instance Protolude.Conv.StringConv Text GHC.Base.String
          -- Defined in ‘Protolude.Conv’
        ...plus one other
        ...plus one instance involving out-of-scope types
        (use -fprint-potential-instances to see them all)
    • In the first argument of ‘(.)’, namely ‘readEither’
      In the first argument of ‘parseJSString’, namely
        ‘(readEither . toS)’
      In the expression: parseJSString (readEither . toS)
    |
110 |   fromJSON = parseJSString (readEither . toS)
    |                             ^^^^^^^^^^

src/Cardano/Prelude/Json/Canonical.hs:110:42: error:
    • Could not deduce (ConvertText Text e2)
        arising from a use of ‘toS’
      from the context: ReportSchemaErrors m
        bound by the instance declaration
        at src/Cardano/Prelude/Json/Canonical.hs:109:10-50
      The type variable ‘e2’ is ambiguous
      These potential instances exist:
        instance [safe] ConvertText Text Text
          -- Defined in ‘Protolude.ConvertText’
        instance [safe] ConvertText Text GHC.Base.String
          -- Defined in ‘Protolude.ConvertText’
        ...plus one instance involving out-of-scope types
        (use -fprint-potential-instances to see them all)
    • In the second argument of ‘(.)’, namely ‘toS’
      In the first argument of ‘parseJSString’, namely
        ‘(readEither . toS)’
      In the expression: parseJSString (readEither . toS)
    |
110 |   fromJSON = parseJSString (readEither . toS)
    |                                          ^^^

src/Cardano/Prelude/Json/Canonical.hs:113:14: error:
    • Could not deduce (Buildable e1)
        arising from a use of ‘parseJSString’
      from the context: ReportSchemaErrors m
        bound by the instance declaration
        at src/Cardano/Prelude/Json/Canonical.hs:112:10-51
      The type variable ‘e1’ is ambiguous
      These potential instances exist:
        instance Buildable Void -- Defined in ‘Formatting.Buildable’
        instance Buildable IntPtr -- Defined in ‘Formatting.Buildable’
        instance Buildable WordPtr -- Defined in ‘Formatting.Buildable’
        ...plus 24 others
        ...plus 12 instances involving out-of-scope types
        (use -fprint-potential-instances to see them all)
    • In the expression: parseJSString (readEither . toS)
      In an equation for ‘fromJSON’:
          fromJSON = parseJSString (readEither . toS)
      In the instance declaration for ‘FromJSON m Integer’
    |
113 |   fromJSON = parseJSString (readEither . toS)
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

src/Cardano/Prelude/Json/Canonical.hs:113:29: error:
    • Could not deduce (Protolude.Conv.StringConv e1 GHC.Base.String)
        arising from a use of ‘readEither’
      from the context: ReportSchemaErrors m
        bound by the instance declaration
        at src/Cardano/Prelude/Json/Canonical.hs:112:10-51
      The type variable ‘e1’ is ambiguous
      These potential instances exist:
        instance Protolude.Conv.StringConv ByteString GHC.Base.String
          -- Defined in ‘Protolude.Conv’
        instance Protolude.Conv.StringConv LB.ByteString GHC.Base.String
          -- Defined in ‘Protolude.Conv’
        instance Protolude.Conv.StringConv Text GHC.Base.String
          -- Defined in ‘Protolude.Conv’
        ...plus one other
        ...plus one instance involving out-of-scope types
        (use -fprint-potential-instances to see them all)
    • In the first argument of ‘(.)’, namely ‘readEither’
      In the first argument of ‘parseJSString’, namely
        ‘(readEither . toS)’
      In the expression: parseJSString (readEither . toS)
    |
113 |   fromJSON = parseJSString (readEither . toS)
    |                             ^^^^^^^^^^

src/Cardano/Prelude/Json/Canonical.hs:113:42: error:
    • Could not deduce (ConvertText Text e1)
        arising from a use of ‘toS’
      from the context: ReportSchemaErrors m
        bound by the instance declaration
        at src/Cardano/Prelude/Json/Canonical.hs:112:10-51
      The type variable ‘e1’ is ambiguous
      These potential instances exist:
        instance [safe] ConvertText Text Text
          -- Defined in ‘Protolude.ConvertText’
        instance [safe] ConvertText Text GHC.Base.String
          -- Defined in ‘Protolude.ConvertText’
        ...plus one instance involving out-of-scope types
        (use -fprint-potential-instances to see them all)
    • In the second argument of ‘(.)’, namely ‘toS’
      In the first argument of ‘parseJSString’, namely
        ‘(readEither . toS)’
      In the expression: parseJSString (readEither . toS)
    |
113 |   fromJSON = parseJSString (readEither . toS)
    |                                          ^^^

src/Cardano/Prelude/Json/Canonical.hs:116:14: error:
    • Could not deduce (Buildable e0)
        arising from a use of ‘parseJSString’
      from the context: MonadError SchemaError m
        bound by the instance declaration
        at src/Cardano/Prelude/Json/Canonical.hs:115:10-55
      The type variable ‘e0’ is ambiguous
      These potential instances exist:
        instance Buildable Void -- Defined in ‘Formatting.Buildable’
        instance Buildable IntPtr -- Defined in ‘Formatting.Buildable’
        instance Buildable WordPtr -- Defined in ‘Formatting.Buildable’
        ...plus 24 others
        ...plus 12 instances involving out-of-scope types
        (use -fprint-potential-instances to see them all)
    • In the expression: parseJSString (readEither . toS)
      In an equation for ‘fromJSON’:
          fromJSON = parseJSString (readEither . toS)
      In the instance declaration for ‘FromJSON m Natural’
    |
116 |   fromJSON = parseJSString (readEither . toS)
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

src/Cardano/Prelude/Json/Canonical.hs:116:29: error:
    • Could not deduce (Protolude.Conv.StringConv e0 GHC.Base.String)
        arising from a use of ‘readEither’
      from the context: MonadError SchemaError m
        bound by the instance declaration
        at src/Cardano/Prelude/Json/Canonical.hs:115:10-55
      The type variable ‘e0’ is ambiguous
      These potential instances exist:
        instance Protolude.Conv.StringConv ByteString GHC.Base.String
          -- Defined in ‘Protolude.Conv’
        instance Protolude.Conv.StringConv LB.ByteString GHC.Base.String
          -- Defined in ‘Protolude.Conv’
        instance Protolude.Conv.StringConv Text GHC.Base.String
          -- Defined in ‘Protolude.Conv’
        ...plus one other
        ...plus one instance involving out-of-scope types
        (use -fprint-potential-instances to see them all)
    • In the first argument of ‘(.)’, namely ‘readEither’
      In the first argument of ‘parseJSString’, namely
        ‘(readEither . toS)’
      In the expression: parseJSString (readEither . toS)
    |
116 |   fromJSON = parseJSString (readEither . toS)
    |                             ^^^^^^^^^^

src/Cardano/Prelude/Json/Canonical.hs:116:42: error:
    • Could not deduce (ConvertText Text e0)
        arising from a use of ‘toS’
      from the context: MonadError SchemaError m
        bound by the instance declaration
        at src/Cardano/Prelude/Json/Canonical.hs:115:10-55
      The type variable ‘e0’ is ambiguous
      These potential instances exist:
        instance [safe] ConvertText Text Text
          -- Defined in ‘Protolude.ConvertText’
        instance [safe] ConvertText Text GHC.Base.String
          -- Defined in ‘Protolude.ConvertText’
        ...plus one instance involving out-of-scope types
        (use -fprint-potential-instances to see them all)
    • In the second argument of ‘(.)’, namely ‘toS’
      In the first argument of ‘parseJSString’, namely
        ‘(readEither . toS)’
      In the expression: parseJSString (readEither . toS)
    |
116 |   fromJSON = parseJSString (readEither . toS)
    |                                          ^^^
cabal: Failed to build cardano-prelude-0.1.0.0 (which is required by
exe:api-server-exe from api-server-0.1.0.0). See the build log
above for details.
</code></pre>
<p>I tried this on Mac and Linux and got the same result.</p>
<p>How do I get past this issue?</p>

CC BY-SA 4.0
2022-07-27T22:13:57.277Z
Not exactly sure what the problem is but your `cabal.project` file should contain the same `index-state` line as the one in `cardano-node`. That may help
Erik de Castro Lopo
CC BY-SA 4.0
2022-07-28T04:03:26.093Z
Thanks @ErikdeCastroLopo, that worked! Also, I had to run this on Linux (Ubuntu) for it to work! Thank you!
Attilah
CC BY-SA 4.0
2022-07-28T04:29:03.080Z
Majority of the Cardano devs use Linux, with the second most common OS being Mac. I don't know of any that use Windows.
Erik de Castro Lopo
CC BY-SA 4.0
2022-07-31T02:50:38.973Z
I was using Mac. The error mentioned in the question was occurring on a mac
Attilah
<cardano-cli><cardano-node>
Errors when building cardano-node as a dependency in my project
# Errors when building cardano-node as a dependency in my project

(Asked by: username_0 on 2022-07-27)

I have included cardano-prelude as a dependency in my project's cabal.project file: https://github.com/omefire/api-server/blob/main/cabal.project
However, when I try to build the project with cabal build, I always end up getting this error:
...
[ 7 of 14] Compiling Cardano.Prelude.GHC.Heap ( src/Cardano/Prelude/GHC/Heap.hs, dist/build/Cardano/Prelude/GHC/Heap.o, dist/build/Cardano/Prelude/GHC/Heap.dyn_o )
[ 8 of 14] Compiling Cardano.Prelude.HeapWords ( src/Cardano/Prelude/HeapWords.hs, dist/build/Cardano/Prelude/HeapWords.o, dist/build/Cardano/Prelude/HeapWords.dyn_o )
[ 9 of 14] Compiling Cardano.Prelude.Json.Parse ( src/Cardano/Prelude/Json/Parse.hs, dist/build/Cardano/Prelude/Json/Parse.o, dist/build/Cardano/Prelude/Json/Parse.dyn_o )
[10 of 14] Compiling Cardano.Prelude.Json.Canonical ( src/Cardano/Prelude/Json/Canonical.hs, dist/build/Cardano/Prelude/Json/Canonical.o, dist/build/Cardano/Prelude/Json/Canonical.dyn_o )

src/Cardano/Prelude/Json/Canonical.hs:110:14: error:
    • Could not deduce (Buildable e2)
        arising from a use of ‘parseJSString’
      from the context: ReportSchemaErrors m
        bound by the instance declaration
        at src/Cardano/Prelude/Json/Canonical.hs:109:10-50
      The type variable ‘e2’ is ambiguous
      These potential instances exist:
        instance Buildable Void -- Defined in ‘Formatting.Buildable’
        instance Buildable IntPtr -- Defined in ‘Formatting.Buildable’
        instance Buildable WordPtr -- Defined in ‘Formatting.Buildable’
        ...plus 24 others
        ...plus 12 instances involving out-of-scope types
        (use -fprint-potential-instances to see them all)
    • In the expression: parseJSString (readEither . toS)
      In an equation for ‘fromJSON’:
          fromJSON = parseJSString (readEither . toS)
      In the instance declaration for ‘FromJSON m Word64’
    |
110 |   fromJSON = parseJSString (readEither . toS)
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

src/Cardano/Prelude/Json/Canonical.hs:110:29: error:
    • Could not deduce (Protolude.Conv.StringConv e2 GHC.Base.String)
        arising from a use of ‘readEither’
      from the context: ReportSchemaErrors m
        bound by the instance declaration
        at src/Cardano/Prelude/Json/Canonical.hs:109:10-50
      The type variable ‘e2’ is ambiguous
      These potential instances exist:
        instance Protolude.Conv.StringConv ByteString GHC.Base.String
          -- Defined in ‘Protolude.Conv’
        instance Protolude.Conv.StringConv LB.ByteString GHC.Base.String
          -- Defined in ‘Protolude.Conv’
        instance Protolude.Conv.StringConv Text GHC.Base.String
          -- Defined in ‘Protolude.Conv’
        ...plus one other
        ...plus one instance involving out-of-scope types
        (use -fprint-potential-instances to see them all)
    • In the first argument of ‘(.)’, namely ‘readEither’
      In the first argument of ‘parseJSString’, namely
        ‘(readEither . toS)’
      In the expression: parseJSString (readEither . toS)
    |
110 |   fromJSON = parseJSString (readEither . toS)
    |                             ^^^^^^^^^^

src/Cardano/Prelude/Json/Canonical.hs:110:42: error:
    • Could not deduce (ConvertText Text e2)
        arising from a use of ‘toS’
      from the context: ReportSchemaErrors m
        bound by the instance declaration
        at src/Cardano/Prelude/Json/Canonical.hs:109:10-50
      The type variable ‘e2’ is ambiguous
      These potential instances exist:
        instance [safe] ConvertText Text Text
          -- Defined in ‘Protolude.ConvertText’
        instance [safe] ConvertText Text GHC.Base.String
          -- Defined in ‘Protolude.ConvertText’
        ...plus one instance involving out-of-scope types
        (use -fprint-potential-instances to see them all)
    • In the second argument of ‘(.)’, namely ‘toS’
      In the first argument of ‘parseJSString’, namely
        ‘(readEither . toS)’
      In the expression: parseJSString (readEither . toS)
    |
110 |   fromJSON = parseJSString (readEither . toS)
    |                                          ^^^

src/Cardano/Prelude/Json/Canonical.hs:113:14: error:
    • Could not deduce (Buildable e1)
        arising from a use of ‘parseJSString’
      from the context: ReportSchemaErrors m
        bound by the instance declaration
        at src/Cardano/Prelude/Json/Canonical.hs:112:10-51
      The type variable ‘e1’ is ambiguous
      These potential instances exist:
        instance Buildable Void -- Defined in ‘Formatting.Buildable’
        instance Buildable IntPtr -- Defined in ‘Formatting.Buildable’
        instance Buildable WordPtr -- Defined in ‘Formatting.Buildable’
        ...plus 24 others
        ...plus 12 instances involving out-of-scope types
        (use -fprint-potential-instances to see them all)
    • In the expression: parseJSString (readEither . toS)
      In an equation for ‘fromJSON’:
          fromJSON = parseJSString (readEither . toS)
      In the instance declaration for ‘FromJSON m Integer’
    |
113 |   fromJSON = parseJSString (readEither . toS)
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

src/Cardano/Prelude/Json/Canonical.hs:113:29: error:
    • Could not deduce (Protolude.Conv.StringConv e1 GHC.Base.String)
        arising from a use of ‘readEither’
      from the context: ReportSchemaErrors m
        bound by the instance declaration
        at src/Cardano/Prelude/Json/Canonical.hs:112:10-51
      The type variable ‘e1’ is ambiguous
      These potential instances exist:
        instance Protolude.Conv.StringConv ByteString GHC.Base.String
          -- Defined in ‘Protolude.Conv’
        instance Protolude.Conv.StringConv LB.ByteString GHC.Base.String
          -- Defined in ‘Protolude.Conv’
        instance Protolude.Conv.StringConv Text GHC.Base.String
          -- Defined in ‘Protolude.Conv’
        ...plus one other
        ...plus one instance involving out-of-scope types
        (use -fprint-potential-instances to see them all)
    • In the first argument of ‘(.)’, namely ‘readEither’
      In the first argument of ‘parseJSString’, namely
        ‘(readEither . toS)’
      In the expression: parseJSString (readEither . toS)
    |
113 |   fromJSON = parseJSString (readEither . toS)
    |                             ^^^^^^^^^^

src/Cardano/Prelude/Json/Canonical.hs:113:42: error:
    • Could not deduce (ConvertText Text e1)
        arising from a use of ‘toS’
      from the context: ReportSchemaErrors m
        bound by the instance declaration
        at src/Cardano/Prelude/Json/Canonical.hs:112:10-51
      The type variable ‘e1’ is ambiguous
      These potential instances exist:
        instance [safe] ConvertText Text Text
          -- Defined in ‘Protolude.ConvertText’
        instance [safe] ConvertText Text GHC.Base.String
          -- Defined in ‘Protolude.ConvertText’
        ...plus one instance involving out-of-scope types
        (use -fprint-potential-instances to see them all)
    • In the second argument of ‘(.)’, namely ‘toS’
      In the first argument of ‘parseJSString’, namely
        ‘(readEither . toS)’
      In the expression: parseJSString (readEither . toS)
    |
113 |   fromJSON = parseJSString (readEither . toS)
    |                                          ^^^

src/Cardano/Prelude/Json/Canonical.hs:116:14: error:
    • Could not deduce (Buildable e0)
        arising from a use of ‘parseJSString’
      from the context: MonadError SchemaError m
        bound by the instance declaration
        at src/Cardano/Prelude/Json/Canonical.hs:115:10-55
      The type variable ‘e0’ is ambiguous
      These potential instances exist:
        instance Buildable Void -- Defined in ‘Formatting.Buildable’
        instance Buildable IntPtr -- Defined in ‘Formatting.Buildable’
        instance Buildable WordPtr -- Defined in ‘Formatting.Buildable’
        ...plus 24 others
        ...plus 12 instances involving out-of-scope types
        (use -fprint-potential-instances to see them all)
    • In the expression: parseJSString (readEither . toS)
      In an equation for ‘fromJSON’:
          fromJSON = parseJSString (readEither . toS)
      In the instance declaration for ‘FromJSON m Natural’
    |
116 |   fromJSON = parseJSString (readEither . toS)
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

src/Cardano/Prelude/Json/Canonical.hs:116:29: error:
    • Could not deduce (Protolude.Conv.StringConv e0 GHC.Base.String)
        arising from a use of ‘readEither’
      from the context: MonadError SchemaError m
        bound by the instance declaration
        at src/Cardano/Prelude/Json/Canonical.hs:115:10-55
      The type variable ‘e0’ is ambiguous
      These potential instances exist:
        instance Protolude.Conv.StringConv ByteString GHC.Base.String
          -- Defined in ‘Protolude.Conv’
        instance Protolude.Conv.StringConv LB.ByteString GHC.Base.String
          -- Defined in ‘Protolude.Conv’
        instance Protolude.Conv.StringConv Text GHC.Base.String
          -- Defined in ‘Protolude.Conv’
        ...plus one other
        ...plus one instance involving out-of-scope types
        (use -fprint-potential-instances to see them all)
    • In the first argument of ‘(.)’, namely ‘readEither’
      In the first argument of ‘parseJSString’, namely
        ‘(readEither . toS)’
      In the expression: parseJSString (readEither . toS)
    |
116 |   fromJSON = parseJSString (readEither . toS)
    |                             ^^^^^^^^^^

src/Cardano/Prelude/Json/Canonical.hs:116:42: error:
    • Could not deduce (ConvertText Text e0)
        arising from a use of ‘toS’
      from the context: MonadError SchemaError m
        bound by the instance declaration
        at src/Cardano/Prelude/Json/Canonical.hs:115:10-55
      The type variable ‘e0’ is ambiguous
      These potential instances exist:
        instance [safe] ConvertText Text Text
          -- Defined in ‘Protolude.ConvertText’
        instance [safe] ConvertText Text GHC.Base.String
          -- Defined in ‘Protolude.ConvertText’
        ...plus one instance involving out-of-scope types
        (use -fprint-potential-instances to see them all)
    • In the second argument of ‘(.)’, namely ‘toS’
      In the first argument of ‘parseJSString’, namely
        ‘(readEither . toS)’
      In the expression: parseJSString (readEither . toS)
    |
116 |   fromJSON = parseJSString (readEither . toS)
    |                                          ^^^
cabal: Failed to build cardano-prelude-0.1.0.0 (which is required by
exe:api-server-exe from api-server-0.1.0.0). See the build log
above for details.

I tried this on Mac and Linux and got the same result.
How do I get past this issue?

**Tags:** cardano-cli, cardano-node
> **Comments:**
> **username_1**: Not exactly sure what the problem is but your `cabal.project` file should contain the same `index-state` line as the one in `cardano-node`. That may help  
> **username_0**: Thanks @ErikdeCastroLopo, that worked! Also, I had to run this on Linux (Ubuntu) for it to work! Thank you!  
> **username_1**: Majority of the Cardano devs use Linux, with the second most common OS being Mac. I don't know of any that use Windows.  
> **username_0**: I was using Mac. The error mentioned in the question was occurring on a mac  

---

## 1 answers

### Answer by username_0 on 2022-07-31. Score: 1 | Accepted answer

As mentioned by @Erik De Castro Lopo in the comments, this issue was resolved by adding the same index-state line in my cabal.project file as that of cardano-node.


---

