Open rfgamaral opened 3 years ago
What do you mean "from an application"? A CI step? Try
eval "$(fnm env)"
Another option is to fnm exec -- npx ...
From a desktop application. I've used SmartGit in the examples above. I'll try the eval
one when possible, and report back.
I can't do the other suggestion because that would change it for the whole team and not everyone uses fnm
.
@Schniz That solved it, and it makes sense, it was stupid of me to do it without eval
🤦♂️
However, I had a different problem after that... You see, I'm using fnm
inside WSL2, and SmartGit (and Fork) on Windows, with wslgit
to call git
inside WSL, which in turn will use fnm
. The problem is the following line generated by fnm env
:
export PATH="/tmp/fnm_multishell_20645_1618069942301/bin":$PATH
This is problematic because $PATH
contains a lot of Windows paths with spaces, and that command breaks. I'm wondering if you could change it to:
export PATH="/tmp/fnm_multishell_20645_1618069942301/bin:$PATH"
I simulated this on my .huskyrc
file (instead of fnm env
and it finally worked without issues.
Any chance you can make that change so that spaces in $PATH
work correctly?
Hmm makes sense! What do you say about contributing it? Should be fairly easy and you will leave a mark 😃
I can't do the other suggestion because that would change it for the whole team and not everyone uses
fnm
.
Let's convince them to use it 😈😈 why won't they use fnm? Is something missing or does not work for them?
Hmm makes sense! What do you say about contributing it? Should be fairly easy and you will leave a mark 😃
I looked at the code, but I have not idea what to do, I don't know Rust, and unfortunately I don't have much time to dig into the source code now :(
Let's convince them to use it 😈😈 why won't they use fnm? Is something missing or does not work for them?
I don't know, never had that conversation. I believe some use it, some use something else, and some probably use nothing. I've recommended it in the past, but I have no idea who started using it and who didn't 😅
FYI, I have temporarily solved this issue on my side by loading fnm
like this:
eval "$(fnm env --shell=zsh --log-level=quiet | sed -e 's/PATH="\(.*\)":\$PATH/PATH="\1:$PATH"/g')"
FYI, I have temporarily solved this issue on my side by loading
fnm
like this:eval "$(fnm env --shell=zsh --log-level=quiet | sed -e 's/PATH="\(.*\)":\$PATH/PATH="\1:$PATH"/g')"
I also did something similar as a workaround for Git Bash in #390.
Putting eval "$(fnm env --log-level=quiet)"
in ~/.huskyrc
(not ~/.zshrc
) worked for me.
eval "$(fnm env --shell=zsh --log-level=quiet | sed -e 's/PATH="(.*)":\$PATH/PATH="\1:$PATH"/g')"
/.huskyrc: line 2: fnm: command not found
same here same issue fnm command not found
@ImBIOS @Robokishan This is not an fnm
issue, but rather how you configured husky
. You may want to take a look at the husky docs: https://typicode.github.io/husky/troubleshooting.html#command-not-found
I have this in my ~/.huskyrc
file:
eval "$(fnm env)"
If husky is not able to find fnm
, you should follow the procedure specific to your OS to add it to the path (or do it in .huskyrc
).
This issue should be closed.
Potential workaround/solution https://github.com/Schniz/fnm/issues/668#issuecomment-2233615946
Note on the info above: ~/.huskyrc
is deprecated. Use ~/.config/husky/init.sh
with newer versions of husky.
I use ZSH and here's how I set up
fnm
on~/.zshrc
:Now I'm trying to set up Git hooks with the latest Husky version, but I can't get them to work. If I commit from my shell, everything works as expected. If I commit from an application, I get this:
Then I followed Husky's instructions to fix this issue, and I have added
fnm env --shell=zsh
to~/.huskyrc
, but then I got thisNot sure how to fix this...