Skip to content

Commit 08a7919

Browse files
0xalpharushNat Chin
authored andcommitted
check the global version is installed (#144)
* check the global version is installed * Hotfixes 0.8.18 to pull from crytic/solc (#159) * Real hot fix * updated return link * Linting errors * Use latest setuptools (#157) * Update setup.py (#160) --------- Co-authored-by: Nat Chin <[email protected]>
1 parent 6f159bd commit 08a7919

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

solc_select/solc_select.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,22 +46,25 @@ def upgrade_architecture() -> None:
4646

4747

4848
def current_version() -> (str, str):
49-
version = os.environ.get("SOLC_VERSION")
5049
source = "SOLC_VERSION"
51-
if version:
52-
if version not in installed_versions():
53-
raise argparse.ArgumentTypeError(
54-
f"Version '{version}' not installed (set by {source}). Run `solc-select install {version}`."
55-
)
56-
else:
57-
source = SOLC_SELECT_DIR.joinpath("global-version")
58-
if Path.is_file(source):
59-
with open(source, encoding="utf-8") as f:
50+
version = os.environ.get(source)
51+
if not version:
52+
source_path = SOLC_SELECT_DIR.joinpath("global-version")
53+
source = source_path.as_posix()
54+
if Path.is_file(source_path):
55+
with open(source_path, encoding="utf-8") as f:
6056
version = f.read()
6157
else:
6258
raise argparse.ArgumentTypeError(
6359
"No solc version set. Run `solc-select use VERSION` or set SOLC_VERSION environment variable."
6460
)
61+
versions = installed_versions()
62+
if version not in versions:
63+
raise argparse.ArgumentTypeError(
64+
f"\nVersion '{version}' not installed (set by {source})."
65+
f"\nRun `solc-select install {version}`."
66+
f"\nOr use one of the following versions: {versions}"
67+
)
6568
return version, source
6669

6770

0 commit comments

Comments
 (0)