Closed shangsunset closed 8 years ago
@shangsunset For starters, I think the correct function is:
function nvm
bass source ~/.nvm/nvm.sh --no-use ';' nvm $argv
end
@shangsunset let me know if what @bucaran suggested works for you.
unfortunately, it didnt work.
@shangsunset
Why the following?
set -g -x PATH /usr/local/bin $PATH
isn't /usr/local/bin/ supposed to be in PATH by default?
And one more thing, neither node or npm are in your $PATH when the sessions starts. So, try
printf "%s\n" $PATH
Hey @bucaran, I deleted set -g -x PATH /usr/local/bin $PATH
and this is the output from running printf "%s\n" $PATH
:
/Users/shangsunset/.pyenv/shims
/usr/local/sbin
/Users/shangsunset/.nvm/versions/node/v5.10.1/bin
/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin
/Users/shangsunset/.nvm/versions/node/v5.10.1/bin
shows first than /usr/local/bin
, which makes sense, but what's inside the nvm
path?
ls -la /Users/shangsunset/.nvm/versions/node/v5.10.1/bin
total 46224
drwxr-xr-x 4 shangsunset staff 136 Apr 5 17:47 .
drwxr-xr-x 10 shangsunset staff 340 Apr 15 09:34 ..
-rwxr-xr-x 1 shangsunset staff 23661896 Apr 5 17:47 node
lrwxr-xr-x 1 shangsunset staff 38 Apr 5 17:47 npm -> ../lib/node_modules/npm/bin/npm-cli.js
And you are saying that when you run, npm
or node
, you get a "command not found" error?
yes
And what happens if you do
/Users/shangsunset/.nvm/versions/node/v5.10.1/bin/node -v
Also, do you have a .bash_profile file in your $HOME
directory? and if you do, what is its contents?
shangsunset@Yeshens-MBP ~> /Users/shangsunset/.nvm/versions/node/v5.10.1/bin/node -v
v5.10.1
shangsunset@Yeshens-MBP ~> cat .bash_profile
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
shangsunset@Yeshens-MBP ~>
does .bash_profile still matter if we are using fish?
Right, it does not matter in fish, but nvm is a bash script and I wanted to see if you were defining any aliases.
If /Users/shangsunset/.nvm/versions/node/v5.10.1/bin/node
works, how come node
, does not?
Try this:
set -gx PATH /Users/shangsunset/.nvm/versions/node/v5.10.1/bin
and run node
again. If that does not work, comment out your .bash_profile
and try again. I don't know how nvm works internally, so that's just a desperate measure.
mmm that works
Okay, can you check what's inside:
/Users/shangsunset/.pyenv/shims
/usr/local/sbin
shangsunset@Yeshens-MBP ~> ls -la /Users/shangsunset/.pyenv/shims
total 0
drwxr-xr-x 2 shangsunset staff 68 Apr 16 00:31 .
drwxr-xr-x 4 shangsunset staff 136 Apr 11 10:50 ..
shangsunset@Yeshens-MBP ~> ls -la /usr/local/sbin
total 16
drwxr-xr-x 4 shangsunset admin 136 Apr 12 09:04 .
drwxrwxr-x 20 shangsunset admin 680 Apr 12 10:07 ..
lrwxr-xr-x 1 shangsunset admin 35 Apr 12 09:04 php-fpm -> ../Cellar/php56/5.6.20/sbin/php-fpm
lrwxr-xr-x 1 shangsunset admin 37 Apr 12 09:04 php56-fpm -> ../Cellar/php56/5.6.20/sbin/php56-fpm
shangsunset@Yeshens-MBP ~>
Well, that looks alright, I guess.
Comment out all of your config.fish, and just leave this
set fisher_home ~/.local/share/fisherman
set fisher_config ~/.config/fisherman
source $fisher_home/config.fish
function nvm
bass source ~/.nvm/nvm.sh --no-use ';' nvm $argv
end
Then reload the shell and try using nvm as you are used to again.
still getting fish: Unknown command 'node'
:(
so weird. i can use nvm to install node but node is unknown...
And if you modify your PATH like this?
/Users/shangsunset/.nvm/versions/node/v5.10.1/bin
/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin
yea node works with /Users/shangsunset/.nvm/versions/node/v5.10.1/bin
in PATH
So, the problem is solved. What is the issue again?
so i need to put set -gx PATH /Users/shangsunset/.nvm/versions/node/v5.10.1/bin $PATH
in my config.fish?
@shangsunset
Nope, that's exactly nvm
's job. You need to do is run nvm
or nvm use foo
when you restart your shell / cd into a path with a .nvmrc
, etc., everytime.
Because nvm
mods in your PATH will not be persisted across sessions AFIK.
I think you were just using nvm
incorrectly, so not your fault, I was confused about this too.
I need to run nvm
every time when i use node
or npm
from now on? That doesnt sound very ideal...
I wonder why I didnt have to run nvm
every time when i was using zsh
or omf/plugin-nvm
. hmmmm...
@shangsunset
nvm
like a function, you need to run it every timenvm
in your config.fish or create a snippet that does it for you.I wonder why I didnt have to run nvm every time when i was using zsh or omf/plugin-nvm. hmmmm...
Well, that's because they either source nvm
or call the nvm
function for you on shell startup.
Related: https://github.com/creationix/nvm/issues/303#issuecomment-210738874
@shangsunset
Just rm ~/.config/functions/config.fish
, and create a new config.fish
with this:
set fisher_home ~/.local/share/fisherman
set fisher_config ~/.config/fisherman
source $fisher_home/config.fish
### add your other configuration here
function nvm
bass source ~/.nvm/nvm.sh --no-use ';' nvm $argv
end
nvm ### call nvm HERE so you don't have to call it every time
@bucaran
Really appreciate your help and patience. However, even though i deleted my existing config.fish and created a new one with what you provided, node
and npm
are still not available upon shell start. unless i run nvm use node
.
@shangsunset I think you could make your life a ton easier if you switched to tj/n, at least just temporarily until you figure out how nvm works.
If you really want to use nvm, though, I advise you to read their documentation thoroughly and learn how to use it instead of depending on plugins first.
Also, please read the "official" fish tutorial. Please take no offence, as I could be wrong, but given your responses, it looks as if you still don't really understand the difference between calling a function, running code on shell startup, etc.
ok thanks.
@shangsunset https://github.com/fisherman/nvm
Please do not steal other people's project names.
@ljharb Dude, you are completely misinterpreting my plugin. The purpose of fisherman/nvm is to serve as a bridge between creationix/nvm and the missing nvm solution in fish.
I did - I asked you politely to change it. You said "No". call it nvm-fish
if you like - but not "nvm". That's confusing for users, and makes googling harder, even if it wasn't rude and potentially an implicit trademark violation.
People that use fisherman know that stuff inside the org, are all plugins for fish, kind of like ohmyfish and similar projects. I wouldn't say it's confusing.
You were politely asked by a project whose name you copied to change it. Whether you agree that it's confusing is irrelevant - it's not cool, under any circumstances.
First, you were not polite, you were not rude either, but you were definitely very hostile. You even called me an "asshole". Why should I accept that? People on the internet are very confrontational when facing a white message box. You wouldn't call me an asshole to my face.
Second, I worked hard on this thing, not that it matters, but I put it there because a lot of people have asked for an nvm in fish for like years and there just wasn't one. Sure, there are wrappers, but it's just not the same. I am calling the project nvm for a simple reason, people migrating from bash to fish that have used creationix/nvm before, are likely to search for "nvm in fish" when they realize creationix/nvm does not work in fish.
so call it "nvm in fish". I insulted you after you posted a very rude one-word answer "No", and after you called me "bro" (which is also rude; you don't know me) and told me to "chill".
I'm glad you worked hard on it, and I hope your project is successful - but it should be successful under its own name, not by stealing the name of something else. If you don't change your name, and your project attains any notoriety, it will forever live under the shadow of that - I won't be the only one you hear it from. Why not just change it?
Well, that's a touching way to put it. There you go: https://github.com/fisherman/nbm ;)
And, I said "dude". From there to asshole it's quite a big jump.
EDIT: Went with https://github.com/fisherman/fish-nvm
EDIT 2: Went with https://github.com/fisherman/fin lol
Thanks, much obliged.
@ljharb See edit. If that's okay with you I'd like to add it to the list of alternatives in your README.
@bucaran thank you, that sounds great. Please feel free to send a PR.
@bucaran fish-nvm was way better than fin, it's very funny naming stuff after fishes and stuff related to them, but that makes googling hard as hell.
If I want a nvm for fish I will search for that on google, not fin. If I want to run bash script on my fish shell I will search for fish bash wrapper or fish bash runner, not bass.
@shangsunset You can solve your problem sourcing nvm every time you open a new shell, this will add a minor delay, but at least it works, just put this line on your config file at ~/.config/fish/config.fish
bass source ~/.nvm/nvm.sh >/dev/null ^&1
@FabioAntunes Which is why I named it nvm in the first place, but then ljharb was right, I can't just name my project after creationix/nvm like that, so I changed it to fin.
Now, bear in mind that fin is not a drop-in replacement for nvm nor it requires nvm
as a dependency. It's a standalone node version manager written in fish.
If I want a nvm for fish I will search for that on google, not fin. If I want to run bash script on my fish shell I will search for fish bash wrapper or fish bash runner, not bass.
I couldn't agree more, and just like fisherman, SEO will be hard to do. Now, on the other hand, those who find it will appreciate it like the hidden gem it is.
Hi, So ive put the
nvm
function in theconfig.fish
and installednode
with nvm. however, i always getfish: Unknown command 'node'
on shell startup, so isnpm
. they will work after i execute anvm
command though, such asnvm ls
.if
nvm
is already sourced, how comenode
wont work?ps: tested in bash. node and npm work normally.
my config.fish: