Closed TheFern2 closed 2 years ago
Same issue here. Did you have luck on this?
I had done a bit of debugging, but I am not great with fish scripting, I figure the index is either out of range or negative when node is activated. I haven't been on my linux machine in a while, but I just turned node prompt off.
Manged to solve this, although I'm still unsure as to the cause.
I tried do a simple echo
on the argv
list and got the following /home/brad package.json .nvmrc .node-version
, which seems correct to me. A simple list with 4 elements. I tried echoing argv[2..]
and got the same error mentioned above.
After reading the Fish language docs, it says that argv[2..]
is effectively equivalent to argv[2..-1]
meaning "from index 2 until the end of the list". Quote from the docs:
A missing starting index in a range defaults to 1. This is allowed if the range is the first index expression of the sequence. Similarly, a missing ending index, defaulting to -1 is allowed for the last index range in the sequence.
Source: https://fishshell.com/docs/current/language.html#expand-index-range
The weird thing though, is if you substitute in argv[2..-1]
it seems to work correctly. It seems that the syntax isn't being respected for some reason. I'm not super familiar with Fish language, so if anyone has any thoughts here I'd love to hear them.
@bradsheppard That's a great catch, and that's really weird. A simple test case fails on fish 3.1.x for me:
set -l foo 1 2 3 4
echo $foo[2..]
echo $foo[..3]
¯\_(ツ)_/¯
I've pushed a change to add an explicit -1
to the range. Let me know if this resurfaces, all!
Thanks for the fix! I will test when I get a chance.
I have enabled node on my fish config, but I am getting an error about invalid index. I am running latest fish, version 3.4.1-249-g39df8f0b3, omf 7, and just installed bobthefish today. Tried folders without package.json or nvmrc and same error. Any ideas how to fix it?