Skip to content
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

Fixes issue where fnm print the node version string when using fish shell in non-interactive mode #958

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

eelcocramer
Copy link

This week I ran into an issue with Neovide, a neovim gui (also written in rust).

I proposed GH-955 but did not feel this was the right fix for this issue, so this PR replaces that.

Neovide starts neovim in a sub-shell and uses the neovim --embed mode to read and write msgpack messages to and from stdout.

When I start Neovide in a folder with a .nvmrc that defines a node version that is not my default, fnm prints a message and that ends up in the communication between Neovide and nvim and makes it crash.

Neovide runs a non-interactive shell, and in that mode your shell init scripts are not supposed to print anything. In that mode, the shell typically don't ready .bashrc and similar. However, for the fish shell, it seems like it always reads config.fish (fish-shell/fish-shell#5394).

This PR adds changes the behaviour of fnm env --use-on-cd for the fish shell to add a conditional check whether the shell is interactive or not. If fish is in non-interactive mode fnm use is started with a new switch --silent that will not let fnm output the version string even if the version will change.

@changeset-bot
Copy link

changeset-bot bot commented May 8, 2023

🦋 Changeset detected

Latest commit: 92d7605

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
fnm Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@eelcocramer eelcocramer changed the title Fixes issue where fish in non-interactive mode Fixes issue where fnm print the node version string when using fish shell in non-interactive mode May 8, 2023
@Schniz
Copy link
Owner

Schniz commented Jun 29, 2023

There is log level configuration that can be set to error, which will do exactly what you want, or am I missing something?

@eelcocramer
Copy link
Author

Maybe. But then the log level should be set to error as a default in non-interactive mode right?

@Schniz
Copy link
Owner

Schniz commented Jun 29, 2023

Hmmm…. Define non interactive? fnm is not a shell. It’s not a debug statement, it’s an info/stdout kind of thing. I don’t think fnm should be quiet by default

@eelcocramer
Copy link
Author

eelcocramer commented Jun 29, 2023

Ah sorry for being verbose. I meant when the fish shell is running non-interactive, i.e. not connected to a keyboard and in that case fnm probably runs in the background somewhere and should be silent.

But another way to achieve that could be to change the logging level here in case the shell runs non-interactively.

Comment on lines +33 to +35
else
fnm use --silent
end
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry for only circling back to it now, can we maybe put it --log-level=error here to avoid info messages?

@Schniz
Copy link
Owner

Schniz commented May 26, 2024

any news on the log-level usage? :frog-eyes:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants