Pin shell in installer-generated env setup (Schniz#1525) #199
Pin shell in installer-generated env setup (Schniz#1525) #199Dargon789 wants to merge 10 commits into
Conversation
* fix(zsh): dedupe use-on-cd hook on re-source * fix(wincmd): support spaces and drive switches in use-on-cd * test(e2e): cover use-on-cd after re-sourcing env * chore: add changeset for use-on-cd shell fixes
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* feat: support x64-glibc-217 * add changeset --------- Co-authored-by: Gal Schlezinger <gal@spitfire.co.il>
* fix(use): clarify interactive install prompt source * chore: add changeset for prompt clarification
* perf(install): pin shell in generated env setup * ci: pin docker platform for ARM installer tests * chore: add changeset for installer shell update
Reviewer's GuideImplements immediate application of the current directory Node version during Sequence diagram for fnm env --use-on-cd applying current directory versionsequenceDiagram
actor User
participant Shell
participant FnmEnv as Env_command
participant SetPath as set_path_for_multishell
participant UseCmd as Use_command
User->>Shell: runs startup script
Shell->>FnmEnv: fnm env --use-on-cd --shell <shell>
FnmEnv->>SetPath: set_path_for_multishell(multishell_path)
SetPath-->>FnmEnv: PATH updated with multishell_path
FnmEnv->>FnmEnv: config_with_multishell = config.clone().with_multishell_path(multishell_path)
FnmEnv->>UseCmd: construct Use { version: None, install_if_missing: false, silent_if_unchanged: true, info_to_stderr: true }
FnmEnv->>UseCmd: apply(config_with_multishell)
UseCmd-->>FnmEnv: apply result (ignored on error)
FnmEnv-->>Shell: shell.use_on_cd(config) script
Shell-->>User: environment ready, current directory version already active
Class diagram for updated Use, FnmConfig, Arch, and Directories typesclassDiagram
class Use {
+UserVersion~Option~ version
+bool install_if_missing
+bool silent_if_unchanged
+bool info_to_stderr
+apply(config: FnmConfig) Result
}
class FnmConfig {
+Url node_dist_mirror
+Url node_rc_mirror
+Option~PathBuf~ base_dir
+Option~PathBuf~ multishell_path
+with_base_dir(base_dir: Option~PathBuf~) FnmConfig
+with_multishell_path(multishell_path: PathBuf) FnmConfig
}
class Directories {
<<struct>>
}
class Arch {
<<enum>>
X86
X64
X64Musl
X64Glibc217
Arm64
Armv7l
Ppc64le
Aarch64AppleDarwin
+as_str() &str
+from_str(s: &str) Result~Arch~
}
FnmConfig --> Directories : uses
FnmConfig --> Arch : configured_with
Use --> FnmConfig : apply(config)
class WindowsCmd {
+use_on_cd(config: FnmConfig) Result~String~
}
class Zsh {
+use_on_cd(config: FnmConfig) Result~String~
}
WindowsCmd ..> FnmConfig : generates cd macro
Zsh ..> FnmConfig : generates chpwd hook
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
There was a problem hiding this comment.
Hey - I've found 2 issues, and left some high level feedback:
- In
set_path_for_multishell, theunsafeblock aroundstd::env::set_varis unnecessary sinceset_varis safe; you can drop theunsafeentirely. - When prepending
multishell_pathtoPATHinset_path_for_multishell, consider de-duplicating the entry so repeatedfnm env --use-on-cdcalls don’t keep growingPATHwith identical prefixes.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `set_path_for_multishell`, the `unsafe` block around `std::env::set_var` is unnecessary since `set_var` is safe; you can drop the `unsafe` entirely.
- When prepending `multishell_path` to `PATH` in `set_path_for_multishell`, consider de-duplicating the entry so repeated `fnm env --use-on-cd` calls don’t keep growing `PATH` with identical prefixes.
## Individual Comments
### Comment 1
<location path="CHANGELOG.md" line_range="13" />
<code_context>
+
+### Patch Changes
+
+- [#1268](https://github.com/Schniz/fnm/pull/1268) [`ddab191`](https://github.com/Schniz/fnm/commit/ddab1911dc33a24aeec9d2b8139df1916c518d64) Thanks [@isaacl](https://github.com/isaacl)! - Make `fnm default` with no trailing positional argument to return the default version
+
+- [#1517](https://github.com/Schniz/fnm/pull/1517) [`d3747af`](https://github.com/Schniz/fnm/commit/d3747affd604223c752171c14944bd5773096b09) Thanks [@Schniz](https://github.com/Schniz)! - Improve `--use-on-cd` shell hook robustness by de-duplicating the zsh hook on re-source and fixing Windows CMD hook behavior for paths with spaces and drive changes.
</code_context>
<issue_to_address>
**nitpick (typo):** Tighten grammar in the `fnm default` description.
The phrase "Make `fnm default` with no trailing positional argument to return the default version" is a bit awkward. Consider wording it as "Make `fnm default` with no trailing positional argument return the default version" or "Have `fnm default` with no trailing positional argument return the default version."
```suggestion
- [#1268](https://github.com/Schniz/fnm/pull/1268) [`ddab191`](https://github.com/Schniz/fnm/commit/ddab1911dc33a24aeec9d2b8139df1916c518d64) Thanks [@isaacl](https://github.com/isaacl)! - Have `fnm default` with no trailing positional argument return the default version
```
</issue_to_address>
### Comment 2
<location path="docs/commands.md" line_range="383" />
<code_context>
This command generates a series of shell commands that should be evaluated by your shell to create a fnm-ready environment.
-Each shell has its own syntax of evaluating a dynamic expression. For example, evaluating fnm on Bash and Zsh would look like `eval "$(fnm env)"`. In Fish, evaluating would look like `fnm env | source`
+Each shell has its own syntax of evaluating a dynamic expression. For example, evaluating fnm on Bash and Zsh would look like `eval "$(fnm env --shell bash)"`. In Fish, evaluating would look like `fnm env --shell fish | source`
Usage: fnm env [OPTIONS]
</code_context>
<issue_to_address>
**nitpick (typo):** Add terminal punctuation to the modified sentence for consistency.
The sentence ending with `fnm env --shell fish | source` is the only one in the paragraph without a period. Please add a period for consistency.
```suggestion
Each shell has its own syntax of evaluating a dynamic expression. For example, evaluating fnm on Bash and Zsh would look like `eval "$(fnm env --shell bash)"`. In Fish, evaluating would look like `fnm env --shell fish | source`.
```
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
There was a problem hiding this comment.
Code Review
This pull request bumps fnm to version 1.39.0 and introduces several performance improvements and bug fixes. A significant change is the reduction of shell startup overhead for env --use-on-cd by applying the initial Node version internally during the env command execution, rather than relying on a subsequent shell hook. The PR also adds support for the x64-glibc-217 architecture, improves the robustness of shell hooks (specifically for Zsh and Windows CMD), and updates documentation to prefer explicit shell flags. Feedback was provided regarding the use of the Error log level to redirect informational messages to stderr, as this might lead to misleading error-style formatting for users.
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Head branch was pushed to by a user without write access
* feat: add possible values to the arch help docs. * add a changeset --------- Co-authored-by: Gal Schlezinger <gal@spitfire.co.il>
* docs: add e2e testing guide for agents * docs: trim AGENTS e2e section * docs: refine AGENTS guidance for e2e and changesets
* Add random number to multishell symlinks This protects against collisions when multiple shells are started in parallel inside Bubblewrap sandboxes, as each shell will have the same timestamp and the same low PID (e.g. 2), since Bubblewrap sandboxes have isolated PID spaces. * Add a changeset --------- Co-authored-by: Gal Schlezinger <gal@spitfire.co.il>
|
@joliss is attempting to deploy a commit to the Foundry development Team on Vercel. A member of the Team first needs to authorize it. |
Summary by Sourcery
Improve shell integration, architecture support, and installer behavior while preparing the 1.39.0 release.
New Features:
Bug Fixes:
Enhancements:
CI:
Documentation:
Tests:
Chores: