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

the mistake about Shell Setup #1110

Open
liiiiiiiiiiiir opened this issue Apr 21, 2024 · 8 comments
Open

the mistake about Shell Setup #1110

liiiiiiiiiiiir opened this issue Apr 21, 2024 · 8 comments

Comments

@liiiiiiiiiiiir
Copy link

I installed fnm with cargo, used powershell.

But after I add the following to the end of my profile file:
fnm env --use-on-cd | Out-String | Invoke-Expression

the mistake would come out:
QQ截图20240421181053

I'm sure the env var is corrent

@Schniz
Copy link
Owner

Schniz commented Apr 21, 2024

it says fnm is not available. Maybe the initialization happens before cargo is added to PATH?

@liiiiiiiiiiiir
Copy link
Author

it says fnm is not available. Maybe the initialization happens before cargo is added to PATH?

nonono, I installed the cargo first, and then I ran cargo install fnm

@liiiiiiiiiiiir
Copy link
Author

it says fnm is not available. Maybe the initialization happens before cargo is added to PATH?

Hello, this error has been resolved. When there is Chinese in the environment variable, fnm env --use-on-cd will output garbled results. I'm sorry about this. So I was wondering if it's possible to add a option to set encoding format. And I just tested Chinese, I don't know if other non English languages have this problem

@Schniz
Copy link
Owner

Schniz commented Apr 22, 2024

Can you please attach the output you get? So we can escape it properly 🙏

@liiiiiiiiiiiir
Copy link
Author

Can you please attach the output you get? So we can escape it properly 🙏
When fnm is installed on the C drive, it will output the following information when used
QQ截图20240422181237
QQ截图20240422181223

Afterwards, I moved FNM to the full English path, and there was no problem using FNM, but the installation path of the node still had garbled characters
QQ截图20240422180346
The folder below is a directory automatically created by FNM when downloading nodes due to garbled characters

@KonradSuli
Copy link

Hey.

Similar issue here, almost opened a new ticket.

For me, my userprofile directory on windows contains the letter 'á': C:\Users\Konrád.
I installed fnm using winget and powershell, and the results were pretty bad.

winget install Schniz.fnm
...
Successfully installed

To the environment variables it added
C:\Users\Konrád\AppData\Local\Microsoft\WinGet\Packages\Schniz.fnm_Microsoft.Winget.Source_8wekyb3d8bbwe

After fixing it manually I reloaded the path
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")
Then installed node
fnm install 20
This created the node installation under a new user folder:
C:\Users\KonrÔöť├şd\AppData\Roaming\fnm

Then I tried playing around a bit more:

PS C:\Projects\t90dct\t90dct-stats\frontend> fnm install 20
Installing Node v20.12.2 (x64)
warning: Version already installed at "C:\\Users\\KonrÔöť├şd\\AppData\\Roaming\\fnm\\node-versions\\v20.12.2"
PS C:\Projects\t90dct\t90dct-stats\frontend> fnm env --use-on-cd | Out-String | Invoke-Expression
fnm:
Line |
  10 |  function global:Set-FnmOnLoad { fnm use --silent-if-unchanged }
     |                                  ~~~
     | The term 'fnm' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
PS C:\Projects\t90dct\t90dct-stats\frontend> fnm env --use-on-cd | Out-String | Invoke-Expression
fnm: The term 'fnm' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
PS C:\Projects\t90dct\t90dct-stats\frontend> winget
winget: The term 'winget' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

After trying fnm env, it kinda killed my PATH as it is, and I had to reload it. Trying to use fnm env from the startup powershell script results in the same error.

I then tried using it from a terminal with administrator priviliges just to see what would happen. After installing fnm there and trying to fnm use it, and fnm env ... I now have 2 more folders where they should not be:

C:\Users\Konrád\AppData\Local\fnm_multishells
C:\Users\Konr├ö├Â┼ąÔöť┼čd\AppData\Roaming\fnm

So yeah... it is kind of broken, not only with chinese characters. Probably something something windows' own character encoding messing with stuff.

@Schniz
Copy link
Owner

Schniz commented May 3, 2024

I haven’t used windows in almost 10 years. Would be great to get your assistance in what needs to change in the fnm env output 🙏

@KonradSuli
Copy link

KonradSuli commented May 3, 2024

Sadly fnm env's output does not seem to be the only thing broken. I tried uninstalling via winget and that also failed. The env variable path that was set was also incorrect. It's probably the handling of the OS path strings in general that's the problem.

That said in the fnm env case specifically this line is to blame:
$env:FNM_DIR = "C:\Users\Konr├ö├Â┼ąÔöť┼čd\AppData\Roaming\fnm"

My rust and knowledge on character encodings are far from anywhere close to even understand what needs to be changed, but I'll take a look when my time permits.

Edit: Also I just noticed that some \fnm_multishells directories were created in the correct place, making me even more confused

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

No branches or pull requests

3 participants