trufflesuite / truffle

:warning: The Truffle Suite is being sunset. For information on ongoing support, migration options and FAQs, visit the Consensys blog. Thank you for all the support over the years.
https://consensys.io/blog/consensys-announces-the-sunset-of-truffle-and-ganache-and-new-hardhat?utm_source=github&utm_medium=referral&utm_campaign=2023_Sep_truffle-sunset-2023_announcement_
MIT License
14.02k stars 2.32k forks source link

`Error: spawnSync /bin/sh ENOBUFS` when compiling Colony with native compiler #4499

Open cameel opened 2 years ago

cameel commented 2 years ago

Issue

I'm trying to compile the Colony contracts using the native compiler and I'm running into an error:

Error: spawnSync /bin/sh ENOBUFS

The same contracts compile just fine when using an emscripten binary.

This seems to have already happened before (#3140) and the buffer size was increased to 10 MB in #3002. Something must have changed since then because this size seems insufficient now.

Steps to Reproduce

git clone https://github.com/JoinColony/colonyNetwork.git
cd colonyNetwork/
git submodule update --init

curl -OL https://binaries.soliditylang.org/linux-amd64/solc-linux-amd64-v0.7.3+commit.9bfce1f6
chmod +x solc-linux-amd64-v0.7.3+commit.9bfce1f6

# NOTE: With https://github.com/trufflesuite/truffle/issues/4490 we could avoid the shell magic here
function solc { "$__SOLC_NATIVE_BINARY" "$@"; }
export -f solc
export __SOLC_NATIVE_BINARY=$(realpath solc-linux-amd64-v0.7.3+commit.9bfce1f6)

cat <<EOF >> truffle.js
module.exports['compilers']['solc']['version'] = "native";
module.exports['compilers']['solc']['docker'] = false;
module.exports['compilers']['solc']['parser'] = null;
EOF

npm install --legacy-peer-deps
npm update truffle
npx truffle compile

For the record, the top of the main branch in the Colony repo while I'm testing it is at e06f7815902801c6b9cc66da8dbfa2aee2b9f874.

Expected Behavior

Compilation finishes without errors.

Actual Results

Error: spawnSync /bin/sh ENOBUFS
    at Object.spawnSync (node:internal/child_process:1081:20)
    at spawnSync (node:child_process:812:24)
    at execSync (node:child_process:895:15)
    at Object.compile (/tmp/colonyNetwork/node_modules/truffle/build/webpack:/packages/compile-solidity/dist/compilerSupplier/loadingStrategies/Native.js:14:1)
    at /tmp/colonyNetwork/node_modules/truffle/build/webpack:/packages/compile-solidity/dist/run.js:200:1
    at Generator.next (<anonymous>)
    at /tmp/colonyNetwork/node_modules/truffle/build/webpack:/packages/compile-solidity/dist/run.js:7:1
    at new Promise (<anonymous>)
    at exports.modules.571193.__awaiter (/tmp/colonyNetwork/node_modules/truffle/build/webpack:/packages/compile-solidity/dist/run.js:3:1)
    at invokeCompiler (/tmp/colonyNetwork/node_modules/truffle/build/webpack:/packages/compile-solidity/dist/run.js:187:1)
    at /tmp/colonyNetwork/node_modules/truffle/build/webpack:/packages/compile-solidity/dist/run.js:41:46
    at Generator.next (<anonymous>)
    at /tmp/colonyNetwork/node_modules/truffle/build/webpack:/packages/compile-solidity/dist/run.js:7:1
    at new Promise (<anonymous>)
    at exports.modules.571193.__awaiter (/tmp/colonyNetwork/node_modules/truffle/build/webpack:/packages/compile-solidity/dist/run.js:3:1)
    at run (/tmp/colonyNetwork/node_modules/truffle/build/webpack:/packages/compile-solidity/dist/run.js:19:1)
    at Object.<anonymous> (/tmp/colonyNetwork/node_modules/truffle/build/webpack:/packages/compile-solidity/dist/index.js:148:1)
    at Generator.next (<anonymous>)
    at fulfilled (/tmp/colonyNetwork/node_modules/truffle/build/webpack:/packages/compile-solidity/dist/index.js:4:42)
Truffle v5.4.23 (core: 5.4.23)
Node v17.1.0

Environment

fainashalts commented 2 years ago

Hi @cameel you may want to try using a shell script instead of a bash function -- spawnSync in Truffle is set up to handle a shell script or a binary executable. Please let us know if that helps!

cameel commented 2 years ago

Unfortunately it did not help. I get the same error even if I replace the part that exports the function with either of these:

wrapper script:

echo '#!/usr/bin/bash' >> solc
echo "$(realpath solc-linux-amd64-v0.7.3+commit.9bfce1f6) \"\$@\"" >> solc
chmod +x solc
export PATH="$PWD:$PATH"

binary:

mv solc-linux-amd64-v0.7.3+commit.9bfce1f6 solc
export PATH="$PWD:$PATH"
kevinweaver commented 2 years ago

Thanks @cameel for bringing this to our attention! We've added this to our backlog to investigate further.