-
Notifications
You must be signed in to change notification settings - Fork 12
fix: use execv in proxyexe #38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Great work! You do mention however on the forum that some manual steps are required to replace the proxy executables. Maybe it would be better to add something in |
The proxyexe binary is built into the choosenim executable. It gets written to So actually, contrary to what I wrote on the forum, currently it isn't necessary to remove the old proxyexe binaries, just to switch to a new (or the same) version of Nim with choosenim after updating choosenim. See the code here: choosenim/src/choosenimpkg/switcher.nim Line 270 in fc240ac
( Updating the proxyexe binaries when choosenim updates itself, can be easily done (see below), but belongs in a different PR, imho, and also doesn't help when somebody just updates choosenim using diff --git a/src/choosenim.nim b/src/choosenim.nim
index 3306e01..c1b628a 100644
--- a/src/choosenim.nim
+++ b/src/choosenim.nim
@@ -167,6 +167,27 @@ proc updateSelf(params: CliParams) =
display("Info:", "Updated choosenim to version " & $version,
Success, HighPriority)
+ # Any Nim installation currently activated by choosenim?
+ if $getCurrentVersion(params) != "":
+ var proxiesToInstall = @proxies
+
+ # Handle MingW proxies.
+ when defined(windows):
+ if not isDefaultCCInPath(params):
+ let mingwBin = getMingwBin(params)
+ if not fileExists(mingwBin / "gcc".addFileExt(ExeExt)):
+ let msg = "No 'gcc' binary found in '$1'." % mingwBin
+ raise newException(ChooseNimError, msg)
+
+ proxiesToInstall.add(mingwProxies)
+
+ if not params.areProxiesInstalled(proxiesToInstall):
+ # Create the proxy executables.
+ for proxy in proxiesToInstall:
+ writeProxy(proxy, params)
+
+
+
proc update(params: CliParams) =
if params.commands.len != 2:
raise newException(ChooseNimError,
diff --git a/src/choosenimpkg/switcher.nim b/src/choosenimpkg/switcher.nim
index 2965859..c195e13 100644
--- a/src/choosenimpkg/switcher.nim
+++ b/src/choosenimpkg/switcher.nim
@@ -107,7 +107,7 @@ proc getSelectedPath*(params: CliParams): string =
proc getProxyPath(params: CliParams, bin: string): string =
return params.getBinDir() / bin.addFileExt(ExeExt)
-proc areProxiesInstalled(params: CliParams, proxies: openarray[string]): bool =
+proc areProxiesInstalled*(params: CliParams, proxies: openarray[string]): bool =
result = true
let proxyExe = proxyToUse()
for proxy in proxies:
@@ -173,7 +173,7 @@ proc getNimbleVersion(toolchainPath: string): Version =
display("Warning:", "Could not find toolchain's Nimble version.",
Warning, MediumPriority)
-proc writeProxy(bin: string, params: CliParams) =
+proc writeProxy*(bin: string, params: CliParams) =
# Create the ~/.nimble/bin dir in case it doesn't exist.
createDir(params.getBinDir())
|
c49fef9
to
5c9cb7e
Compare
Now that there is an implementation of this PR for Windows as well, I will try to add sensible tests. Not sure how yet, but I will come up with something. |
734cd27
to
cc15dca
Compare
Hi there, thanks for your work. I wanted to test your implementation, but i have seen, that your fork does not implement the newest additions. could you update your branch to the latest commits, so i can try it out? i would appreciate it. |
c8c45e9
to
a65877e
Compare
I've rebased the PR branch on Ignore all the commits listed above. I'm not sure what I did there but I hope everything is in order again now. |
a65877e
to
c032684
Compare
I never seem to get around to writing proper tests for it. In fact, I don't really know how to best write these test and I could use some help! I've bee using this patch in the AUR package of choosenim for months now and it works perfectly for me and I haven't got any reports of problems with it from other AUR user either. |
@SpotlightKid yet the CI is red, what's up with that? |
@Araq The CI uses an outdated runner. Support for I'll have a look what's up with the other OSes. |
The project was updated with the new repo.
Signed-off-by: Christopher Arndt <[email protected]>
Signed-off-by: Christopher Arndt <[email protected]>
Also don't define 'exec' proc if useExec is not set Signed-off-by: Christopher Arndt <[email protected]>
Signed-off-by: Christopher Arndt <[email protected]>
72c278f
to
954da31
Compare
CI failure is not caused by this PR, we need to wait for nightlies fixing |
a little feedback: i am using your patches since march and hadn't any problems with them. yes, there are missing test, but the current situation for linux users is bad, especially for newcomers, because they hit multiple walls until to find the right issues and fix it by hand. so i would vote for applying the patches, to get a step forward. better as staying in the current situation. |
ref https://forum.nim-lang.org/t/12524
Potential fix for #13 on POSIX and Windows systems.
On non-posix/windows systems still uses the old behaviour using
startProcess
. Use--undef:useExec
to switch back to old behaviour on posix too.