IntersectMBO / plutus-apps

The Plutus application platform
Apache License 2.0
305 stars 213 forks source link

Cannot run cabal build on plutus-apps on an M1 Mac using v1.0.0 #675

Closed trevinwisaksana closed 1 year ago

trevinwisaksana commented 2 years ago

Summary

Hi,

I'm getting an error when running cabal repl using the plutus-starter project. The error may be caused by some incorrect or outdated dependencies used in the cabal.project. Possibly libsodium. But since it's widely used in other projects I cannot build the rest as well.

Steps to reproduce the behavior

  1. Change directory the plutus-apps folder and run nix-shell and run cabal build all
  2. You should be getting an error like this symbol not found in flat namespace (_sodium_free)

Actual Result

Failed to build byron-spec-ledger-0.1.0.0.
Build log (
/Users/trevinwisaksana/.cabal/logs/ghc-8.10.7/byrn-spc-ldgr-0.1.0.0-a82fd687.log
):
Configuring library for byron-spec-ledger-0.1.0.0..
Preprocessing library for byron-spec-ledger-0.1.0.0..
Building library for byron-spec-ledger-0.1.0.0..
[ 1 of 16] Compiling Byron.Spec.Ledger.Core ( src/Byron/Spec/Ledger/Core.hs, dist/build/Byron/Spec/Ledger/Core.o, dist/build/Byron/Spec/Ledger/Core.dyn_o )
<command line>: dlopen(/Users/trevinwisaksana/.cabal/store/ghc-8.10.7/lib/libHScrdn-crypt-clss-2.0.0-4ac0ea6e-ghc8.10.7.dylib, 0x0005): symbol not found in flat namespace (_sodium_free)

Failed to build plutus-core-0.1.0.0.
Build log (
/Users/trevinwisaksana/.cabal/logs/ghc-8.10.7/plts-cr-0.1.0.0-f68cfa68.log ):
Warning: plutus-core.cabal:312:23: visibility is experimental feature (issue
#5660)
Configuring library for plutus-core-0.1.0.0..
Preprocessing library for plutus-core-0.1.0.0..
Building library for plutus-core-0.1.0.0..
[  1 of 191] Compiling Crypto           ( plutus-core/src/Crypto.hs, dist/build/Crypto.o, dist/build/Crypto.dyn_o )
[  2 of 191] Compiling Data.Aeson.Flatten ( plutus-core/src/Data/Aeson/Flatten.hs, dist/build/Data/Aeson/Flatten.o, dist/build/Data/Aeson/Flatten.dyn_o )
[  3 of 191] Compiling Data.Aeson.THReader ( plutus-core/src/Data/Aeson/THReader.hs, dist/build/Data/Aeson/THReader.o, dist/build/Data/Aeson/THReader.dyn_o )
[  4 of 191] Compiling Data.ByteString.Hash ( plutus-core/src/Data/ByteString/Hash.hs, dist/build/Data/ByteString/Hash.o, dist/build/Data/ByteString/Hash.dyn_o )
[  5 of 191] Compiling Data.SatInt      ( plutus-core/src/Data/SatInt.hs, dist/build/Data/SatInt.o, dist/build/Data/SatInt.dyn_o )
[  6 of 191] Compiling ErrorCode        ( common/ErrorCode.hs, dist/build/ErrorCode.o, dist/build/ErrorCode.dyn_o )
[  7 of 191] Compiling PlutusCore.Builtin.Emitter ( plutus-core/src/PlutusCore/Builtin/Emitter.hs, dist/build/PlutusCore/Builtin/Emitter.o, dist/build/PlutusCore/Builtin/Emitter.dyn_o )
[  8 of 191] Compiling PlutusCore.Data  ( plutus-core/src/PlutusCore/Data.hs, dist/build/PlutusCore/Data.o, dist/build/PlutusCore/Data.dyn_o )
[  9 of 191] Compiling PlutusCore.DataFilePaths ( plutus-core/src/PlutusCore/DataFilePaths.hs, dist/build/PlutusCore/DataFilePaths.o, dist/build/PlutusCore/DataFilePaths.dyn_o )
[ 10 of 191] Compiling PlutusCore.InlineUtils ( common/PlutusCore/InlineUtils.hs, dist/build/PlutusCore/InlineUtils.o, dist/build/PlutusCore/InlineUtils.dyn_o )
[ 11 of 191] Compiling PlutusCore.Pretty.ConfigName ( plutus-core/src/PlutusCore/Pretty/ConfigName.hs, dist/build/PlutusCore/Pretty/ConfigName.o, dist/build/PlutusCore/Pretty/ConfigName.dyn_o )
[ 12 of 191] Compiling PlutusPrelude    ( prelude/PlutusPrelude.hs, dist/build/PlutusPrelude.o, dist/build/PlutusPrelude.dyn_o )
[ 13 of 191] Compiling PlutusCore.Pretty.Utils ( plutus-core/src/PlutusCore/Pretty/Utils.hs, dist/build/PlutusCore/Pretty/Utils.o, dist/build/PlutusCore/Pretty/Utils.dyn_o )
[ 14 of 191] Compiling PlutusCore.Pretty.Readable ( plutus-core/src/PlutusCore/Pretty/Readable.hs, dist/build/PlutusCore/Pretty/Readable.o, dist/build/PlutusCore/Pretty/Readable.dyn_o )
<command line>: dlopen(/Users/trevinwisaksana/.cabal/store/ghc-8.10.7/lib/libHScrdn-crypt-clss-2.0.0-4ac0ea6e-ghc8.10.7.dylib, 0x0005): symbol not found in flat namespace (_sodium_free)
cabal: Failed to build byron-spec-ledger-0.1.0.0 (which is required by
plutus-starter-0.1.0.0). See the build log above for details.
Failed to build plutus-core-0.1.0.0 (which is required by
plutus-starter-0.1.0.0). See the build log above for details.

Expected Result

Should successfully enter cabal repl.

Describe the approach you would take to fix this

No response

System info

MacOS 12.5, 16 inch 2021 Apple M1 Pro Memory 16 GB

trevinwisaksana commented 2 years ago

The issue seems to be with the plutus-core library having build issues within nix-shell on an M1. When entering nix-shell and running cabal build plutus-core this error occurs. But without being in a nix-shell the build is successful

trevinwisaksana commented 2 years ago

I believe I've identified the solution is we need to install IOHK's version of libsodium within the nix-shell environment. Unfortunately I do not know how to do it. I tried running these commands within nix-shell (based on installing cardano-node):

git clone https://github.com/input-output-hk/libsodium
cd libsodium
git checkout 66f017f1
./autogen.sh
./configure
make
sudo make install

But it's installed into usr/local/lib instead of becoming something nix can recognize. Anyone reading this knows how to install it properly as a nix dependency?

trevinwisaksana commented 1 year ago

Is there anyone that can help with this? It's still showing the same error in v1.0.0

berewt commented 1 year ago

Unfortunately, plutus-starter is unmainained and should be rebuild from scratch in the future. A WIP that tried to upgrade the nix environment was on its way, but it causes other issues, so it's on pause at the moment. If you really want to give plutus-starter a try, you may try the corresponding branch though : https://github.com/input-output-hk/plutus-starter/tree/nicolas/plutus-apps1.1