paulfitz / daff

align and compare tables
https://paulfitz.github.io/daff
MIT License
793 stars 67 forks source link

Compiling from sources #60

Open davidedelvento opened 8 years ago

davidedelvento commented 8 years ago

Related with issue #59 I'm trying to build daff. I installed binaries for haxe v3.2.1 from their website since my distro (mint) provided something that did not work because apparently was too old (v3.0.0)

I tried to run make and got the following:

#######################################################
## Set up directories
mkdir -p bin
mkdir -p lib
#######################################################
## Generate javascript
haxe language/js.hxml # produces lib/daff.js
#######################################################
## Make library version
cat env/js/fix_exports.js >> lib/daff.js
cat env/js/table_view.js >> lib/daff.js
cat env/js/ndjson_table_view.js >> lib/daff.js
cat env/js/sqlite_database.js >> lib/daff.js
cat env/js/util.js >> lib/daff.js
#######################################################
## Make executable version (just add shebang)
echo "#!/usr/bin/env node" > bin/daff.js
cat lib/daff.js >> bin/daff.js
chmod u+x bin/daff.js
#######################################################
## Check size
 10561  31095 260971 bin/daff.js
./scripts/run_tests.sh
=======================================================
== test_3way_alignment.js
make: *** [test] Error 1

For my particular purposes (using daff just as CLI diff, not as a library) I think I need the cpp target, so I tried make cpp and got:

haxe language/cpp.hxml
/bin/sh: 1: haxelib: not found
End_of_file
make: *** [cpp] Error 1

Note that I also had downloaded hxcpp v3.2.102 and tried to build per their instructions but at the second haxe compile.hxml I've got Error: /bin/sh: 1: haxelib: not found

So I tried to figure out what this haxelib was and how to install it, with mixed success, because everybody who is installing it is doing what daff is doing in its travis file namely using haxelib to install haxelib (line 23) and I have a bootstrap issue. Before chasing the rabbit in the rabbit hole, I'd like to:

paulfitz commented 8 years ago

When you ran make, I believe this line:

haxe language/js.hxml # produces lib/daff.js

did actually compile daff (haxe compilation is ridiculously fast, which can be misleading). If you have node installed, you can do:

nodejs lib/daff.js

and you should see the regular CLI output of daff. The failure of the default tests to run suggests you may not have nodejs.

From what you've said so far, I don't think you need the cpp build, in which case you won't need haxelib or hxcpp. (But I'm surprised you didn't receive haxelib along with haxe when you downloaded haxe, they should have been two binaries side-by-side).

I hear you on the need for clearer instructions. Will work on that. Thanks for trying!

davidedelvento commented 8 years ago

Ok, so that clarifies everything and I know now how to proceed. However, let me be clear with what I had to do, for others possibly finding this issue and figuring out how to solve their problems.

I do have nodejs correctly installed, but there is a name clash with an Amateur Radio thing called ax25-node which is aliased node, so my Linux Mint has no node command to mean nodejs, see http://stackoverflow.com/questions/21168141/cannot-install-packages-using-node-package-manager-in-ubuntu/21168305#21168305 for details. However, instead of messing up with my OS, I think it's nicer to change ./scripts/run_tests.sh to use nodejs instead of node, if that makes any sense. I tried both approaches (changing the script and creating a syslink called node) with the same result, in that everything worked fine, but test_file_types.js failed as described below. So here are some sub-issues:

1) maybe ./scripts/run_tests.sh needs to use nodejs instead of node? someone on stackoverflow seems to imply that it's not totally compatible, so I am not sure that's appropriate, but it seemed to work equally for me it'd be certainly more compatible with Debian and derivative.

2) I think that the three cases in run_tests.sh should simply be three different makefile targets, and I will be happy to make that change in a separate branch for you if you agree with that (this is actually not an issue per se, just would have made the discovery of the ax25-node problem easier)

3) As I said the test_file_types.js seems to be broken and fails with

== test_file_types.js

module.js:340
    throw err;
          ^
Error: Cannot find module 'tmp'
    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> (/home/ddvento/github/daff/test/test_file_types.js:2:11)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)

It seems to be many people affected by this issue for different nodejs libraries, e.g. http://stackoverflow.com/questions/25473573/grunt-fails-cannot-find-module-tmp and https://github.com/bower/bower/issues/1003 -- however I don't understand nodejs enough to debug it (this is the first time I use nodejs). For the time being, I just changed the extension of test_file_types.js so that it is not picked by the run_test.sh script and everything worked fine, but you may want to check this.

So in conclusion, as far as I am concerned this issue can be closed, but there are these 3 related issues which I will be happy to open as separate ones (and possibly also send a PR for 1 and 2) if you deem it appropriate. Thanks!

paulfitz commented 8 years ago

For 1) totally fine to use nodejs name if it is more portable. For 2) splitting those cases up also sounds like a good idea.

For 3) working around this seems a reasonable thing for you to do. Just for reference: I believe doing npm install in the repo directory would install the tmp module (it is listed in devDependencies in package.json) - but that test isn't relevant to the stuff you are interested in in any case. There are another batch of tests lurking in the make ntest_js target that would need all the dependencies installed. The reason there's a second batch of tests is that I realized writing tests in each individual language was going to be a pain so I switched to writing them in haxe half way through. It proved a little complicated so I'd suggest you not worry about it at this point if writing tests in python or javascript feels more straightforward to you.

Leaving this open since there's clearly a lot to document and clean up :-) but welcome focussed contributions as separate PRs.

Admiring your persistence :-)

davidedelvento commented 8 years ago

1) I sent a pull request, but looks like setting up the travis env is trickier than I thought (despite being similar to my local laptop). Do what you think is best in that regard.

2) I sent a separate pull request, hopefully that's a no-brainer to accept

3) silly me! In fact I had done that for fibers, sqlite3 and probably more, but did not realize that was a "real" dependency.

For the persistence, your project wasn't too bad for a newbie. It could and should be better, since it was not a walk in the park for the faint of heart either, but really, it wasn't too bad. You should see what I have to deal for work :-)