Skip to content
This repository has been archived by the owner on Dec 6, 2023. It is now read-only.

Opening new tmux split runs avn twice #20

Closed
aaronjensen opened this issue Aug 30, 2015 · 7 comments
Closed

Opening new tmux split runs avn twice #20

aaronjensen opened this issue Aug 30, 2015 · 7 comments

Comments

@aaronjensen
Copy link

Using zsh, these dotfiles: https://github.com/aaronjensen/dotfiles

When I open a tmux split from a directory w/ a .nvmrc I get two activation messages. The first is in color, the second is not:

avn activated v0.10.26 via .nvmrc (avn-nvm v0.10.26)
avn activated v0.10.26 via .nvmrc (avn-nvm v0.10.26)

To repro, use my dotfiles:

$ tmux
$ cd <some dir w/ .nvmrc>
# Hit ctrl-o, v to open a split
@wbyoung
Copy link
Owner

wbyoung commented Aug 30, 2015

@aaronjensen thanks for the report.

I can't reproduce this, but I'm also needing to comment out set-option -g default-command "reattach-to-user-namespace -l $SHELL -l" from your tmux config to get tmux running. Perhaps that could be the problem… can you try disabling this and see what happens?

I'll try to look into this more at some point, but the duplicate message is probably a symptom of avn receiving multiple calls for the chpwd_functions hook or being run multiple times. Also, your setup probably puts you into an edge case category, so while I'd like to get to the bottom of this, it's also likely that it'll be a low priority.

PR welcome, though. 😄

For anyone who looks into this in the future, the dotfiles are currently aaronjensen/dotfiles@026bd5b.

@wbyoung wbyoung changed the title opening a new terminal prints activation message twice Opening new tmux split runs avn twice Aug 30, 2015
@aaronjensen
Copy link
Author

Removing reattach-to-user-namespace doesn't help. When you used the were you using bash or zsh? They start out as zsh by default.

I just added a .nvmrc to my home directory and opened a new window and it repro'd, so no tmux required...

@aaronjensen
Copy link
Author

Here's the problem, a hack to work around problems w/ rvm:

https://github.com/aaronjensen/dotfiles/blob/master/zlogin#L2

so... i guess it'd be nice if avn was idempotent. It didn't switch versions if it didn't need to?

@aaronjensen
Copy link
Author

I fixed the root cause (zshenv adding to path multiple times somehow broke rvm's initial path loading) and removed the hacks. All good now. It'd still be nice if avn was idempotent (especially because avn, and to a lesser extent nvm, is surprisingly slow)

@wbyoung
Copy link
Owner

wbyoung commented Aug 31, 2015

It's

@wbyoung
Copy link
Owner

wbyoung commented Aug 31, 2015

It's idempotent with respect to itself, but it'd require (more) internal knowledge of nvm and n to truly get there.

@wbyoung
Copy link
Owner

wbyoung commented Aug 31, 2015

Oh, and on the speed issue: avn should not have any noticeable impact when you cd anywhere without a config file.

When it performs a switch, it may be slow (it starts a node process & performs file operations), but as you mention nvm can be slow, too. I could add some profiling timers into the code base to help figure out where speed issues occur. I've had better luck with n for faster startup of new shells and switching.

I know @ljharb and others have been working on speed in nvm:

nvm-sh/nvm#703

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants