AlexanderAA / ledger_binaries_windows

Ledger (a powerful command-line accounting system) v2.6.1 and v3.1.x binaries for windows systems
https://www.ledger-cli.org
66 stars 10 forks source link

Error in path expansion #3

Open aresaguilar opened 8 years ago

aresaguilar commented 8 years ago

I have found the following bug in the 3.1.1 version:

When using a windows path, cygwin does not expand it properly, e.g.: > ledger -f "c:\Users\ares\ledger.dat" Gives the following error (note the incorrect path expansion): Error: Cannot read journal file "/cygdrive/c/Users/ares/c:/Users/ares/ledger.dat"

ngleb commented 8 years ago

You can add directory with ledger.exe to PATH and run it from directory with ledger.dat file, so your PATH="C:\Somwhere-with-ledger.exe\" in CMD you go to C:\Users\ares and run: ledger.exe -f ledger.dat

I use it inside Emacs (x64 edition from sourceforge), but it requires to manually modify all the commands and point ledger-report to binary PATH and remove %(ledger-file) expansion. It also somehow opens a file ledger.dat second time like it's inside cygwin in read-only mode (and prompts me to continue or not reading the file). It works though I also would like to find a better solution.

aresaguilar commented 8 years ago

I ended up compiling ledeger myself from cygwin as instructed here: https://github.com/ledger/ledger/wiki/Build-instructions-for-Cygwin

ngleb commented 8 years ago

So you don't have the same problem like the one you described and the path expansion works correct? Have you used the patch mentioned at the top of that manual?

aresaguilar commented 8 years ago

@ngleb Yes, everything works correct that way. I didn't see the patch so I had to do it myself, but I ended up doing the same as described in that patch.

AlexanderAA commented 8 years ago

@aresaguilar Do you think that binaries in this repository are still relevant? Maybe it makes sense to remove them and direct everyone to the build instructions link you posted. Also please feel free to share the updated version of ledger binaries.

aresaguilar commented 8 years ago

@ngleb @AlexanderAA I don't know why, but it has stopped working now. I've tried recompiling but it does not work. Now it expands the path even worse: > ledger -f "c:\Users\ares\ledger.dat" expands into Error: Cannot read journal file "/cygdrive/c/Users/ares/c:Usersaresledger.dat"

aresaguilar commented 8 years ago

I've been debugging ledger and there seems to be a problem with boost library. I've opened a bug http://bugs.ledger-cli.org/show_bug.cgi?id=1188

I know very little C++, so the only solution I've came from is to add a line in src/context.h:120, to go from:

#if BOOST_VERSION >= 104600 && BOOST_FILESYSTEM_VERSION >= 3
  filename = filesystem::absolute(filename, cwd);
#else

to

#if BOOST_VERSION >= 104600 && BOOST_FILESYSTEM_VERSION >= 3
  path fs2{filename.string().substr(18,filename.string().length())};
  filename = filesystem::absolute(fs2, cwd);
#else

I simply erase the "c:\Users\aaguilar\" from the path. Obviously it's probably the worst solution, but my knowledge of C++ does not allow me to do anymore.

Anyone can help with a better solution?

ngleb commented 8 years ago

@AlexanderAA I think that binaries is still useful, migh be useful to add some instructions/notes on how to use it properly.

justinjk007 commented 7 years ago

So what is the state of this, because I am getting this error now.

JaneSmith commented 7 years ago

Same issue here.

ngleb commented 7 years ago

This build was created using Cygwin which will always emulate UNIX/POSIX environment.

Probably the easiest way to solve the issue is by compiling ledger in MSYS2/MinGW environment. In this case it will be native Windows application, no MSYS2/MinGW will be required to run it. Ledger source code already has all necessary support (so no changes will be necessary).

I combined necessary steps to compile ledger which is very easy, but I will test it and update it soon to make sure everything works: https://gist.github.com/ngleb/944346a67960776371aab74149edf38c

I don't think sharing my binaries would be a good idea as it is totally unsafe.

gety9 commented 6 years ago

Having similar error.

When doing ctrlC ctrlO ctrlR in ledger mode it gives error: Error: Cannot not read journal file.