Mark Needham

Thoughts on Software Development

Neo4j: The case of neo4j-shell and the invisible text ft. Windows and the neo4j-desktop

with 4 comments

I’ve been playing around with Neo4j on a Windows VM recently and I wanted to launch neo4j-shell to run a few queries.

The neo4j-shell script isn’t shipped with Neo4j desktop which I used to install Neo4j on my VM but we can still launch it from the Windows Command Prompt with the following command:

C:\Users\Mark> cd "C:\Program Files\Neo4j Community"
C:\Program Files\Neo4j Community>jre\bin\java -cp bin\neo4j-desktop-2.0.0-RC1.jar
Welcome to the Neo4j Shell! Enter 'help' for a list of commands
NOTE: Remote Neo4j graph database service 'shell' at port 1337
Want bash-like features? throw in jLine ( on the classpath

Unfortunately if we start typing in a query we don’t get any feedback as to what we’re typed, although if we type something syntactically valid and suffix it with a semi colon and press enter it will be evaluated!

e.g. this is the output from entering the following query

START n = node(*) RETURN COUNT(n);
2013 11 29 16 53 56

The reason for the problem is to do with the ‘.shell_history’ file that the shell tries to write to the directory it’s launched from. In this case we don’t have permission to write anything to ‘C:\Program Files\Neo4j Community’ and so we get no feedback.

To workaround this problem we need to start the command prompt as an administrator which we can do from the apps menu by right clicking the ‘Command Prompt’ icon:

2013 11 29 17 00 59

Next we click ‘Start as Administrator’ and click through the next screen:

2013 11 29 17 01 14

Now if we launch neo4j-shell and type in our query we get the expected feedback:

2013 11 29 17 04 26
Be Sociable, Share!

Written by Mark Needham

November 29th, 2013 at 5:08 pm

Posted in neo4j

Tagged with

  • jotomo

    Hm, starting as admin is kind of an ugly workaround, and will not work if the user has no admin rights. AFAIK the .shell_history file is createdy by JLine and should thus not be the problem as JLine init fails in your case. Except if JLine init only partially succeeded …

    Someone else ran into this permission problem (on UNIX). I’ve created an issue to move the file to ~/.neo4j_shell_history, which should work well on both UNIX and Windows, issue is here:

  • @jotomo:disqus yeh you’re right it is a bit ugly! I tried out what you said and the .shell_history file doesn’t get written to when I start up the shell without admin access.

    Your suggestion of writing to home.dir seems reasonable.

    I just wrote this up because a few Windows users have been seeing this problem and I wanted to be able to point them at a workaround.

  • timbrell

    Would it work to run the command from your home directory and specify the full path to java/the jar file? I don’t have a Windows machine handy to test it but I suspect something like the following might work:

    “C:Program FilesNeo4j Communityjrebinjava” -cp “C:Program FilesNeo4j Communitybinneo4j-desktop-2.0.0-RC1.jar”

    The only thing I think that might prevent it from working is if it searches for conf relative to the working directory rather than the jar location.

  • Sergei

    Is it possible to run the neo4j command line tools without administrator command prompt?