fnm icon indicating copy to clipboard operation
fnm copied to clipboard

When fnm is installed with winget, the symbolic link gets incorrect target if account contains character with accent

Open Attila-FIN opened this issue 1 year ago โ€ข 3 comments

I've installed fnm with winget winget install Schniz.fnm

However, after installation the execution was not possible. Then I've found that in folder %LOCALAPPDATA%\Microsoft\WinGet\Links the link to fnm.exe had an incorrect target, since my account's folder includes an "รก" character.

The solution was to re-create the link with: New-Item -ItemType SymbolicLink -Path $env:LOCALAPPDATA -Name "\Microsoft\WinGet\Links\fnm.exe" -Value "$env:LOCALAPPDATA\Microsoft\WinGet\Packages\Schniz.fnm_Microsoft.Winget.Source_8wekyb3d8bbwe\fnm.exe"

However, after executing "fnm env", the result still includes the incorrect character and the resultant environment variables are wrong.

Attila-FIN avatar Jun 18 '24 19:06 Attila-FIN

The solution seems to be to add the following lines into the profile script (notepad $profile):

# Configure environment for Schniz.fnm

# Save the current encoding and switch to UTF-8.
$prev = [Console]::OutputEncoding
[Console]::OutputEncoding = [System.Text.UTF8Encoding]::new()

fnm env --use-on-cd | Out-String | Invoke-Expression

# Restore the previous encoding.
[Console]::OutputEncoding = $prev

Perhaps the system wide setting could be also the solution, but I haven't tested that: image

Attila-FIN avatar Jun 19 '24 08:06 Attila-FIN

I had the exact same issue weeks ago, and it made me give up on fnm. Thanks to your fix, I could get it running.

This issue also affects nvm-windows, so if you happen to have an accent in your username, you simply can't have access to any node version manager on windows !

GregoireBellon avatar Jun 24 '24 13:06 GregoireBellon