Skip to content

Commit 9b99c59

Browse files
committed
Comments in _run_solc
1 parent 9cfa803 commit 9b99c59

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

crytic_compile/platform/solc.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,16 +519,21 @@ def _run_solc(
519519

520520
additional_kwargs: Dict = {"cwd": working_dir} if working_dir else {}
521521
if not compiler_version.version in [f"0.4.{x}" for x in range(0, 11)]:
522-
# Add . as default allowed path
522+
# Add --allow-paths argument, if it isn't already specified
523+
# We allow the CWD as well as the directory that contains the file
523524
if "--allow-paths" not in cmd:
524525
file_dir_start = os.path.normpath(os.path.dirname(filename))
526+
# Paths in the --allow-paths arg can't contain commas, since this is the delimeter
527+
# Try using absolute path; if it contains a comma, try using relative path instead
525528
file_dir = os.path.abspath(file_dir_start)
526529
if "," in file_dir:
527530
try:
528531
file_dir = os.path.relpath(file_dir_start)
529532
except ValueError:
533+
# relpath can fail if, for example, we're on Windows and the directory is on a different drive than CWD
530534
pass
531535

536+
# Even the relative path might have a comma in it, so we want to make sure first
532537
if "," not in file_dir:
533538
cmd += ["--allow-paths", ".," + file_dir]
534539
else:

0 commit comments

Comments
 (0)