Skip to content

Installing into python venv overwrites VIRTUAL_ENV environment variable #243

Closed

Description

@karypid

Hello,

When I install nodeenv on my Windows 10 machine with Python 3.7.4 I get the following:

> python -m venv .venv
...
> .venv\Scripts\Activate.ps1
(.venv) > pip install nodeenv
... (installs version 1.3.3)
(.venv) > nodeenv -p
 * Install prebuilt node (13.1.0) ..... done.
 * Overwriting c:\users\u\ws\.venv\Scripts\activate.bat with new content
 * Overwriting c:\users\u\ws\.venv\Scripts\deactivate.bat with new content
 * Overwriting c:\users\u\ws\.venv\Scripts\Activate.ps1 with new content
You do not have sufficient privilege to perform this operation.
You do not have sufficient privilege to perform this operation.
Error: Failed to create nodejs.exe link
 * Install npm.js (latest) ...
(.venv) >

Why does nodenv overwrite the activate scripts removing the VIRTUAL_ENV environment variable? I see it sets the NODE_PATH and NODE_VIRTUAL_ENV environment variables (updating the PATH to include them). I feel that this is wrong. Other scripts may use VIRTUAL_ENV to determine the context they are running in and this breaks them.

Should it not APPEND to the existing activate script (i.e. add NODE_VIRTUAL_ENV/NODE_PATH leaving the rest alone) rather than overwrite it?

P.S. I see some errors regarding insuffucient privileges to perform some operation. Is that normal? Maybe the resulting activate scripts are like that due to the failing part of the setup?

Activity

  1. asottile commented on Dec 31, 2019

    @asottile
    Contributor

    appears to just be an oversight --

    nodeenv/nodeenv.py

    Lines 900 to 905 in e0914dd

    if opt.python_virtualenv:
    disable_prompt = DISABLE_PROMPT.get(name, '')
    enable_prompt = ENABLE_PROMPT.get(name, '')
    content = disable_prompt + content + enable_prompt
    need_append = bool(disable_prompt)
    writefile(file_path, content, append=need_append)

    as for the permission errors, it's likely attempting to symlink (which is fine if it can't)

  2. ravigupta-design commented on Sep 18, 2020

    @ravigupta-design

    @karypid , I think what you need to do is after activating python venv and installing nodeenv, you need to create the nodeenv environment like this:
    $ nodeenv env
    where env is the name of the nodeenv environment and you can name it as per your wish.
    And, then activate it.
    You can find more information here: https://ekalinin.github.io/nodeenv/

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions