Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Freeze returns empty and error when trying to create env from file #121

Closed
connienguyen opened this issue May 8, 2015 · 4 comments
Closed

Comments

@connienguyen
Copy link

I am having some issues using freeze to keep a current list of installed modules.

When I tried (env)(venv)$ freeze I got:

/var/www/mysite/nodejs
└──

I tried testing freeze -l bloop.txt and I got:

-bash: [: -l: binary operator expected
-bash: $@: ambiguous redirect

I installed the npm modules using the -g flag.

I'm also having a problem trying to create a new nodeenv on a different machine from a requirements.txt that I wrote following the example in the README.

(venv)$ nodeenv --requirements=requirements.txt --jobs=4 env
 * Install node (0.12.2)..Traceback (most recent call last):
  File "/var/www/mysite/venv/bin/nodeenv", line 9, in <module>
    load_entry_point('nodeenv==0.13.1', 'console_scripts', 'nodeenv')()
  File "/var/www/mysite/venv/local/lib/python2.7/site-packages/nodeenv.py", line 855, in main
    create_environment(env_dir, opt)
  File "/var/www/mysite/venv/local/lib/python2.7/site-packages/nodeenv.py", line 698, in create_environment
    install_node(env_dir, src_dir, opt)
  File "/var/www/mysite/venv/local/lib/python2.7/site-packages/nodeenv.py", line 576, in install_node
    build_node_from_src(env_dir, src_dir, node_src_dir, opt)
  File "/var/www/mysite/venv/local/lib/python2.7/site-packages/nodeenv.py", line 545, in build_node_from_src
    callit([make_cmd] + make_opts, opt.verbose, True, node_src_dir, env)
  File "/var/www/mysite/venv/local/lib/python2.7/site-packages/nodeenv.py", line 436, in callit
    % (cmd_desc, proc.returncode))
OSError: Command make --jobs=4 failed with error code 2

My requirements.txt file looks like this:

express@4.12.3
npm@2.7.4
redis@0.12.1
socket.io@1.3.5

I am using nodeenv 0.13.1.

Any help on these issues would be appreciated. Thanks!

Note: (env) is my nodeenv environment and (venv) is my python virtual environment.

@ekalinin
Copy link
Owner

Hi @connienguyen

Thanks for report.

Just repeat first issue:

➥ cd ~/tmp/ && mkdir nodeenv-test && cd nodeenv-test
➥ virtualenv env
Running virtualenv with interpreter /usr/bin/python2
New python executable in env/bin/python2
Also creating executable in env/bin/python
Installing setuptools, pip...done.
➥ . env/bin/activate
➥ pip install nodeenv
➥ nodeenv -p --prebuilt
 * Install node (0.12.2)... done.
 * Appending data to ~/tmp/nodeenv-test/env/bin/activate
➥ npm -g install express@4.12.3
express@4.12.3 ~/tmp/nodeenv-test/env/lib/node_modules/express
➥ freeze
freeze: command not found
➥ deactivate 
➥ . env/bin/activate
➥ freeze
~/tmp/nodeenv-test
└──
➥ freeze -l | wc -l
0

The problem is in this condition:

In this condition it was assumed that there are only 2 major versions of the npm: 0.*, 1.*.

@ekalinin
Copy link
Owner

About re-creation environment from requirements.txt.
I just tested this feature and seems it works:

➥ cat requirements.txt 
express@4.12.3
redis@0.12.1
socket.io@1.3.5
➥ virtualenv env
➥ . env/bin/activate
➥ pip install nodeenv
➥ nodeenv --requirements=requirements.txt --jobs=4 --prebuilt env-copy
 * Install node (0.12.2)... done.
 * Install node.js packages ... done.
➥ . env-copy/bin/activate 
➥ freeze
express@4.12.3
redis@0.12.1
socket.io@1.3.5

Can you provide more details?
Or create a new issue with new details?

@connienguyen
Copy link
Author

Hi @ekalinin ,

Thanks for helping me out. I have upgraded nodeenv from 0.13.1 to 0.13.2 and freeze seems to be working perfectly now.

Regarding the second issue, I haven't gotten the same issue again and am able to recreate an environment. I have a question though. I develop on a local machine and deploy on a remote server. In nodeenv, am I able to update my virtual environment requirements installations from file similar to the python virtualenv where I can run pip install -r requirements.txt? Would I have to recreate an environment each time I make a change to requirements.txt or manually install each one?

Also, I would like to note that there was an issue when the requirements.txt file included a newline at the end.

Here are the errors that occur when a newline is included.

(venv)$ nodeenv --requirements=requirements.txt --jobs=4 --prebuilt env
 * Install node (0.12.2)... done.
 * Install node.js packages ... Traceback (most recent call last):
  File "/Users/hades/Documents/Repos/mysite/venv/bin/nodeenv", line 9, in <module>
    load_entry_point('nodeenv==0.13.2', 'console_scripts', 'nodeenv')()
  File "/Users/hades/Documents/Repos/mysite/venv/lib/python2.7/site-packages/nodeenv.py", line 855, in main
    create_environment(env_dir, opt)
  File "/Users/hades/Documents/Repos/mysite/venv/lib/python2.7/site-packages/nodeenv.py", line 710, in create_environment
    install_packages(env_dir, opt)
  File "/Users/hades/Documents/Repos/mysite/venv/lib/python2.7/site-packages/nodeenv.py", line 632, in install_packages
    cmd % {"pack": package}], show_stdout=opt.verbose, in_shell=True)
  File "/Users/hades/Documents/Repos/mysite/venv/lib/python2.7/site-packages/nodeenv.py", line 436, in callit
    % (cmd_desc, proc.returncode))
OSError: Command ". env/bin/activate && npm install -g " failed with error code 235

When this happens, it also creates an npm-debug.log file:

(venv)$ cat npm-debug
0 info it worked if it ends with ok
1 verbose cli [ 'node',
1 verbose cli   '/Users/hades/Documents/Repos/mysite/nodejs/env/bin/npm',
1 verbose cli   'install',
1 verbose cli   '-g' ]
2 info using npm@2.7.4
3 info using node@v0.12.2
4 silly cache add args [ '.', null ]
5 verbose cache add spec .
6 silly cache add parsed spec { raw: '.',
6 silly cache add   scope: null,
6 silly cache add   name: null,
6 silly cache add   rawSpec: '.',
6 silly cache add   spec: '/Users/hades/Documents/Repos/mysite/nodejs',
6 silly cache add   type: 'local' }
7 error addLocal Could not install /Users/hades/Documents/Repos/mysite/nodejs
8 verbose stack Error: EISDIR, read
8 verbose stack     at Error (native)
9 verbose cwd /Users/hades/Documents/Repos/mysite/nodejs
10 error Darwin 14.3.0
11 error argv "node" "/Users/hades/Documents/Repos/mysite/nodejs/env/bin/npm" "install" "-g"
12 error node v0.12.2
13 error npm  v2.7.4
14 error code EISDIR
15 error errno -21
16 error EISDIR, read
17 error If you need help, you may report this error at:
17 error     <https://github.com/npm/npm/issues>
18 verbose exit [ -21, true ]

@ekalinin
Copy link
Owner

Thanks for helping me out.

No problems :)

I have upgraded nodeenv from 0.13.1 to 0.13.2 and freeze seems to be working perfectly now.

Cool!

Regarding the second issue, I haven't gotten the same issue again and am able to recreate an environment.

Ok.

Would I have to recreate an environment each time I make a change to requirements.txt or manually install each one?

Seems, it much easier to install each one by npm.

Also, I would like to note that there was an issue when the requirements.txt file included a newline at the end. Here are the errors that occur when a newline is included.

Yes. It's a bug.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants