-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
feat(install): add support for --unsafe
install flag
#1008
Conversation
Signed-off-by: Rajdeep Malakar <[email protected]>
Signed-off-by: Rajdeep Malakar <[email protected]>
Signed-off-by: Rajdeep Malakar <[email protected]>
Signed-off-by: Rajdeep Malakar <[email protected]>
…ts nested package caches from failing)
Changed the |
@jhheider It seems to be okay, but I'm not in PC rn (it's 1:02AM here lol). Can you try it now please, if possible? |
bugs in the script, but i can add a commit to fix them. |
but the speed looks good:
|
Thanks. Sucks to be without laptop/PC, lol. Anyways, thanks again. |
Is that right after doing the install, or after doing an initial run? It caches only at the first run, so subsequent runs should be faster than the first one. And the first one might interfere with the rest. |
No, I mean if either is set, it should be on. Which is the way you have it, I believe. Setting the envvar to zero shouldn't do anything. |
By shouldn't do anything, do you mean it should ignore that? So, if that's set, regardless of its value, it should do an unsafe install? |
If yes, it gets simpler: function is_unsafe(unsafe: boolean): boolean {
return Deno.env.get("PKGX_UNSAFE_INSTALL") || unsafe;
} |
No. If it's non-zero, or the --unsafe flag is passed, it should do an unsafe install. If the envvar is zero, it has no effect one way or the other. |
The default behaviour (without any env or flag) is to install normally. So,
if the env is set to 0, it should do that? Sorry for sounding like an idiot.
…On Wed, 15 May, 2024, 8:14 pm Jacob Heider, ***@***.***> wrote:
So, if that's set, regardless of its value, it should do an unsafe install?
No. If it's non-zero, or the --unsafe flag is passed, it should do an
unsafe install. If the envvar is zero, it has no effect one way or the
other.
—
Reply to this email directly, view it on GitHub
<#1008 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ATXDOIZKEBPBKQ6ZCQFUVFDZCNYEJAVCNFSM6AAAAABHSDC4DWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMJSG42DCNRYHA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Exactly. Setting it 0 is the same as not setting it. So, it doesn't affect behavior. If it's set to 0 and the flag is passed it's unsafe. If it's 0 and no flag, then safe. Set to 0 is a no-op. |
So, this: function is_unsafe(unsafe: boolean): boolean {
const env = parseInt(Deno.env.get("PKGX_UNSAFE_INSTALL") || "0") ? true : false;
return env || unsafe;
} With this, there are six possible combinations:
|
@jhheider implemented it, is it okay? If so, can you please test that the env works as expected? (It probably does, but still a test is a good idea) |
right, i don't think that changed anything. your original implementation checked the truth value of the env || the flag. so, it should still be working correctly. |
looks like good work |
I've got to say this approach is just as not future-proof as the previous. Perhaps we should fix it for good by adding some known comment to the stubs? Like: #!/bin/sh
# managed by pkgx |
Guys, I don't want to be silly, but I had proposed this on Apr 11. @jhheider is there a chance you missed my comment and later came up with the same proposal? Don't get me wrong, all I want is |
That is possible, but it'll break compatibility with the stubs installed by older versions. PKGX wouldn't detect them as installed by PKGX if we completely move to this approach. As for unsafe install, I've had the idea to see and check for .env files (generated for unsafe installations only). That's not as reliable, though, because it would fail if the cache was somehow deleted, or not yet generated. |
Perhaps we can keep searching for |
Ha. I don't specifically recall your comment, but, yes, we were talking in discord about what and how to cache. I certainly don't deserve the credit for the idea, but we came to the same conclusion as you. |
maybe i read that proposal before coming up with this PR, and forgot
about it before doing it. it is certainly inspired by your proposal.
so, i think you deserve the credit!
…On Sat, Jun 8, 2024 at 1:42 AM Felipe Santos ***@***.***> wrote:
as proposed by @jhheider (thanks!)
Guys, I don't want to be silly, but I had proposed this on Apr 11. @jhheider is there a chance you missed my comment and later came up with the same proposal?
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
That sounds like a good option. What do you think @jhheider? We can also add that to unsafe install now (which is in scope of this PR), because backwards compatibility doesn't exist for it. |
sure, sounds like a good idea. |
does `#MANAGED BY PKGX` sound good for that comment? (it's unique enough
to not cause conflicts)
|
go for it! |
Signed-off-by: Rajdeep Malakar <[email protected]>
done! |
Also, updated the example to reflect the current |
Pull Request Test Coverage Report for Build 10740267243Details
💛 - Coveralls |
Nice feature. Additive so easy merge. |
closes #997
closes #991
This PR adds support for the
--unsafe
install flag to PKGX, which, as proposed by @jhheider and @felipecrs (thanks!), creates additional env stubs for a package on the first run, making subsequent runs make use of the already installed binaries, thus making it faster[1].The stub
As for the stub, it makes it a bit different, for instance, here's a "safe"
node
wrapper (installed normally):And here's the "unsafe" (as in experimental)
node
wrapper:Additional changes
Additionally, this PR also makes the following behavioural changes to PKGX:
pkgx uninstall
now also removes the env stub of the packagepkgx install
now checks for bothexec pkgx
(old behaviour) and#MANAGED BY PKGX
(comment) to determine whether that file was created by PKGX.Usage
To do an unsafe installation, there are two options:
--unsafe
flag (e.gpkgx install --unsafe node
)PKGX_UNSAFE_INSTALL
environmental variable.In the presence of both, the
--unsafe
flag takes precedence.Caveats
This approach doesn't come without any caveat. It's necessary to document them upon having such a functionality.
As per my knowledge, these are the known issues:
Most (if not all) of them error correctly and offer (potentially) helpful error messages.
[1]