-
Notifications
You must be signed in to change notification settings - Fork 14
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
Auto-shimming for project toolchains #23
Conversation
# Unresolved questions | ||
[unresolved]: #unresolved-questions | ||
|
||
- When, if ever, should shims be deleted? The ability of a user to simply delete an entire project from disk makes tracking shim use problematic, at best. What, exactly, is the behavior of a shim when the associated tool is not part of the toolchain? If it simply "forwards" to the shell, this is less of an issue. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My first instinct is to say this isn't a problem, since shims are more or less transparent. Yes, typing which foo
will show a different answer than if Notion weren't installed, but otherwise the shim is supposed to behave identically to the underlying tool it delegates to (and notion which foo
is a way to "see through" that difference as well), and be fast at doing its delegation. So generally I think it should be fine to leave shims in place.
The counterargument would be that shims are the most intrusive part of the Notion design, in that they impact the way developers think about how tools work on their machine.
But the problem with that is, if someone wants to delete a shim and projects keep automatically re-creating the shim, they're going to be really frustrated.
So maybe a coarser-grained approach is the right answer: if Notion is operational, you are letting it control the set of shims. If you want to get the shims out of your way, you should deactivate Notion all at once, with notion deactivate
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it simply "forwards" to the shell, this is less of an issue.
Yes, the behavior should be forwarding to the shell. So the shims are effectively fully transparent except for the behavior of which
and the process tree (for example when inspecting the process table).
|
||
This scan will be a two-level process. First, the project's `package.json` will be inspected for all dependencies and devDependencies. Second, each of those dependencies' `package.json` files will be inspected for binaries to shim. For each binary, Notion will attempt to create a shim symlink, catching `EEXISTS` and considering it a success. Any other error will result in an appropriate message to `stderr`, but not halt the scanning/shimming process. | ||
|
||
This same scan will also occur when pinning a version of Node using `notion use`, to ensure that shims are created for packages installed prior to setting up a toolchain for the project. Finally, the scan will be available via a new `notion autoshim .` command. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd cut the autoshim
command for now. I think we should see how the tool feels with shim management kept entirely under the hood. We can always consider adding shim management commands back in after we've gotten some experience using Notion for a while.
It's not impossible to create or delete a shim by hand without a subcommand, it's just manual and icky enough to dissuade users from doing it casually. And you can always trigger autoshimming by running yarn
or npm i
.
But I'm now coming to the opinion that we should start by eliminating the notion shim
command completely, and drop the autoshim
command from this RFC.
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that notion shim
isn't a user-facing command, but (at least for now) I think there is some value in it for Notion developers. For example, I found myself deleting third-party shims quite frequently as part of implementing auto-shimming.
Between that and the fact that notion shim auto
is already implemented and working, I'd prefer to punt this for now. It's easy enough to remove the command later, and in the mean time, we may find value in it for scripting or some such. (I liken notion shim
to git's "plumbing" commands, to a degree.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@benblank I don't want to start shipping things to users just because they're already implemented -- the point of RFCs is to try to get to consensus before we ship things. And we need to be careful about shipping user-visible features with the expectation of removing them -- removing features is very costly once you have users, and we're getting close to launching and encouraging adoption.
At the same time, I hear what you're saying about the usefulness of internal features for developers.
Let's use Cargo's feature flags functionality to put features that are only for developers behind a flag. And let's put the entire notion shim
command behind a feature flag; I'm not convinced it's an appropriate feature for end users. If we decide later that it is, it'll already be in the codebase and easy to enable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW your point about "plumbing" is good too. Probably the best way to think about plumbing commands is that they're for external automation (people writing extensions or scripts).
We definitely should expose plumbing commands but they're lower-level and hard to change, so we can be a little more cautious about exposing them. Starting with a feature flag seems like a good first step, and then we should think about the UI of plumbing commands. (For example, maybe we want to mark them explicitly as such in the UI, e.g. notion plumbing shim ...
? But we don't need to decide that here for this RFC.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Putting notion shim
behind a feature flag sounds like a great idea. I'll update the implementation PR as soon as I figure out how to do that. ;-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@benblank https://doc.rust-lang.org/cargo/reference/manifest.html#the-features-section is a good place to start.
Coming back to this now, a couple thoughts: I think I'd like to either remove the I'm having doubts about the idea that autoshimming should fail silently. The way I'm thinking about it is, if there's a best-effort operation that happens as part of a shim, it should fail silently (or perhaps to a log file, but without affecting the console behavior); but if there's a core operation that a shim does, it should fail loudly. IOW, if autoshimming fails it's a sign that something is really wrong. I think we want this case to override the successful result of the underlying tool and print an error and return an error code. @benblank Thoughts? |
I can update re: autoshim once I'm back in the office tomorrow. I'm still on the fence about exit codes; I really don't like the idea of obscuring the output of a shimmed tool, but I do see that it may make sense here. I'm happy to go with consensus on that one. |
I agree with @dherman that if autoshimming is a core feature of Notion, we should show an error if it fails, so that the user knows that their system is not actually in a correct state. @benblank To your concern about obscuring the output of
That way we are still surfacing the result of the shimmed tool, but letting the user know that something else went wrong (and ideally giving them a push in the right direction of how to fix it). |
Oh, this raises an interesting question: what do we do if the underlying tool fails? If it fails, I think I do share @benblank's concern about overriding the underlying tool's exit code. So there are a few possibilities here:
The current RFC text is (1), and my concern is that it's swallowing a serious error -- for example, think about what happens when people do things like I think (4) is terrifying in the way @benblank is worried: we shouldn't swallow failures in an underlying tool. I'm a little queasy about (3) as well: at least it doesn't swallow the underlying tool's failure, choosing between two failures to report seems fundamentally risky. So, what about (2)? This way, the only thing we're ever overriding is a success, in which case I think @charlespierce's suggestion is good: the error message can provide a bit of disambiguation about what exactly failed and what didn't. |
volta-cli/volta#235 Raises some concerns about the overall idea of Autoshimming, and I think there's some good discussion to be had about whether it is necessary. The RFC states "Automatic management of shims is a core competency of Notion", but after seeing the concerns raised in the above issue, I'm not so sure that's the case. In my experience, it's not commonly expected that locally installed packages will be available within the shell. Rather, those are typically invoked using the The only tools that we really want to shim are tools that are normally installed globally (e.g. I can see a couple different ways to support that:
Of those two, I feel like the first fits better into the common OSS workflow, and is easy enough to explain (You globally install |
I think this is really a key point that I'm embarrassed to have overlooked for so long. To me, this is pretty dispositive that while auto-shimming was a good area of exploration (and thank you for your work on it, @benblank!), having a single, user-managed toolchain is a clearer, safer, and more understandable model. Again, even if we decide against auto-shimming, this RFC was awesome work and super helpful in driving out discussion. I really appreciate it! |
@charlespierce good write up! I can get behind that. |
Closing as we've decided to move towards a more user-controlled model. Even though we're closing this RFC, it was great work and really helped us think through the details! |
Rendered