Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in path expansion #3

Open
aresaguilar opened this issue Sep 26, 2016 · 12 comments
Open

Error in path expansion #3

aresaguilar opened this issue Sep 26, 2016 · 12 comments

Comments

@aresaguilar
Copy link

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
Copy link

ngleb commented Oct 1, 2016

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
Copy link
Author

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

@ngleb
Copy link

ngleb commented Oct 4, 2016

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
Copy link
Author

@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
Copy link
Owner

@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
Copy link
Author

@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
Copy link
Author

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
Copy link

ngleb commented Oct 8, 2016

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

@justinjk007
Copy link

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

@JaneSmith
Copy link

Same issue here.

@ngleb
Copy link

ngleb commented Sep 19, 2017

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
Copy link

gety9 commented Apr 8, 2018

Having similar error.

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

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

No branches or pull requests

6 participants