It appears that Brian Murray is no longer at Canonical.
I hope someone from [email protected] team listed as maintainer at 
https://packages.ubuntu.com/noble/nodeenv is aware of this.

I believe the above patch is not fully functional on Ubuntu 24.04, since 
nodeenv 0.13.4 contains a hard-coded python2 dependency.
As a workaround /usr/lib/python3/dist-packages/nodeenv.py can be edited to 
replace the hard coded python2 with python3 (on the line containing ['which', 
'python2'] ...).

################## Apply the patch
docker run -it ubuntu:24.04 bash
apt update
DEBIAN_FRONTEND=noninteractive apt install -y curl patch
DEBIAN_FRONTEND=noninteractive apt install -y nodeenv
curl -sLO 
https://bugs.launchpad.net/ubuntu/+source/nodeenv/+bug/2091101/+attachment/5854962/+files/nodeenv.diff
patch -d /usr/lib/python3/dist-packages < nodeenv.diff 

################## Test 1: Listing of node versions works
nodeenv --list

/usr/bin/nodeenv:6: DeprecationWarning: pkg_resources is deprecated as an API. 
See https://setuptools.pypa.io/en/latest/pkg_resources.html
  from pkg_resources import load_entry_point
/usr/lib/python3/dist-packages/nodeenv.py:759: SyntaxWarning: invalid escape 
sequence '\d'
  VERSION_RE = re.compile('\d+\.\d+\.\d+')
/usr/lib/python3/dist-packages/nodeenv.py:914: SyntaxWarning: invalid escape 
sequence '\.'
  ACTIVATE_SH = """
0.0.1
...

################## Test 2: Installing a node version fails due to a missing 
python2 version.
This problem was discussed upstream in 
https://github.com/ekalinin/nodeenv/pull/305, but a breaking workaround of 
switching to "#!/usr/bin/env python3" was rejected.
Installing "apt-get install python3-is-python" does not resolve this problem.
However, /usr/lib/python3/dist-packages/nodeenv.py can be edited to replace the 
hard coded python2 with python3 as a workaround.

nodeenv --node=22.15.0 env

/usr/bin/nodeenv:6: DeprecationWarning: pkg_resources is deprecated as an API. 
See https://setuptools.pypa.io/en/latest/pkg_resources.html
  from pkg_resources import load_entry_point
/usr/lib/python3/dist-packages/nodeenv.py:759: SyntaxWarning: invalid escape 
sequence '\d'
  VERSION_RE = re.compile('\d+\.\d+\.\d+')
/usr/lib/python3/dist-packages/nodeenv.py:914: SyntaxWarning: invalid escape 
sequence '\.'
  ACTIVATE_SH = """
 * Install node (22.15.0).Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/nodeenv.py", line 544, in 
build_node_from_src
    _, which_python2_output = callit(
                              ^^^^^^^
  File "/usr/lib/python3/dist-packages/nodeenv.py", line 460, in callit
    raise OSError("Command %s failed with error code %s"
OSError: Command which python2 failed with error code 1

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/bin/nodeenv", line 11, in <module>
    load_entry_point('nodeenv==0.13.4', 'console_scripts', 'nodeenv')()
  File "/usr/lib/python3/dist-packages/nodeenv.py", line 890, in main
    create_environment(env_dir, opt)
  File "/usr/lib/python3/dist-packages/nodeenv.py", line 731, in 
create_environment
    install_node(env_dir, src_dir, opt)
  File "/usr/lib/python3/dist-packages/nodeenv.py", line 607, in install_node
    build_node_from_src(env_dir, src_dir, node_src_dir, opt)
  File "/usr/lib/python3/dist-packages/nodeenv.py", line 549, in 
build_node_from_src
    raise OSError(
OSError: Python >=3.0 virtualenv detected, but no python2 command (required for 
building node.js) was found

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2091101

Title:
  Crashes when listing versions

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/nodeenv/+bug/2091101/+subscriptions


-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to