NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.97k stars 13.98k forks source link

Neo4j error: compgen not found #130112

Closed xpe closed 11 months ago

xpe commented 3 years ago

Describe the bug

neo4j gives an error saying that compgen is not found.

To Reproduce

neo4j version (with a slight change to set JAVA_HOME correctly, see #130106) gives:

/nix/store/lrsrks8z0snvvbxqcb6avsvrqg001w01-neo4j-3.5.14/share/neo4j/bin/neo4j: line 308: compgen: command not found
neo4j 3.5.14

Expected behavior

The error should not occur.

Screenshots

Here is the relevant code triggering the error:

setup_arbiter_options() {
  is_arbiter() {
    compgen -G "${NEO4J_LIB}/neo4j-server-enterprise-*.jar" >/dev/null && \
      [[ "$(echo "${dbms_mode:-}" | tr [:lower:] [:upper:])" == "ARBITER" ]]
  }
  # ...
  # ...

Additional context

Via this IRC log:

10:01 <srhb> Hurr. Any psychic debuggers on the line? I'm trying to use optparse-applicatives bash completion with a shell hook, but I get "bash: compgen: command not found" when I use the action completer 
10:02 <srhb> I'm probably missing something obvious. 
10:07 <tilpner> srhb - Make sure to use bashInteractive, not bash 
10:08 <tilpner> Or bashCompletion/bash-completion maybe 
10:10 <srhb> tilpner: Isn't bashInteractive the default for nix-shell? 
10:10 <tilpner> srhb - I don't know 
10:10 <srhb> Hum... Not sure how to switch it anyway. 
10:11 <tilpner> But nis -p bash --run 'bash -c compgen' errors while nis -p bashInteractive --run 'bash -c compgen doesn't output anything 
10:11 <tilpner> I don't actually use bash, so I'm clueless too 
10:11 <srhb> tilpner: Got it. Thank you. 

Along these lines, another nix package (ccache) uses the following code to solve the problem, seems to me:

doCheck = true;
  checkInputs = [
    # test/run requires the compgen function which is available in
    # bashInteractive, but not bash.
    bashInteractive
  ] ++ lib.optional stdenv.isDarwin xcodebuild;

Source(s):

Public Mentions

Also mentioned on Reddit about two years ago:

The neo4j start script complains about not being able to find compgen. I’m not sure how important compgen is to the startup process, but I did some research and it’s part of the ImageMagick package. I installed ImageMagick and now have compgen, but the neoj4 start script still does not find it... This feels hopeless. I’ll just use the commercial desktop version.

... though I don't think a bug report was filed at that time (?).

Notify maintainers

Metadata Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

 - system: `"x86_64-darwin"`
 - host os: `Darwin 20.5.0, macOS 10.16`
 - multi-user?: `no`
 - sandbox: `no`
 - version: `nix-env (Nix) 2.3.12`
 - channels(xpe): `"nixpkgs-21.11pre294471.51bb9f3e9ab"`
 - nixpkgs: `/Users/xpe/.nix-defexpr/channels/nixpkgs`

Maintainer information:

# a list of nixpkgs attributes affected by the problem
attribute:
# a list of nixos modules affected by the problem
module: neo4j
roberth commented 3 years ago

cc @offlinehacker

DavidRConnell commented 3 years ago

I am running into the same error. Based on the provided suggestions, are we assuming builder needs to be set to "${bashInteractive}/bin/bash"? The manual states mkDerivation always uses bash (assumingly "${bash}/bin/bash") does this mean it needs to be rewritten using derivation instead of mkDerivation or is there a way to force mkDerivation to use the bashInteractive version of bash?

roberth commented 3 years ago

-enterprise- leads me to believe that it doesn't apply to the variant we're packaging. So patching out those lines may be an option.

rewritten using derivation instead of mkDerivation

stdenv does so much that I wouldn't want to forego it. It's easier to change the relevant bits to run in a bashInteractive subshell. Another option is to add to nativeBuildInputs a "wrapper" for compgen using bashInteractive in the shebang.

DavidRConnell commented 3 years ago

The pull request I submitted fixes the issue but I'm not sure if it's an acceptable solution as it should add that compgen wrapper to the global environment. Meaning it might mess with anything else that tries to call compgen. The problem is it seems like compgen is needed in the environment when calling neo4j. Should it maybe be put somewhere in ${neo4j}/share then added to the path in the makeWrapper call?

As for the enterprise part, @roberth may be right. I don't see any jar files in my ${neo4j}/share that match the glob there. If that's the only place calling compgen it looks safe to delete that line. Where is that code?

I'm also still having problems getting the server to start. Running neo4j console gives an error:

ERROR Failed to start Neo4j: Starting Neo4j failed: Component 'org.neo4j.server.database.LifecycleManagingDatabase@39529185' was successfully initialized, but failed to start. Please see the attached cause exception "/nix/store/zg9flxzh7g16g4frbxmy8x24grpx3d80-neo4j-3.5.14/share/neo4j/logs/debug.log (Read-only file system)"

Which I believe is due to it not being able to write the log files in /nix/store. Is there a way to handle log files in this scenerio or do we need to try to get neo4j to write them elsewhere?

DavidRConnell commented 3 years ago

I went ahead and moved where the compgen wrapper is so it's not in ${neo4j}/bin. I think that's clearly the better solution.

stale[bot] commented 2 years ago

I marked this as stale due to inactivity. → More info

Artturin commented 11 months ago

There's no longer a compgen call in share/neo4j/bin/neo4j or in any file