maxtaco / coffee-script

IcedCoffeeScript
http://maxtaco.github.com/coffee-script
MIT License
727 stars 58 forks source link

iced as run-time: wrong path to "iced-coffee-script" folder in Windows #139

Closed zolern closed 9 years ago

zolern commented 9 years ago

When icedcoffeescript file is started with iced very strange exception is raised:

somefile.iced:

for i in [0..10]
   await
      setTimeout defer(), 500
console.log "hello"

Started wih iced:

D:\Temp> iced somefile.iced

Error: Cannot find module 'C:Documents and SettingsZolernApplication Data
pm
ode_modulesiced-coffee-script'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (D:\Temp\somefile.iced:1:1)
at Object.<anonymous> (D:\Temp\somefile.iced:1:1)
at Module._compile (module.js:456:26)

Actually path to iced-coffee-script module is C:\Documents and Settings\Zolern\Application Data\npm\node_modules\iced-coffee-script. It seems that all backslashes are treated as escape symbols.

After some not so deep investigation I found where compiler add full path to iced-coffee-script module:

nodes.coffee, line 2685:

modname = if interp then pathmod.join(__dirname, "..", "..") else "iced-runtime"

Workaround: just replace backslashes in path to slashes:

modname = if interp then (pathmod.join(__dirname, "..", "..")).replace(/\\/g,"/") else "iced-runtime"
akshayakrsh commented 9 years ago

Any idea, if when this will reach the actual package? Maintaining this workaround is quite tedious!

zolern commented 9 years ago

It is easy to make pull request with this local workaround, but my concern is that it will be "patch over the patch", i.e. this problem may be needs deeper investigation. Yes, replacing slashes with backslashes solves the problem, but I am curious what and why actually "eats" slashes?

akshayakrsh commented 9 years ago

@maxtaco hey man, requesting you to kindly look into it. Thanks :)

maxtaco commented 9 years ago

I pushed a fix live in 1.8.0-b. I don't have access to a windows machine so let me know if this worked. If not, feel free to open the bug report.

You guys were exactly right about what the problem was. ICS was emitting code of the form:

iced = require 'C:\Documents And Settings\Joe\Foo'

When that is then evaled, the backslashes are dropped.

akshayakrsh commented 9 years ago

@maxtaco Please merge pr #141 (you'll still need to recompile the project)

maxtaco commented 9 years ago

I've pushed v1.8.0-c and confirmed that it works on Windows. There was a fix in the codebase for a similar problem (#84), so let's reuse that code rather (which escapes the '\' characters) rather than rewriting the path with / chars.

zolern commented 9 years ago

One confirm from me too: now 1.8.0-c works like a charm. Thank you and waiting for 1.8.0-c npm update...

maxtaco commented 9 years ago

npm is updated for me...

maxtaco commented 9 years ago
npm install -g iced-coffee-script
/Users/max/opt/bin/iced -> /Users/max/opt/lib/node_modules/iced-coffee-script/bin/coffee
/Users/max/opt/bin/icake -> /Users/max/opt/lib/node_modules/iced-coffee-script/bin/cake
iced-coffee-script@1.8.0-c /Users/max/opt/lib/node_modules/iced-coffee-script
zolern commented 9 years ago

Ops, my bad: I didn't check it, just saw that information about iced-coffee-script version at http://maxtaco.github.io/coffee-script still says "1.8.0-a". Sorry, and thanks again.

maxtaco commented 9 years ago

Yeah, that's a whole other can of worms. The brochure site is in major need of help.

zolern commented 9 years ago

Need volunteers? I can help with a pleasure: love so much iced-coffee...

maxtaco commented 9 years ago

Thank you Encho! Sure. The need is a creative one. The example app on there now is broken because Twitter closed their API. And @malgorithms was never a big fan of it. So in the next version of the brochure site, there should be a better (working) app that we can showcase ICS with. Just haven't figured out what the app is....