fnm
fnm copied to clipboard
Support cleaning the cache directory
It would be great if fnm
supported cleaning up the cache directory. Currently, I have 2398 directories in the cache directory, and I think that having a command (which maybe runs periodically when you run any fnm
command?)that removes everything in that directory is better than having to do so manually while the folders build up.
@Schniz
hey there. There is no good solution unfortunately.
- these are not directories but symlinks. They don't really harm your computer but feel free to remove them:
rm $(dirname $FNM_MULTISHELL_PATH)/*
- periodic cleanings aren't gonna cut it 100% because we need to know whether the shell is still in use. however this is not really possible because we can't know for sure which shell have evaluated this env. it was possible if we would say to init fnm with
fnm env --pid=$$
but we don't. - as I mentioned time does not tell us anything. We might be able to clean on restarts--but I don't know how to hook into that. If you know how to make this magic happen I'd be happy to pair or get your insights so we can bake this into fnm and clean up the symlinks directory.
- I have 937 symlinks (shocking, I expected way more).
du $(dirname $FNM_MULTISHELL_PATH)
return 0 bytes, so I am not concerned about it. should I?
Maybe this is useful: https://stackoverflow.com/questions/18221348/exit-hook-working-both-on-bash-and-zsh
Thanks for this!!!
Hello~ I don't know why fnm needs to create multishells symlinks. Even if you enter the same path again, it still creates a new and different symlinks. I don't understand why it was designed this way.
Hello~ I don't know why fnm needs to create multishells symlinks. Even if you enter the same path again, it still creates a new and different symlinks. I don't understand why it was designed this way.
@fengyinxu It's because each shell instance can be using its own version of Node.js, so each multishell symlink is specific to one shell instance.
Hello~ I don't know why fnm needs to create multishells symlinks. Even if you enter the same path again, it still creates a new and different symlinks. I don't understand why it was designed this way.
@fengyinxu It's because each shell instance can be using its own version of Node.js, so each multishell symlink is specific to one shell instance.
Typically, what we need is a different version of Nodejs for each project, not each shell instance. I'm not familiar with rust. I'm curious as to why fnm designed it this way (cache, multishells) What is the need for this design. I see there is a PR #865 associated with the issue, but it's a pity that the PR has not been merged now.
@fengyinxu Commands like fnm use
change the node version the shell is using; even .node-version
and engines.node
support set the node version in the shell where you cd
ed into the project.
Is there a reason for not creating these symlinks in $TMPDIR
? 🤔