Skip to content

"Cannot import url" error when working with standard json on newest mac version #10059

@shellygr

Description

@shellygr

Description

In Mac OS 10.15.7, a single contract file compiled with standard-json with the input file provided as a URL, Solidity compiler fails to compile with the following error:

{"errors":[{"component":"general","formattedMessage":"Cannot import url (\"/Users/thomas/Code/MacSucks/Bank.sol\"): File outside of allowed directories.","message":"Cannot import url (\"/Users/thomas/Code/MacSucks/Bank.sol\"): File outside of allowed directories.","severity":"error","type":"IOError"}],"sources":{}}

A workaround is to provide a relative path instead of the absolute path.
This is a change of behavior compared to Ubuntu, Windows, and Mac OS 10.15.6.

Environment

  • Compiler version: solc6.10
  • Operating system: Mac OS 10.15.7

Steps to Reproduce

This happens on any contract. But we take this solidity snippet:

pragma solidity ^0.6.0;

contract Bank {
    struct Account {
        uint256 balance;
        uint256 exists;
    }
    mapping (address => Account) accounts;
    uint256 public totalSupply;

    function create(address a) public {
        require(accounts[a].exists == 0);
        accounts[a].exists = 1;
    }
}

This file is stored in /Users/thomas/Code/MacSucks/Bank.sol.

We prepare the following standard-json input:

	{
		"language": "Solidity",
		"sources": {
			"/Users/thomas/Code/MacSucks/Bank.sol": {
				"urls": [
					"/Users/thomas/Code/MacSucks/Bank.sol"
				]
			}
		},
		"settings": {
			"remappings": [],
			"outputSelection": {
				"*": {
					"*": [
						"storageLayout",
						"abi",
						"evm.deployedBytecode",
						"evm.methodIdentifiers"
					],
					"": [
						"id",
						"ast"
					]
				}
			}
		}
	}

Here are a few attempts to run the compiler and what each one gives:

  • solc6.10 --allow-paths /Users/thomas/Code/MacSucks --standard-json < json.json - fails on newest Mac, succeeds in other environments.
  • solc6.10 --standard-json < json.json - fails on all environments
  • solc6.10 --allow-paths / --standard-json < json.json - succeeds
  • solc6.10 --allow-paths . --standard-json < json.json - succeeds
  • solc6.10 --allow-paths /Users/thomas/Code/MacSucks,. --standard-json < json.json - succeeds

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions