#1102884 pyenv: man page is inaccurate + pyenv: cannot rehash: /usr/share/pyenv/shims isn't writable

Package:
pyenv
Source:
pyenv
Submitter:
Francesco Poli (wintermute)
Date:
2025-07-21 17:15:02 UTC
Severity:
normal
Tags:
#1102884#5
Date:
2025-04-12 18:34:07 UTC
From:
To:
Dear Maintainer,
I gave pyenv a try and noticed the following issue.

The pyenv(1) man page states, in part:

[...]
|      1. Append the following to $HOME/.bashrc
|
|                     if command -v pyenv 1>/dev/null 2>&1;
|                        eval "$(pyenv init - bash)"
|                     fi
[...]

However, this suggestion is wrong.
Firstoff, a "then" is missing after the semicolon (syntax error).
Secondly, if the PYENV_ROOT environment variable is not set to
a suitable user-writable directory, the following error is generated
each time a shell is started:

  mkdir: cannot create directory ‘/usr/share/pyenv/versions’: Permission denied

A better suggestion seems to be to append the following to $HOME/.bashrc

                      export PYENV_ROOT="$HOME/.pyenv"
                      if command -v pyenv 1>/dev/null 2>&1; then
                          eval "$(pyenv init - bash)"
                      fi

However, this (after I started actually using pyenv) began to produce
the following error each time a shell is started:

  pyenv: cannot rehash: /usr/share/pyenv/shims isn't writable

Other than this (do you need a separate bug report for it?), pyenv
seems to work, even though my $PATH is modified by adding three new
directories:

  (a)   $HOME/.pyenv/shims
  (b)   /usr/share/pyenv/shims
  (c)   /usr/share/pyenv/bin

I can understand the reason behind the addition of directory (a),
which is  $(pyenv root)/shims  , as documented in the man page.
I am not sure I understand why directory (c) is added, as this
directory does not exist.
I suspect that the addition of directory (b) is the cause of the
error I am seeing.

Please fix the man page and/or the manipulation of the $PATH by pyenv
(and/or forward my bug report upstream, as appropriate).

Thanks for your time and dedication!

#1102884#12
Date:
2025-05-06 18:00:10 UTC
From:
To:
We believe that the bug you reported is fixed in the latest version of
pyenv, which is due to be installed in the Debian FTP archive.

A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to 1102884@bugs.debian.org,
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
Josenilson Ferreira da Silva <nilsonfsilva@hotmail.com> (supplier of updated pyenv package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing ftpmaster@ftp-master.debian.org)
Format: 1.8
Date: Fri, 02 May 2025 21:05:39 -0300
Source: pyenv
Binary: pyenv pyenv-runtime
Architecture: source all
Version: 2.5.5-1
Distribution: experimental
Urgency: medium
Maintainer: Debian Python Team <team+python@tracker.debian.org>
Changed-By: Josenilson Ferreira da Silva <nilsonfsilva@hotmail.com>
Description:
 pyenv      - Simple Python version management
 pyenv-runtime - Simple Python version management (runtime components)
Closes: 1102884 1103905
Changes:
 pyenv (2.5.5-1) experimental; urgency=medium
 .
   * New upstream version 2.5.5
   * debian/control:
      - Added binary with simple components for runtime (Closes: #1103905)
      - Added Breaks/Replaces for pyenv-runtime
      - Updated list of required dependencies
   * debian/copyright:
      - Updated GPL2 license terms
   * debian/patches:
      - 004.fixed-line-break.patch: Removed pyenv.1 file
      - 006.change-shell-to-fix-test.patch: Fixed hunk issue
      - 007.fixed-command-manpage.patch: Fix command  bashrc (Closes: #1102884)
      - 008.added-pyenv-runtime-information.patch: Add information pyenv-runtime
   * debian/pyenv.install:
      - Specified pyenv binary package files
   * debian/pyenv.links:
      - Removed pyenv binary link
   * debian/pyenv.manpages:
      - Removed pyenv manpage
   * debian/pyenv-runtime.instal:
      - Added components to pyenv-runtime binary
   * debian/pyenv-runtime.links:
      - Created pyenv symbolic link
   * debian/pyenv-runtime.manpages:
      - Linked pyenv manpage to pyenv-runtime binary
   * debian/pyenv.sh:
      - Removed unnecessary wrapper
   * debian/rules:
      - Adjustments for correct construction of binaries
      - Fixed variable declaration
Checksums-Sha1:
 0b6000e92ab49547b84cb955ac80e6eba6658027 2118 pyenv_2.5.5-1.dsc
 34bd01d71cf2855c0431d63237851900678ef588 1339960 pyenv_2.5.5.orig.tar.gz
 e39ba5ac2a090e59dafb289987a86e8476fa155b 11068 pyenv_2.5.5-1.debian.tar.xz
 3d5f9d67e64f76bb48436b079578d639aa5581c8 40884 pyenv-runtime_2.5.5-1_all.deb
 39163f1efb7b5a16dc95b466ce6c6c7a6512146e 309440 pyenv_2.5.5-1_all.deb
 d37694c19095c33483eef1d3175fc6eabeec6b96 8840 pyenv_2.5.5-1_amd64.buildinfo
Checksums-Sha256:
 19f0d8faf288a1baa15544b18ec0a13c610e1471166f308c420dbdd2ce894c0d 2118 pyenv_2.5.5-1.dsc
 f1992bb226b4b258ff1ce3168c0470f87a1affa5f796d820f5dfc3d20bd82008 1339960 pyenv_2.5.5.orig.tar.gz
 1ef2723a341977c31ea2f460f3872740f154f49b7c11cdb61d78d3faed390079 11068 pyenv_2.5.5-1.debian.tar.xz
 1ab567b78b365ade4acad5b2687ba80808a8d9570865dea05c29d3ae7d6322dd 40884 pyenv-runtime_2.5.5-1_all.deb
 bd1e211463be8ed7f57167f41771c3ee8c7eae2964ae890b877dd4b7768566e8 309440 pyenv_2.5.5-1_all.deb
 6f4e1b72d001416f83472f569ac3d93e242b9b75f57eaf0ddbc4eb895d2e6fdb 8840 pyenv_2.5.5-1_amd64.buildinfo
Files:
 d37367d09ffe4b5ba3d6533d77339d64 2118 python optional pyenv_2.5.5-1.dsc
 57164da57f5db45e646edcf34e39203d 1339960 python optional pyenv_2.5.5.orig.tar.gz
 3477954b4bd704482a964c791c98c082 11068 python optional pyenv_2.5.5-1.debian.tar.xz
 6b0a46aa0a701e8442ad167d70094923 40884 python optional pyenv-runtime_2.5.5-1_all.deb
 28fc0c10466ad4da363334e52ef009b8 309440 python optional pyenv_2.5.5-1_all.deb
 e1cac7b63affd4693f1e43dbae9eaab6 8840 python optional pyenv_2.5.5-1_amd64.buildinfo
-----BEGIN PGP SIGNATURE-----

iQJGBAEBCgAwFiEEdyKS9veshfrgQdQe5fQ/nCc08ocFAmgaAnwSHG1lcmt5c0Bk
ZWJpYW4ub3JnAAoJEOX0P5wnNPKHJj8QAKQP6C+SoRqmPPZvHsaexYbAAT3lrvrv
8/uxl3JrNO6eXo5BR+5z1cElx6plvGX3cevoPxr8Bc41hBU1T9OreqkO3Quq9X7p
ksJswawfJ2A5luGaLlFituNKTkETqftuNy9GMHiEH14urEi8PdixHhjnfpUcTUKl
+ouAPuOnjX0GIToAmWqy1zBCNnHDkbK48UBger2Y9G+C2EW3i1Zx8XQtyxM6oWsc
G43nP2Ln8IfQktqU/5GrEKY2+7aJAFg4yQJF/YZH1CX5z1NZL5btEbOpGaJkriqZ
ytrmR/5vL+V5oEh7HttiEH9ddT3vP3MtaCKK668JVR2/poWgzHXFhV6ze4E3+m5p
Kz+focFQ0lvt30mWcbQxlwpZuhZvYSQTTd6x1YkQ0cILKhT24NB5wP6IUsC1w+ea
ZGfWgroRrjGqdsySq9Pb0c98z++lR9l6gZmQeEeHZu17YQpqdJOc8JAR9DGuMn+5
oHa5fZEw6D28kby+yRuObhDRiS63a8RAxienLPEGFep2WcH0uyq0vc2wYGS7ue0i
AZsDegycLTOJUIoAFPXsrfe5oXkZoAg1smvvbrbfaax0ZoktryxLcN8SQCS3PfqS
wUP6mWs6qtFIWLTLxm0e552HN5rPLk2dhaTdVRhuBrLnlqBqY+ch6VqzqGgK8ZbI
ZHbHhC2KG2PN
=l1Y7
-----END PGP SIGNATURE-----

#1102884#17
Date:
2025-05-07 12:16:12 UTC
From:
To:
Hello,

this bug was ultimately caused by /etc/profile.d/pyenv.sh, which Debian ships.

It sets the PYENV_ROOT to a directory that the user cannot actually write to,
in the users environment.

This basically breaks all of pyenv for non-root usage; installing versions
no longer works even if the shims for shell integration aren't used at all,
which is what I'm doing.

If there's some need for me to add a bit more urgency to getting the fixed
version rolled into trixie, I'd say this is it: pyenv is unusable out of the
box for anyone but root even without any shims as soon as the user logs back
into their shell, because the profile.d file that is in 2.5.4 but thankfully
will be removed in 2.5.5 sets environment variables to something that doesn't
make sense.

#1102884#22
Date:
2025-07-21 17:04:12 UTC
From:
To:
Control: found -1 pyenv/2.5.5-1
[...]

Hello Nicolas,
thanks for spotting this, which really seems to be the root cause of
the "cannot rehash" error.

However, file '/etc/profile.d/pyenv.sh' still seems to be shipped in the
pyenv/2.5.5-1 Debian package.

I am thus reopening this bug report.


Josenilson,
please drop '/etc/profile.d/pyenv.sh' from the Debian package.

Moreover, the man page now suggests:

[...]
|      1. Append the following to $HOME/.bashrc
|
|                     if command -v pyenv 1>/dev/null 2>&1; then
|                         export PYENV_ROOT="$HOME/.pyenv"
|                         export PATH="$PYENV_ROOT/bin:$PATH"
|                         eval "$(pyenv init - bash)"
|                     fi
[...]

This suggestion is better than it was in the pyenv/2.5.4-1 Debian
package, but now suggests to add a path that does not seem to
exist ("$PYENV_ROOT/bin").

I would say that a better suggestion would more simply be:

[...]
|      1. Append the following to $HOME/.bashrc
|
|                     if command -v pyenv 1>/dev/null 2>&1; then
|                         export PYENV_ROOT="$HOME/.pyenv"
|                         eval "$(pyenv init - bash)"
|                     fi
[...]

Please enhance the man page.

Thanks for your time and dedication.