Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: .tool-versions behavior #228

Open
NamPNQ opened this issue Apr 22, 2024 · 8 comments · May be fixed by #289
Open

[BUG]: .tool-versions behavior #228

NamPNQ opened this issue Apr 22, 2024 · 8 comments · May be fixed by #289
Assignees
Labels
bug Something isn't working
Milestone

Comments

@NamPNQ
Copy link

NamPNQ commented Apr 22, 2024

Describe the bug
The behavior of asdf will keep search up until reach /
https://github.com/asdf-vm/asdf/blob/ccdd47df9b73d0a22235eb06ad4c48eb57360832/lib/utils.bash#L212

While vfox just use config from current directory

@NamPNQ NamPNQ added the bug Something isn't working label Apr 22, 2024
@aooohan
Copy link
Member

aooohan commented Apr 23, 2024

https://vfox.lhan.me/guides/quick-start.html#_5-switch-runtime

vfox use config from three places:

  1. $HOME/.version-fox/.tool-versions
  2. $PWD/.tool-versions
  3. $HOME/.version-fox/tmp/<shell-pid>/.tool-versions

The behavior of asdf will keep search up until reach /

To be honest, I don't like this strategy.

@NamPNQ
Copy link
Author

NamPNQ commented Apr 23, 2024

Just imagine you're in project, config .tool-versions is stay in project/.tool-versions. Then you go to child dir on your project, what you expected? You want use the right tools you already configured or any another version?

@aooohan
Copy link
Member

aooohan commented Apr 23, 2024

Then you go to child dir on your project, what you expected? You want use the right tools you already configured or any another version?

The current vfox strategy is that if you have a .tool-version in your project (project/.tool-versions), that version will be used in the current shell, regardless of whether you switch directories or not, the version is not changed until the next .tool-versions file is encountered, or vfox use command is executed manually.

@NamPNQ
Copy link
Author

NamPNQ commented Apr 23, 2024

Maybe we don't understand each other
Here is simple to reproduce what I mean

$ cd `mktemp -d`
$ mkdir -p proj/child
$ node -v # 20 for example
$ echo "nodejs 16.20.2" > proj/.tool-versions
$ vfox install nodejs@16.20.2
$ cd proj
$ node -v # 16 => its ok
$ cd child
$ node -v # 20 => its not ok => and this is unexpected behavior since another tools (asdf, nvmrc, pyenv...) always look at parent folder

@aooohan
Copy link
Member

aooohan commented Apr 24, 2024

$ cd `mktemp -d`
$ mkdir -p proj/child
$ node -v # 20 for example
$ echo "nodejs 16.20.2" > proj/.tool-versions
$ vfox install nodejs@16.20.2
$ cd proj
$ node -v # 16 => its ok
$ cd child
$ node -v # 20 => its not ok => and this is unexpected behavior since another tools (asdf, nvmrc, pyenv...) always look at parent folder

Okay, it can indeed be reproduced.

@aooohan aooohan added this to the 0.4.2 milestone Apr 24, 2024
@NamPNQ
Copy link
Author

NamPNQ commented Apr 29, 2024

@aooohan Your fix is not works if we go directly to child folder

@aooohan
Copy link
Member

aooohan commented Apr 29, 2024

@aooohan Your fix is not works if we go directly to child folder

I'm aware of this, and for this issue, I need to make sure that the behavior I described earlier is correct.

As I said earlier, I really don't like the strategy of keeping search up until reach /.

Also, as for the situation you mentioned, I can't think of a case where it would go directly to a child folder of the project instead of the project root first.

@NamPNQ
Copy link
Author

NamPNQ commented May 2, 2024

I think navigate to child directory is a common practice, particularly in monorepo projects.
Additionally, several other approaches exist, such as launch a new shell from the child directory

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants