diff options
author | Ivan Yonchovski <yyoncho@users.noreply.github.com> | 2023-01-18 22:38:48 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-18 21:38:48 +0100 |
commit | 7c6dcfd968867ec9b2fee5ca3ef8f251a6faa350 (patch) | |
tree | cb55a8fa438c7343b2e2f911d546ff10d31ba355 /compiler/nim.nim | |
parent | 00ef27f4d18bcd5f56132d9ac5dfab840ef4e6fe (diff) | |
download | Nim-7c6dcfd968867ec9b2fee5ca3ef8f251a6faa350.tar.gz |
Implicitly set noNimblePath when nimble.lock is present (#21266)
Fixes https://github.com/nim-lang/nimble/issues/1004
Diffstat (limited to 'compiler/nim.nim')
-rw-r--r-- | compiler/nim.nim | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/compiler/nim.nim b/compiler/nim.nim index c2b70dda2..420579b97 100644 --- a/compiler/nim.nim +++ b/compiler/nim.nim @@ -41,6 +41,15 @@ when defined(profiler) or defined(memProfiler): {.hint: "Profiling support is turned on!".} import nimprof +proc nimbleLockExists(config: ConfigRef): bool = + const nimbleLock = "nimble.lock" + let pd = if not config.projectPath.isEmpty: config.projectPath else: AbsoluteDir(getCurrentDir()) + if optSkipParentConfigFiles notin config.globalOptions: + for dir in parentDirs(pd.string, fromRoot=true, inclusive=false): + if fileExists(dir / nimbleLock): + return true + return fileExists(pd.string / nimbleLock) + proc processCmdLine(pass: TCmdLinePass, cmd: string; config: ConfigRef) = var p = parseopt.initOptParser(cmd) var argsCount = 0 @@ -74,6 +83,11 @@ proc processCmdLine(pass: TCmdLinePass, cmd: string; config: ConfigRef) = config.arguments.len > 0 and config.cmd notin {cmdTcc, cmdNimscript, cmdCrun}: rawMessage(config, errGenerated, errArgsNeedRunOption) + if config.nimbleLockExists: + # disable nimble path if nimble.lock is present. + # see https://github.com/nim-lang/nimble/issues/1004 + disableNimblePath(config) + proc getNimRunExe(conf: ConfigRef): string = # xxx consider defining `conf.getConfigVar("nimrun.exe")` to allow users to # customize the binary to run the command with, e.g. for custom `nodejs` or `wine`. |