Skip to content
This repository has been archived by the owner on Jan 4, 2024. It is now read-only.

Doesn't work on Windows #6

Open
anyong opened this issue May 9, 2015 · 7 comments
Open

Doesn't work on Windows #6

anyong opened this issue May 9, 2015 · 7 comments

Comments

@anyong
Copy link

anyong commented May 9, 2015

Just following the quick start and immediately run into this error:

>>> settings.configure(USE_MANAGER=True)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python34\lib\site-packages\js_host\conf.py", line 55, in configure
    from .host import host
  File "C:\Python34\lib\site-packages\js_host\host.py", line 8, in <module>
    manager = JSHostManager()
  File "C:\Python34\lib\site-packages\js_host\base_server.py", line 70, in __init__
    self.validate_status()
  File "C:\Python34\lib\site-packages\js_host\base_server.py", line 214, in validate_status
    version = self.get_version().split('.')
  File "C:\Python34\lib\site-packages\js_host\base_server.py", line 117, in get_version
    return self.get_status()['version']
  File "C:\Python34\lib\site-packages\js_host\base_server.py", line 113, in get_status
    self.status = self.read_config_file(self.get_path_to_config_file())
  File "C:\Python34\lib\site-packages\js_host\base_server.py", line 104, in read_config_file
    raise ConfigError(stderr)
js_host.exceptions.ConfigError: b'C:\\dev\\project\\static\\node_modules\\.bin\\js-host:2\r\nbasedir=`dirname "$0"`\r\n        ^\r\nSyntaxError: Unexpected token ILLEGAL\r\n    at exports.runInThisContext (vm.js:73:16)\r\n    at Module._compile (module.js:443:25)\r\n    at Object.Module._extensions..js (module.js:478:10)\r\n    at Module.load (module.js:355:32)\r\n    at Function.Module._load (module.js:310:12)\r\n    at Function.Module.runMain (module.js:501:10)\r\n    at startup (node.js:129:16)\r\n    at node.js:814:3\r\n'

Edit:

Seems to be unrelated to the above error... js-host should run the .cmd file on Windows, not the bin/sh file. If I just run ./js-host.cmd from the command line:

$ ./node_modules/.bin/js-host.cmd ./host.config.js  --manager
Manager listening at 127.0.0.1:9009

Here's how I fixed the python code to make this work:

base_server.py
96: (self.get_path_to_bin(), config_file, '--config',) + self.read_config_file_params,
108: (deleted - stdout.read() is already a string)

conf.py
24: BIN_PATH = os.path.join('node_modules', '.bin', 'js-host.cmd')

Then when I run django python manage.py runserver my js-host server spins up in the console as expected:

$ ./node_modules/.bin/js-host.cmd ./host.config.js  --manager
Manager listening at 127.0.0.1:9009
2015-05-09T18:57:16.281Z - info: GET /status
2015-05-09T18:57:16.332Z - info: GET /status
2015-05-09T18:57:16.368Z - info: GET /status
2015-05-09T18:57:16.404Z - info: POST /host/status
2015-05-09T18:57:17.328Z - info: GET /status
2015-05-09T18:57:17.366Z - info: POST /host/status
2015-05-09T18:57:17.401Z - info: POST /host/start
2015-05-09T18:57:17.403Z - info: Starting child host with config: C:\dev\project\static\host.config.js
2015-05-09T18:57:18.293Z - info: POST /host/connect
2015-05-09T18:57:18.296Z - info: Connection 1431197838295-66abca40-ebe7-46d3-ae91-d37587626412 opened to host with config C:\dev\project\static\host.config.js
2015-05-09T18:57:23.765Z - info: GET /status
2015-05-09T18:57:23.805Z - info: GET /status
2015-05-09T18:57:23.842Z - info: GET /status
2015-05-09T18:57:23.877Z - info: POST /host/status
2015-05-09T18:57:23.955Z - info: POST /host/connect
2015-05-09T18:57:23.956Z - info: Connection 1431197843956-4a681948-308f-4fd3-bfe2-fb197e8d1f67 opened to host with config C:\dev\project\static\host.config.js

But I'm no expert so I've no idea how to make this compatible with Windows without breaking the existing stuff as I've clearly done here. Anyway, I'm using this for now until a fix comes out. Cheers!

@anyong anyong changed the title Windows line feeds? Doesn't work on Windows May 9, 2015
@markfinger
Copy link
Owner

I suppose we could detect windows and append .cmd to the BIN

@anyong
Copy link
Author

anyong commented May 10, 2015

Ok, it seems like there is more to the story here... base_server.py line 96 originally had self.path_to_node as an argument, and I had to remove that to get js_host working with the path .bin/js-host.cmd business. That was because if i ran node path/to/node_modules/.bin/js-host.cmd I would get all kinds of errors. Actually if it's running from node, it should just run node path/to/node_modules/js-host/bin/js-host.js. The first way, I had to manually start the js-host command from the CLI, and the second way, django automatically spins up the js-host server when I run python manage.py runserver - that's much better.

I'm determined to get this stuff working on my Windows machine! If you want to include any of these fixes in the packages directly I'm happy to test them out. Thanks.

@markfinger
Copy link
Owner

Well, I've managed to get the js-host test suite running under windows, so I'll take a stab at this

@markfinger
Copy link
Owner

It's working on an old XP box now, but I suspect that there will be more issues with later versions & powershell, so I'll keep testing

@markfinger
Copy link
Owner

@anyong

What version of windows are you running?
What's the usual terminal/shell used for windows development these days? Powershell?

@anyong
Copy link
Author

anyong commented May 10, 2015

I use 8.1 with cygwin / bash, but I tried with regular old cmd.exe too and
got the same results.

On Sun, May 10, 2015 at 9:02 PM, Mark Finger [email protected]
wrote:

@anyong https://github.com/anyong

What version of windows are you running?
What's the usual terminal/shell used for windows development these days?
Powershell?

Reply to this email directly or view it on GitHub
#6 (comment)
.

@markfinger
Copy link
Owner

Thanks. I'll grab a vm and give it a whirl

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants