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

fix: return err if symlink is not created #259

Merged
merged 1 commit into from
May 13, 2024

Conversation

AnWeber
Copy link
Contributor

@AnWeber AnWeber commented May 12, 2024

I would have tried to create a plugin yesterday (https://github.com/anweber/vfox-mani). It was hard because vfox is not always chatty about error. For example, the symlink was not created, but the command vfox use [email protected] was completed without error.
Apparently, the optional hook pre_use.lua is expected to return the current version. Only then will the current folder be created, for which a symlink is generated. The dependencies are not well documented, so I was only able to determine the cause of the error after debugging vfox.
This MR now always logs the error and also displays the file name used (targetDir .. "/current"). This MR, does not fix the problem, that the first PATH variable must always have a subfolder current. If there is no pre_use hook, this folder may not exist.

@aooohan
Copy link
Member

aooohan commented May 13, 2024

Apparently, the optional hook pre_use.lua is expected to return the current version. Only then will the current folder be created, for which a symlink is generated.

Normally, pre_use and symlink have no direct dependency. We can still use the plugin as normal, without implementing the pre_use hook.

Can you give the steps to reproduce? And what operating system did you test on?

The dependencies are not well documented, so I was only able to determine the cause of the error after debugging vfox.

Sorry for all the trouble. You can see the debug logs without debugging vfox by adding --debug flag, such as vfox --debug use mani.

@aooohan aooohan changed the title feat: return err if symlink is not created fix: return err if symlink is not created May 13, 2024
@aooohan aooohan closed this May 13, 2024
@aooohan aooohan reopened this May 13, 2024
@aooohan aooohan merged commit 3614e26 into version-fox:main May 13, 2024
@AnWeber AnWeber deleted the fail_on_symlink_error branch May 13, 2024 19:19
@AnWeber
Copy link
Contributor Author

AnWeber commented May 13, 2024

Normally, pre_use and symlink have no direct dependency. We can still use the plugin as normal, without implementing the pre_use hook.

I would have tried to reproduce the error again today (with 0.5.0 and 0.5.1). I did not get it again. I don't understand the changed behavior at the moment. Test system is WSL2 with Distro Ubuntu (Host win11), Shell ZSH. Error was when creating the symlink, but without a specific cause. As you advised, I only saw it after using --debug. I generated the error with this commit version: vfox-mani. Command vfox use [email protected] created no error entry but, mani did not work. I'm still trying to recreate it, but I blame it on a code corpse that I didn't commit or delete. Error seems to be on my side.

Sorry for all the trouble. You can see the debug logs without debugging vfox by adding --debug flag, such as vfox --debug use mani.

You have programmed a nice piece of code. And it was very easy to set up and It's fun to play with. But I probably missed a few little things:

  • add hint for --debug arg in Test plugin section, I tried --verbose and only found the global args after some time because I tried vfox current --help which does not output the --debug arg
  • add some best practices plugin which supports an easy use case. Most asdf plugins download only assets added on the release page of a Github Release(e.g elm, bun, zoxide, yq). Your empty template is great for documentation, but I prefer a simple working example.
  • a better distinction between which plugins are official and which are user provided. My approach to new projects is that I adapt a working example to my needs. I prefer official code which follows some best practices.
  • Documentation for ctx is missing. A link to an interface would be nice

These are just suggestions, and more of a retro for me of what I failed at (I'll leave out the fact that I've never programmed lua. :-)).

@aooohan
Copy link
Member

aooohan commented May 14, 2024

You have programmed a nice piece of code. And it was very easy to set up and It's fun to play with. But I probably missed a few little things:

  • add hint for --debug arg in Test plugin section, I tried --verbose and only found the global args after some time because I tried vfox current --help which does not output the --debug arg
  • add some best practices plugin which supports an easy use case. Most asdf plugins download only assets added on the release page of a Github Release(e.g elm, bun, zoxide, yq). Your empty template is great for documentation, but I prefer a simple working example.
  • a better distinction between which plugins are official and which are user provided. My approach to new projects is that I adapt a working example to my needs. I prefer official code which follows some best practices.
  • Documentation for ctx is missing. A link to an interface would be nice

These are just suggestions, and more of a retro for me of what I failed at (I'll leave out the fact that I've never programmed lua. :-)).

Thanks for the suggestions, they're very useful, and I'll take them one by one. ;)

aooohan added a commit that referenced this pull request May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants