Fable: Unable to compile simple fsx with Fable on macOS

Created on 25 Feb 2017  ·  10Comments  ·  Source: fable-compiler/Fable

I'm unable to compile simple fsx with Fable on macOS

I'm running node 5.0 and F# 4.1

As getting started suggests I started by installing fable...

npm install -g fable-compiler

Created a main.fsx with the following contents

let zzz = "Hello world"
printfn "%s " zzz 

Attempted to compile
fable main.fsx

Expected main.js to have been built but got error env: node\r: No such file or directory

Googling the error suggests problem with line endings but main.fsx was created on macOS in vs code and bottom right of vs code windows displays LF indicating unix line endings.

Re-creating the same main.fsx file on windows and running fable main.fsx works perfectly.

All 10 comments

I don't really know much of node, but I ran some minutes ago into similar problems. The error message comes from a file containing Windows line breaks (\r\n) so that the line

#!/usr/bin/env node\r\n

results in that error.

I was using fable not with -g but as a development dependency, and call it via npm run build.

 "scripts": {"build": "fable"}

I suspect the error may come from fable 07.44

> npm list --depth 0                                                                          old [32a3a87]
[email protected] /Users/fb/Dropbox/kata/f#/fable-hello
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected]


> npm run build                                                                               old [32a3a87]

> [email protected] build /Users/fb/Dropbox/kata/f#/fable-hello
> fable

env: node\r: No such file or directory

npm ERR! Darwin 16.4.0
npm ERR! argv "/usr/local/Cellar/node/7.6.0/bin/node" "/usr/local/bin/npm" "run" "build"
npm ERR! node v7.6.0
npm ERR! npm  v4.1.2
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! [email protected] build: `fable`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the [email protected] build script 'fable'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the fable-hello package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     fable
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs fable-hello
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls fable-hello
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/fb/Dropbox/kata/f#/fable-hello/npm-debug.log

after downgrading to 0.7.43

> npm install [email protected]                                                 old [32a3a87] untracked
[email protected] /Users/fb/Dropbox/kata/f#/fable-hello
└── [email protected]


> npm list --depth 0                                                                          old [32a3a87]
[email protected] /Users/fb/Dropbox/kata/f#/fable-hello
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected]

it is working

> npm run build                                                                               old [32a3a87]

> [email protected] build /Users/fb/Dropbox/kata/f#/fable-hello
> fable

fable-compiler 0.7.43: Start compilation...
/Users/fb/Dropbox/kata/f#/fable-hello> npm install
Compiled code.js at 10:08:43 PM
/Users/fb/Dropbox/kata/f#/fable-hello> webpack
Hash: 823d3e82598dd9a2c135
Version: webpack 2.2.1
Time: 996ms
        Asset    Size  Chunks             Chunk Names
    bundle.js  234 kB       0  [emitted]  main
bundle.js.map  313 kB       0  [emitted]  main
  [13] ./~/core-js/modules/_core.js 117 bytes {0} [built]
  [48] ./~/core-js/modules/core.get-iterator-method.js 293 bytes {0} [built]
 [114] ./~/core-js/modules/core.is-iterable.js 317 bytes {0} [built]
 [119] ./~/core-js/index.js 639 bytes {0} [built]
 [124] ./~/core-js/modules/core.delay.js 403 bytes {0} [built]
 [125] ./~/core-js/modules/core.dict.js 4.51 kB {0} [built]
 [126] ./~/core-js/modules/core.function.part.js 206 bytes {0} [built]
 [128] ./~/core-js/modules/core.number.iterator.js 238 bytes {0} [built]
 [129] ./~/core-js/modules/core.object.classof.js 112 bytes {0} [built]
 [130] ./~/core-js/modules/core.object.define.js 138 bytes {0} [built]
 [131] ./~/core-js/modules/core.object.is-object.js 115 bytes {0} [built]
 [132] ./~/core-js/modules/core.object.make.js 244 bytes {0} [built]
 [135] ./~/core-js/modules/core.string.unescape-html.js 308 bytes {0} [built]
 [306] ./~/core-js/shim.js 7.38 kB {0} [built]
 [307] ./temp/code.js 208 bytes {0} [built]
    + 293 hidden modules

@simax try npm install -g [email protected]

@fbehrens thank-you. That did the trick.

@alfonsogarciacaro please have a look at this issue.

Damn! This happens to me for releasing a version directly from my Windows machine and letting the OS sneak these \rs everywhere 😬 I've released a new version from the CI server as I used to do before. Can you please check if it works now?

Thanks a lot @fbehrens for pointing out the problem and sorry for the trouble!

works for me with [email protected]. I believe you can prevent your future self from that happening with editorconfig, und the matching editor plugin.

@fbehrens Thanks for the confirmation! You're very right that I should make the life of my future self easier. Actually, if it weren't for you, I would have spent a lot of time before remembering the issue with the line breaks. I'll set the option in my editor, however I think the problem occurs when copying the file to the build folder (as I haven't touched index.js in months), which is something I don't fully understand because I'm using the same FAKE script in my Windows machine and AppVeyor.

Thanks @alfonsogarciacaro that's working now. Thanks for the quick response.

I think I've found the problem, I left the default git option in Windows to check out with Windows-style line breaks so probably the \r characters got inserted when I cloned the project in that machine.

so on your windows machine you had core.autocrlf true and will set it to false.
Then you have to take care that your windows editors use LF ending.
If you like to test this setup i'm available for testing within the next hour.

Thanks @fbehrens! Sorry, I was away today but I think I got it working thanks to your help 😄 I'll ask you if I find another problem.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

alfonsogarciacaro picture alfonsogarciacaro  ·  35Comments

sergey-tihon picture sergey-tihon  ·  70Comments

et1975 picture et1975  ·  25Comments

alfonsogarciacaro picture alfonsogarciacaro  ·  26Comments

sandeepc24 picture sandeepc24  ·  46Comments