Hi all, I am getting a cypher error that I just cannot figure the problem with. I am using docker and neo4j 4.2.2. After spinning up the container I have a cypher script that needs to be run to seed some initial data (this I have done with tremendous help from Dominic Kumar in another thread).
The strange part about this error is that it did appear to work fine but now gives this starnge error.
Here is the detail, I am using this dockerfile
FROM neo4j:4.2.2
ENV NEO4J_HOME="/var/lib/neo4j"
ENV NEO4J_PASSWD=neo4j_dependency
ENV NEO4J_apoc_import_file_enabled=true
ENV APOC_VERSION=4.2.0.1
# SHould look at copying this from a shared resource folder
ADD https://github.com/neo4j-contrib/neo4j-apoc-procedures/releases/download/${APOC_VERSION}/apoc-${APOC_VERSION}-all.jar ${NEO4J_HOME}/plugins
# Copy over generated dependency graph json file from shared resource folder
COPY Dependencies_Tree_Full_UnSorted.json ${NEO4J_HOME}/import/
# copy over cypher script from shared resource folder
COPY data_loader.cypher ${NEO4J_HOME}/import/
# set initial-password to start loading the data
# sleep for 20 secs for neo4j to start without any overlapping
CMD bin/neo4j-admin set-initial-password ${NEO4J_PASSWD} && \
bin/neo4j start && sleep 20 && \
if [ -f "${NEO4J_HOME}/import/data_loader.cypher" ]; then \
echo "We should be executing the cypher now?" && \
cat ${NEO4J_HOME}/import/data_loader.cypher | NEO4J_USERNAME=neo4j NEO4J_PASSWORD=${NEO4J_PASSWD} bin/cypher-shell --fail-fast && rm ${NEO4J_HOME}/import/*; \
fi && tail -f /logs/neo4j.log
and in the dockerfile I execute the following cypher file
// load data from json file (without full path default location is /import)
call apoc.load.json("file:///Dependencies_Tree_Full_UnSorted.json") yield value
// merge loaded data into DB as nodes
merge (n:Node {nodeId: value.id}) on create set n.name = value.name
// using current data
with n, value
// unwind all of the node depends on nodes
unwind value.dependsOn as depOn
// merge loaded dependencies into DB as nodes
merge (e:Node {nodeId: depOn.id}) on create set e.name = depOn.name
// specify depends on relationship
merge (n)-[:Depends_On]-(e);
After building my image I then try to start the container and this is the output that I get
Changed password for user 'neo4j'.
Directories in use:
home: /var/lib/neo4j
config: /var/lib/neo4j/conf
logs: /logs
plugins: /var/lib/neo4j/plugins
import: /var/lib/neo4j/import
data: /var/lib/neo4j/data
certificates: /var/lib/neo4j/certificates
run: /var/lib/neo4j/run
Starting Neo4j.
Started neo4j (pid 248). It is available at http://localhost:7474/
There may be a short delay until the server is ready.
See /logs/neo4j.log for current status.
starting data load ...
Invalid input '': expected
"RETURN"
"CREATE"
"DELETE"
"SET"
"REMOVE"
"DETACH"
"MATCH"
"WITH"
"UNWIND"
"USE"
"CALL"
"LOAD"
"FROM"
"FOREACH"
"MERGE"
"OPTIONAL"
"USING" (line 1, column 1 (offset: 0))
"CALL apoc.load.json("file:///Dependencies_Tree_Full_UnSorted.json") yield value"
^
The error 'Invalid input' doesnt make sense to me and I cannot see what is wrong in my cypher file. I have copied and pasted the same cypher into a running neo4j docker container and it executes without issue.
The exact same code also works fine on another environment without any error but just this one environment is producing this error. I have tried googling but have found nothing yet that can explain what is wrong? Can anybody help?
And that is what makes it s strange. I have run the exact same code on another dev machine also and it worked as expected. I try creating the cypher script file from scratch again and type it all out again and see what happens.
Well it looks as if you are correct again, I have totally rewritten the cypher from scratch and the error has gone away so it must have been some spaces or hidden characters. Yet again i thank you for your kind help.
Hi @andy_mcshane , glad it worked. I always check-in the working code to GitHub and pull in any environments, that way its always the same with versioning. (sometimes i use it along with travis-ci).