neo4jrb/neo4j-ruby-driver

NameError (uninitialized constant Neo4j)

mattes opened this issue · 3 comments

I added gem "neo4j-ruby-driver" to my Gemfile, installed seabolt as well, ran bundle install, but getting NameError (uninitialized constant Neo4j).

Ubuntu 18.04
Rails 6.1.2.1
ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-linux]

@mattes you would have to elaborate on this more or say what's specific in your environment. Maybe provide a mini rails app showing the error.

Thanks for your fast reply. Here is a Dockerfile which installs a fresh Rails 6.1.2.1 on Ruby 3.0.0 under Debian Buster.

# docker build -f rails-neo4j-debug .
FROM debian:10

RUN apt-get update && \
    DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
      build-essential \
      pkg-config \
      git \
      curl \
      ca-certificates \
      tzdata \
      libpq-dev \
      libsqlite3-dev \
      zlib1g-dev \
      libssl-dev \
      libreadline-dev

WORKDIR /tmp

# compile seabolt for debian
RUN curl -Ls https://cmake.org/files/v3.12/cmake-3.12.3-Linux-x86_64.tar.gz | tar xvz -C /usr/local/ --strip 1 &&\
    git clone --single-branch --branch v1.7.4 https://github.com/neo4j-drivers/seabolt.git /tmp/seabolt &&\
    cd /tmp/seabolt && cmake -D CMAKE_BUILD_TYPE=Release /tmp/seabolt && cmake --build . --target package && mv /tmp/seabolt/lib/* /usr/local/lib/

# Install node
ENV PATH /opt/node/bin:$PATH
RUN git clone https://github.com/nodenv/node-build.git /opt/node-build &&\
    /opt/node-build/bin/node-build 14.15.4 /opt/node &&\
    node --version &&\
    npm --version &&\
    npm install -g yarn &&\
    yarn --version &&\
    rm -r /opt/node-build

# Install ruby
ENV PATH /opt/ruby/bin:$PATH
RUN git clone https://github.com/rbenv/ruby-build.git /opt/ruby-build &&\
    /opt/ruby-build/bin/ruby-build 3.0.0 /opt/ruby &&\
    gem install bundler --no-document &&\
    ruby --version &&\
    rm -r /opt/ruby-build


# Create a fresh rails app
RUN gem install rails
RUN rails new app
WORKDIR /tmp/app

# Install neo4j-ruby-driver
RUN echo 'gem "neo4j-ruby-driver"' >> /tmp/app/Gemfile
RUN bundle install

# see if Neo4j was loaded:
RUN rails runner 'puts Neo4j::Driver::GraphDatabase.inspect'

Outputs:

uninitialized constant Neo4j

User error. I needed to manually require "neo4j/driver" in my Rails app.