Skip to content

--node=system won't work if there's already a compiled node on the virtualenv #43

Closed

Description

@maniqui

This may not be a bug per-se, but I've found this: on a virtualenv, if you first run nodeenv -p, it will download, compile and install a copy of node on ~/.virtualenvs/myproject/bin. So far, so good.

But later, if you decide to use the system-wide node install, running nodeenv -p --node=system won't help you (nor running nodeenv--node=system, without the -p option).
The standard output will tell you that some changes are applied to ~/.virtualenvs/myproject/bin/activate and it may even install npm, but the compiled node will be still there in ~/.virtualenvs/myproject/bin/, and a which node will tell you that that's the node that will be used.

In other words, the --node=system didn't take any effect, and one could say that it "failed silently".

BTW, as a side-effect of running nodeenv -p a few times, I noticed that the same lines are n-plicated inside ~/.virtualenvs/myproject/bin/activate. I don't know if there is a "cure" for that, but just letting you know. I manually cleaned the n-plicated lines.

Activity

  1. maniqui commented on Oct 9, 2013

    @maniqui
    Author

    BTW, I forgot to comment the workaround for re-configuring nodeenv to use the system-wide node is:

    1. delete the node file from ~/.virtualenvs/myproject/bin/. This is the one that was downloaded, compiled & installed by nodeenv.
    2. run nodeenv -p --node=system

    You can confirm which node is being used in the current virtualenv by running `which node'

  2. neverfox commented on May 18, 2014

    @neverfox

    I tried this workaround in 0.7.2, and still get the following error from nodeenv -p --node=system

    * Appending nodeenv settings to /home/neverfox/.virtualenvs/my_project/bin/activate
     * Install npm.js (latest) ... Traceback (most recent call last):
      File "/home/neverfox/.virtualenvs/my_project/bin/nodeenv", line 9, in <module>
        load_entry_point('nodeenv==0.7.2', 'console_scripts', 'nodeenv')()
      File "/home/neverfox/.virtualenvs/my_project/lib/python2.7/site-packages/nodeenv-0.7.2-py2.7.egg/nodeenv.py", line 546, in main
        create_environment(env_dir, opt)
      File "/home/neverfox/.virtualenvs/my_project/lib/python2.7/site-packages/nodeenv-0.7.2-py2.7.egg/nodeenv.py", line 482, in create_environment
        install_npm(env_dir, src_dir, opt)
      File "/home/neverfox/.virtualenvs/my_project/lib/python2.7/site-packages/nodeenv-0.7.2-py2.7.egg/nodeenv.py", line 409, in install_npm
        callit(cmd, opt.verbose, True)
      File "/home/neverfox/.virtualenvs/my_project/lib/python2.7/site-packages/nodeenv-0.7.2-py2.7.egg/nodeenv.py", line 299, in callit
        % (cmd_desc, proc.returncode))
    OSError: Command ". /home/neverfox/.virtu...h && deactivate_node" failed with error code 2
    
  3. ekalinin commented on May 19, 2014

    @ekalinin
    Owner

    Hi @neverfox !

    Here's my try:

    ➥ node -v
    v0.10.25
    ➥ virtualenv env
    ➥ . env/bin/activate
    (env) ➥ pip install nodeenv
    (env) ➥ nodeenv --version
    0.9.2
    (env) ➥ nodeenv -p --prebuilt
     * Install node.js (0.10.28) ... done.
     * Appending nodeenv settings to ~/tmp/nodeenv-test/env/bin/activate
    (env) ➥ node -v
    v0.10.28
    (env) ➥ nodeenv -p --node=system
     * Appending nodeenv settings to ~/tmp/nodeenv-test/env/bin/node
     * Appending nodeenv settings to ~/tmp/nodeenv-test/env/bin/activate

    I don't see any errors. Can you provide more details?

  4. neverfox commented on May 25, 2014

    @neverfox

    @ekalinin I'm using virtualenvwrapper. Here's what I get:

    ~ » node -v
    v0.10.28
    
    ~ » mkvirtualenv my_env
    Using base prefix '/usr'
    New python executable in my_env/bin/python3
    Also creating executable in my_env/bin/python
    Installing setuptools, pip...done.
    
    (my_env)
    ~ » easy_install nodeenv
    Searching for nodeenv
    Reading https://pypi.python.org/simple/nodeenv/
    Best match: nodeenv 0.9.2
    Downloading https://pypi.python.org/packages/source/n/nodeenv/nodeenv-0.9.2.tar.gz#md5=e7f387b409efde9e4dcdc59575926f16
    Processing nodeenv-0.9.2.tar.gz
    Writing /tmp/easy_install-cvkn45ue/nodeenv-0.9.2/setup.cfg
    Running nodeenv-0.9.2/setup.py -q bdist_egg --dist-dir /tmp/easy_install-cvkn45ue/nodeenv-0.9.2/egg-dist-tmp-oj7kvf4s
    warning: no previously-included files found matching '*.pyc'
    warning: no previously-included files found matching '*.swp'
    Adding nodeenv 0.9.2 to easy-install.pth file
    Installing nodeenv script to /home/neverfox/.virtualenvs/my_env/bin
    
    Installed /home/neverfox/.virtualenvs/my_env/lib/python3.4/site-packages/nodeenv-0.9.2-py3.4.egg
    Processing dependencies for nodeenv
    Finished processing dependencies for nodeenv
    
    (my_env)
    ~ » nodeenv --version
    0.9.2
    
    (my_env)
    ~ » nodeenv -p --prebuilt
     * Install node.js (0.10.28) ... done.
     * Appending nodeenv settings to /home/neverfox/.virtualenvs/my_env/bin/activate
    
    (my_env)
    ~ » nodeenv -p --node=system
    b'/home/neverfox/.virtualenvs/my_env/bin/node'
    Traceback (most recent call last):
      File "/home/neverfox/.virtualenvs/my_env/bin/nodeenv", line 9, in <module>
        load_entry_point('nodeenv==0.9.2', 'console_scripts', 'nodeenv')()
      File "/home/neverfox/.virtualenvs/my_env/lib/python3.4/site-packages/nodeenv-0.9.2-py3.4.egg/nodeenv.py", line 634, in main
        create_environment(env_dir, opt)
      File "/home/neverfox/.virtualenvs/my_env/lib/python3.4/site-packages/nodeenv-0.9.2-py3.4.egg/nodeenv.py", line 562, in create_environment
        install_activate(env_dir, opt)
      File "/home/neverfox/.virtualenvs/my_env/lib/python3.4/site-packages/nodeenv-0.9.2-py3.4.egg/nodeenv.py", line 535, in install_activate
        content = content.replace('__SHIM_NODE__', shim_node)
    TypeError: Can't convert 'bytes' object to str implicitly
  5. ekalinin commented on May 27, 2014

    @ekalinin
    Owner

    Now i see an error.
    It related only for python 3.4.
    Thanks for reporting!

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions