Solidity: CLI: --allow-paths should support trailing `/`

Created on 20 Apr 2017  路  6Comments  路  Source: ethereum/solidity

$ solc/solc --allow-paths /Users/alex/Projects/solidity xyxy.sol 
Warning: This is a pre-release compiler version, please do not use it in production.
/Users/alex/Projects/solidity/restricted/test.sol:1:1: Warning: Source file does not specify required compiler version!

^
xyxy.sol:1:1: Warning: Source file does not specify required compiler version!
import "/Users/alex/Projects/solidity/restricted/test.sol";
^
Spanning multiple lines.
$ solc/solc --allow-paths /Users/alex/Projects/solidity/ xyxy.sol 
Warning: This is a pre-release compiler version, please do not use it in production.
xyxy.sol:1:1: Error: Source "/Users/alex/Projects/solidity/restricted/test.sol" not found: File outside of allowed directories.
import "/Users/alex/Projects/solidity/restricted/test.sol";
^---------------------------------------------------------^
bug

Most helpful comment

Does not work as expected with"." and ".." in Solidity 0.4.19 (0.4.19+commit.c4cbbb05.Windows.msvc).

Working cases:
solc --allow-paths .
solc --allow-paths ./,
solc --allow-paths ../,

Cases that do not work:
solc --allow-paths ./
solc --allow-paths ..
solc --allow-paths ../

All 6 comments

I'm observing different things:

$ solc --overwrite --bin -o out_dir github.com/ethereum/dapp-bin/library/=/tmp/test_contract --allow-paths /tmp/test_contract/ temp.sol
temp.sol:3:1: Error: Source "/tmp/test_contract/linkedList.sol" not found: File outside of allowed directories.
import "github.com/ethereum/dapp-bin/library/linkedList.sol" as linked_list;
^--------------------------------------------------------------------------^
temp.sol:4:1: Error: Source "/tmp/test_contract/iterable_mapping.sol" not found: File outside of allowed directories.
import "github.com/ethereum/dapp-bin/library/iterable_mapping.sol" as it_mapping;
^-------------------------------------------------------------------------------^

However, just by appending a comma it'll compile:
$ solc --overwrite --bin -o out_dir github.com/ethereum/dapp-bin/library/=/tmp/test_contract/ --allow-paths /tmp/test_contract, temp.sol

@jonnyhsy I think it is the same problem. The problem is that allow-paths doesn't work with a trailing slash.

Hi @axic , I also tried $ solc --overwrite --bin -o out_dir github.com/ethereum/dapp-bin/library/=/tmp/test_contract/ --allow-paths /tmp/test_contract temp.sol; (no trailing slash), it also failed with error

temp.sol:3:1: Error: Source "/tmp/test_contract/linkedList.sol" not found: File outside of allowed directories.
import "github.com/ethereum/dapp-bin/library/linkedList.sol" as linked_list;
^--------------------------------------------------------------------------^
temp.sol:4:1: Error: Source "/tmp/test_contract/iterable_mapping.sol" not found: File outside of allowed directories.
import "github.com/ethereum/dapp-bin/library/iterable_mapping.sol" as it_mapping;
^-------------------------------------------------------------------------------^

Does not work as expected with"." and ".." in Solidity 0.4.19 (0.4.19+commit.c4cbbb05.Windows.msvc).

Working cases:
solc --allow-paths .
solc --allow-paths ./,
solc --allow-paths ../,

Cases that do not work:
solc --allow-paths ./
solc --allow-paths ..
solc --allow-paths ../

@JechoJekov it's working for me , thank you

@JechoJekov Thanks Champ

Was this page helpful?
0 / 5 - 0 ratings