solc-js
solc-js copied to clipboard
Getting Error: EEXIST: file already exists, mkdir '.'
Hi:
I run this command: solcjs --bin --include-path node_modules/ --base-path . LookupContract.sol
And get this result:
Warning: Visibility for constructor is ignored. If you want the contract to be non-deployable, making it "abstract" is sufficient.
--> LookupContract.sol:9:1:
|
9 | constructor (string memory _name, uint _mobileNumber) public {
| ^ (Relevant source part starts here and spans across multiple lines).
fs.js:885
return binding.mkdir(pathModule._makeLong(path),
^
Error: EEXIST: file already exists, mkdir '.'
at Object.fs.mkdirSync (fs.js:885:18)
at Object.<anonymous> (/usr/local/lib/node_modules/solc/solc.js:232:4)
at Module._compile (module.js:653:30)
at Object.Module._extensions..js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)
at Function.Module.runMain (module.js:694:10)
at startup (bootstrap_node.js:204:16)
at bootstrap_node.js:625:3
Here is the content of LookupContract.sol
:
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;
contract LookupContract {
mapping (string => uint) public myDirectory;
constructor (string memory _name, uint _mobileNumber) public {
myDirectory[_name] = _mobileNumber;
}
function setMobileNumber(string memory _name, uint _mobileNumber) public {
myDirectory[_name] = _mobileNumber;
}
function getMobileNumber(string memory _name) public view returns (uint) {
return myDirectory[_name];
}
}
Here is my package.json
{
"name": "first-hedera-contract-js-sdk",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"@hashgraph/cryptography": "^1.4.0",
"@hashgraph/sdk": "^2.18.0",
"dotenv": "^16.0.1",
"encoding": "^0.1.13",
"expo": "^45.0.8",
"expo-crypto": "^10.2.0",
"expo-random": "^12.3.0"
}
}
Help? I am jammed up.
Triple thanks in advance!
This works:
solcjs --bin ./LookupContract.sol -o ./bin
This is the result:
ls -lh ./bin
total 4.0K
-rw-r--r-- 1 root root 3.6K Aug 23 03:01 LookupContract_sol_LookupContract.bin
Hi @reselbob, what version of solcjs
and nodejs
are you using?
I had no problem running the first or the second command with your code:
npm install
solcjs --bin --include-path node_modules/ --base-path . test.sol
Or without including the node_modules:
solcjs --bin ./test.sol -o ./bin
My versions are:
node v18.8.0
solcjs 0.8.15+commit.e14f2714.Emscripten.clang
node --version
v16.17.0
solcjs --version
0.8.16+commit.07a7930e.Emscripten.clang
Let me revisit the issue, please. Thank you sincerely @r0qs to taking the time to help me out.
I also tried to reproduce and this does not happen for me. What platform are you on?
The crash apparently happens when the script tries to create the directory (.
in this case): https://github.com/ethereum/solc-js/blob/a0226f0847f54153a232351827a0f2917192a54c/solc.ts#L225
It errors out because the directory exists but this is not supposed to happen because we use the recursive
option. It could be a bug in node.js or the fs
module - maybe there's something unusual on your filesystem (permissions?) - but whatever it is, the function is supposed to handle that.