torch/trepl

Command history problem

skaae opened this issue · 11 comments

launching the REPL with th the i cannot move the curser and the command history is not working

Pressing the arrows results in : ^[[A^[[D^[[C^[[B^[[D^[[C^[[B

the luajit REPL works fine.

I installed the torch7 following the instructions on https://github.com/torch/torch7/wiki/Cheatsheet

I'm on OSx 10.7.5 with danish keyboard.
(i tried swithing to U.S International PC keyboard, but that did not solve the problem)

looks like this is a readline version problem: (http://stackoverflow.com/questions/1087975/ipython-os-x-up-arrow-gives-a)

it's possible that the wrong version of readline is being loaded via FFI in trepl

Can you give me the output for:
brew which readline

and also for:
brew unlink readline && brew link readline --force

then, output for:
echo $PATH
echo $DYLD_LIBRARY_PATH

Thanks

brew which readline
readline: 6.3.6

brew unlink readline && brew link readline --force:

Unlinking /usr/local/Cellar/readline/6.3.6... 0 symlinks removed
Linking /usr/local/Cellar/readline/6.3.6...
Error: Could not symlink share/info/rluserman.info
/usr/local/share/info is not writable.

echo $PATH:
/Users/sorensonderby/.rbenv/shims:/Users/sorensonderby/.rbenv/bin:/opt/local/bin:/opt/local/sbin:/Users/sorensonderby/Library/Enthought/Canopy_64bit/User/bin:/Users/sorensonderby/Library/Enthought/Canopy_64bit/User/bin:/Users/sorensonderby/.cljr/bin:/Users/sorensonderby/Documents/pylearn2/pylearn2/scripts:/Applications/MATLAB_R2013b.app/bin:/Applications/sbt/bin:/Users/sorensonderby/Documents/scala-2.9.2/bin/:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/local/ncbi/blast/bin:/usr/texbin

echo $DYLD_LIBRARY_PATH returns empty

right, so that looks like the problem right there.
Readline is not getting linked properly into /usr/local/lib, so the OSX shipped readline is being loaded by trepl (and it is really old and incompatible).

For you to solve this, you might want to make /usr/local/share/info writeable (not sure why it isn't, it should be in OSX), and then redo "brew link readline --force" until it comes out without error.

I think i created the symlink i.e:
brew unlink readline && brew link readline --force
Unlinking /usr/local/Cellar/readline/6.3.6... 0 symlinks removed
Linking /usr/local/Cellar/readline/6.3.6... 18 symlinks created

But still no history.
I just noticed that i get a warning when i start the th repl:

WARNING: could not find/load readline, defaulting to linenoise
WARNING: could not find/load linenoise, defaulting to raw repl

The warning is still present after i created the symlink

ugh, now it cant find readline at all, that's even more weird. as always, i suggest that you remove readline once and install again (brew remove readline && brew cleanup && brew install readline)

I think it was like that before as well :) i just didnt read the warning. But still no luck.

Running brew remove readline && brew cleanup && brew install readline gives the following warning:

==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/readline-6.3.6.lion.bottle.tar.gz
Already downloaded: /Library/Caches/Homebrew/readline-6.3.6.lion.bottle.tar.gz
==> Pouring readline-6.3.6.lion.bottle.tar.gz
==> Caveats
This formula is keg-only, so it was not symlinked into /usr/local.

OS X provides the BSD libedit library, which shadows libreadline.
In order to prevent conflicts when programs look for libreadline we are
defaulting this GNU Readline installation to keg-only.

Generally there are no consequences of this for you. If you build your
own software and it requires this formula, you'll need to add to your
build variables:

    LDFLAGS:  -L/usr/local/opt/readline/lib
    CPPFLAGS: -I/usr/local/opt/readline/include

note: from trepl, deadline is loaded dynamically (via ffi), there's no
compilation/detection at install time.

On Mon, Aug 11, 2014 at 9:05 AM, Soumith Chintala notifications@github.com
wrote:

ugh, now it cant find readline at all, that's even more weird. as always,
i suggest that you remove readline once and install again (brew remove
readline && brew cleanup && brew install readline)


Reply to this email directly or view it on GitHub
#4 (comment).

great now that you reinstalled readline, link it with "brew link readline --force"
fingers crossed, now trepl will load it.

if this also doesn't work, last resort is to specify a DYLD_LIBRARY_PATH in your .profile

export DYLD_LIBRARY_PATH=/usr/local/lib:$DYLD_LIBRARY_PATH

Yes!

Your last suggestion did the trick.

(btw thanks for supporting me on 3 issues simultaneously!)

I had the same issue on OS X 10.9.5. I also ended up having to set the DYLD_LIBRARY_PATH environment variable. Seems to work now. Thanks!