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

Latest pyenv versions require different initialisation #1882

Closed
SwampFalc opened this issue May 18, 2021 · 6 comments · Fixed by #1885
Closed

Latest pyenv versions require different initialisation #1882

SwampFalc opened this issue May 18, 2021 · 6 comments · Fixed by #1885
Assignees

Comments

@SwampFalc
Copy link

SwampFalc commented May 18, 2021

The latest versions of pyenv no longer support the initialisation commands that are currently used in the plugin.

Error message upon starting a new terminal:

WARNING: `pyenv init -` no longer sets PATH.
Run `pyenv init` to see the necessary changes to make to your configuration.

Expected Behavior

  • Using the pyenv plugin should work without error message.
  • The shims folder is no longer in PATH.

Current Behavior

Error message. No shims in PATH.

Possible Solution

Hard to say... The fix in and of itself is simple, but I do not expect it to be backwards compatible. So anyone that updates bashit but not their pyenv would end up with the inverse problem.

Fix: use pyenv init --path instead of pyenv init -

Steps to Reproduce

  1. Update pyenv following https://github.com/pyenv/pyenv#upgrading
  2. Open a new terminal

Your Environment

  • Bash-it version used: latest
  • pyenv version used: also latest (1.2.27-41-gddf952ab)
@SwampFalc SwampFalc changed the title Latest pyenv versions require different commands Latest pyenv versions require different initialisation May 18, 2021
@cornfeedhobo
Copy link
Member

Well that's a bummer. I'll try to take a look this weekend.

@cornfeedhobo cornfeedhobo self-assigned this May 19, 2021
@SwampFalc
Copy link
Author

Looking at it, I think pyenv/pyenv#1920 is probably the place with the most explanations about what's happening, why and what their plans for the future are.

@davidpfarrell
Copy link
Contributor

Thanks for reporting this !

So changes like this one have been a long-time-coming since you're not really supposed to modify the $PATH variable within .bashrc, which is where these types of evals usually live.

I have an idea for dealing with this particular instance:

The devs have made the pyenv init --path effects transparent here:

Sets up your shims path. This is the only requirement for pyenv to function properly. You can do this by hand by prepending $(pyenv root)/shims to your $PATH.

With this transparency, we have permission to manually add the shims folder to our path, ie something like:

eval "$(pyenv init -)"
# In case we're using a new pyenv, manually add the shims to the path 
# pathmunge will safely abort if the path entry is already present
pathmunge "$(pyenv root)/shims" before

This could be a one-line fix that gets us past the issue for now ...

@SwampFalc
Copy link
Author

That approach sounds more backwards compatible.
However, I do believe the order should be reversed. Since pyenv init - rehashes the shims, I suspect it might need the shims folder in the path already.

@davidpfarrell
Copy link
Contributor

Since pyenv init - rehashes the shims, I suspect it might need the shims folder in the path already.

Doh!, yes that is correct.

An issue with setting the path first is that pyenv doesn't check the path before generating the new path statement (verified locally), so if the shims folder is already on the path, will be added to the path again ... perhaps not a terrible issue but less than ideal.

So, reversing the order could be a quick-fix while we work on a better one.

I suspect we'll need multiple plugins with some kind of tag in the name to distinguish them ...

@cornfeedhobo
Copy link
Member

I've deleted my last comment because it was too long and not accurate. Instead, I've opened a PR that solves the problem, and will follow up with any discussion there. Thanks @SwampFalc & @davidpfarrell !

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

Successfully merging a pull request may close this issue.

3 participants