Comments (14)
I was not able to reproduce the bug:
~ $ cat .config/fish/functions/nvm.fish
function nvm
bass source ~/.nvm/nvm.sh ';' nvm $argv
end
~ $ nvm use v4
Now using node v4.1.1 (npm v2.14.4)
~ $ which node
/Users/edc/.nvm/versions/node/v4.1.1/bin/node
~ $ cd tmp
~/tmp $ cat .nvmrc
v0.10.40
~/tmp $ nvm use
Found /Users/edc/tmp/.nvmrc with version <v0.10.40>
Now using node v0.10.40 (npm v1.4.28)
~/tmp $ which node
/Users/edc/.nvm/v0.10.40/bin/node
~/tmp $ nvm current
v0.10.40
~/tmp $ which node
/Users/edc/.nvm/v0.10.40/bin/node
~/tmp $ nvm --version
0.25.4
Have you tried the same flow in bash?
from bass.
I got mostly what you got
~/tmp$ cat ~/.config/fish/functions/nvm.fish
function nvm
bass source ~/.nvm/nvm.sh ';' nvm $argv
end
~$ nvm current
v4.1.1
~$ which node
/Users/ttt/.nvm/versions/node/v4.1.1/bin/node
~$ cd tmp
~/tmp$ nvm use
Found /Users/ttt/tmp/.nvmrc with version <v0.10.40>
Now using node v0.10.40 (npm v1.4.28)
~/tmp$ which node
/Users/ttt/.nvm/v0.10.40/bin/node
~/tmp$ nvm current
v4.1.1
~/tmp$ which node
/Users/ttt/.nvm/versions/node/v4.1.1/bin/node
~/tmp$ nvm --version
/Users/ttt/.nvm/nvm.sh: line 2188: echo: write error: Broken pipe
0.28.0
This bit might say something /Users/ttt/.nvm/nvm.sh: line 2188: echo: write error: Broken pipe
, which points to the 2nd line here
nvm_supports_source_options() {
[ "_$(echo 'echo $1' | . /dev/stdin yes 2> /dev/null)" = "_yes" ]
}
Any ideas?
from bass.
I suspect it's because of nvm
. Is it possible for you to downgrade to 0.27.x? I will test with 0.28.0 if you still have the same problem after downgrade.
from bass.
Nope, downgrading didn't work:
~$ nvm current
v4.1.1
~$ which node
/Users/ttt/.nvm/versions/node/v4.1.1/bin/node
~$ cd tmp
~/tmp$ nvm use
/Users/ttt/.nvm/nvm.sh: line 2111: echo: write error: Broken pipe
Found /Users/ttt/tmp/.nvmrc with version <v0.10.40>
Now using node v0.10.40 (npm v1.4.28)
~/tmp$ which node
/Users/ttt/.nvm/v0.10.40/bin/node
~/tmp$ nvm current
v4.1.1
~/tmp$ which node
/Users/ttt/.nvm/versions/node/v4.1.1/bin/node
~/tmp$ nvm --version
0.27.1
I've also tried with 0.27.0
, and 0.25.4
(the one you were using)
I don't think it is nvm
because it works fine when I switch to bash and run the exact commands.
I'm thinking it's something to do with the bass source ~/.nvm/nvm.sh
line in the nvm
function
from bass.
I found the problem. It was because I had the default
alias. Removing the default
alias allows nvm
to just use the previously set nvm
version ie,
~$ nvm current
system
~$ which node
/usr/local/bin/node
~$ cd tmp
~/tmp$ nvm use
Found /Users/ttt/tmp/.nvmrc with version <v0.10.40>
Now using node v0.10.40 (npm v1.4.28)
~/tmp$ nvm current
v0.10.40
~/tmp$ which node
/Users/ttt/.nvm/v0.10.40/bin/node
~/tmp$ cd ..
~$ nvm current
v0.10.40
~$ which node
/Users/ttt/.nvm/v0.10.40/bin/node
Note how the nvm version is the same even after going to a different directory. In the previous case, the default
would override this.
Bash does do what is expected though, so it's still kind of a bug in the bass version. However, it works for me without default
, so I'm good =)
Up to you, what you want to do with this 🐛 =)
from bass.
Glad to hear it works out!
I was able to reproduce it, and the bug was because nvm.sh
switches to the default every time it is source'd. Bass has to source nvm.sh
on every nvm command, so this is a limitation that's a bit hard to address. For now, I would suggest to not add a default
alias as a workaround. I'll leave this open to see if I can come up with a fix.
from bass.
Can bass not do something along the lines of (pseudocode) "if nvm is already sourced, and nvm current
works, store that value in a variable, and after sourcing nvm, nvm use --silent $previousValue
"?
It's slightly inefficient but not that bad.
from bass.
Does fish + bass support sourcing with arguments? if so, I would consider adding (in addition to the --install
argument that's already there) a --no-use
argument that bypassed the auto-use behavior.
from bass.
Does fish + bass support sourcing with arguments
The short answer is yes. The sourcing is done by bash, so as long as bash supports it, it works. I tested with the following fish function:
$ cat ~/.config/fish/functions/nvm.fish
function nvm
bass source ~/.nvm/nvm.sh --no-use ';' nvm $argv
end
Then I modified nvm.sh to add support of --no-use
:
@@ -1791,9 +1791,9 @@
elif nvm_rc_version >/dev/null 2>&1; then
nvm install >/dev/null
fi
-elif [ -n "$VERSION" ]; then
+elif [ -n "$VERSION" ] && [ "_$1" != "_--no-use" ]; then
nvm use "$VERSION" >/dev/null
-elif nvm_rc_version >/dev/null 2>&1; then
+elif nvm_rc_version >/dev/null 2>&1 && [ "_$1" != "_--no-use" ]; then
nvm use >/dev/null
fi
Now it works flawlessly:
$ cat .nvmrc
v4.1.1
$ nvm use default
Now using node v0.10.41 (npm v1.4.29)
$ nvm current
v0.10.41
$ nvm use system
Now using system version of node: v0.12.2 (npm v2.7.5)
$ nvm current
system
$ nvm use
Found /private/tmp/.nvmrc with version <v4.1.1>
Now using node v4.1.1 (npm v2.14.4)
/private/tmp
$ nvm current
v4.1.1
I think it's a pretty good solution!
from bass.
Awesome. I'll add it as part of nvm-sh/nvm#972 (and the ordering of --install
or --no-use
won't actually matter, but --no-use
will of course trump --install
) and update here when it's released.
from bass.
Great! Thanks, @ljharb!
from bass.
Done and released in v0.30.2.
from bass.
Thanks, @ljharb!
@taktran, is this good to close?
from bass.
Great, thanks!
from bass.
Related Issues (20)
- How does bass import function from bash and why nvm need sourced every time ? HOT 2
- Annoying virtualenv conflict HOT 1
- Newlines sourced as \\n string literals
- append_path: command not found
- Quotes disappear from arguments when running script through bass HOT 3
- No module named 'json' HOT 3
- bass -d "source someshell.sh" not exactly stay the same every time
- Sourcing large number of exports is very slow, or hangs indefinitely HOT 10
- Command 'python' not found HOT 5
- "Variables may not be used as commands" HOT 2
- variables cannot be bracketed HOT 1
- "Bass internal error!" when status code is not 0 HOT 5
- Sourcing bash alias with question mark triggers `No matches for wildcard` error HOT 3
- cannot read file system information bug HOT 1
- `$1` is set in contrast to bash HOT 8
- Test scripts: using double `dirname` does not work if command line is `./test_dollar_on_output.fish` HOT 1
- Alias with $* does not get correctly converted HOT 1
- Significantly slower to source paths to a different directory HOT 4
- Bass and ssh-agent aren't interacting well on Linux HOT 3
- Can bass convert script files? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bass.