PrimalHQ / primal-caching-service

Primal’s caching service for Nostr connects to the specified set of relays, collects all events in real time, stores them locally, and makes them available to nostr clients through a web socket-based API.
https://primal.net
MIT License
86 stars 13 forks source link

Trouble building/running the caching service with nix #6

Closed erskingardner closed 1 year ago

erskingardner commented 1 year ago

Hey guys, I'm new to nix and thus unsure how to proceed here. I've installed nix on Ubuntu 22.04.2 LTS and cloned the repo. Then from the repo directory I'm running nix --extra-experimental-features 'nix-command flakes' develop -c sh -c '$start_primal_caching_service'

On the first run, it installed most of the dependencies but errored on installing HTTP. Following runs of the same command return the following:

gcc -shared -g -fPIC -O2 -o libbech32.so -Ibech32/ref/c bech32.c
bech32.c:5:10: fatal error: segwit_addr.c: No such file or directory
    5 | #include "segwit_addr.c"
      |          ^~~~~~~~~~~~~~~
compilation terminated.
make: *** [Makefile:2: libbech32.so] Error 1
  0 dependencies successfully precompiled in 0 seconds. 83 already precompiled.
  1 dependency errored. To see a full report either run `import Pkg; Pkg.precompile()` or load the package
  0 dependencies successfully precompiled in 0 seconds. 83 already precompiled.

ERROR: LoadError: The following 1 direct dependency failed to precompile:

HTTP [cd3eb016-35fb-5094-929b-558a96fad6f3]

Error: Missing source file for HTTP [cd3eb016-35fb-5094-929b-558a96fad6f3
Stacktrace:
 [1] pkgerror(msg::String)
   @ Pkg.Types /nix/store/i92h4wy9ay6iays1dsg99qsjsjybyli1-julia-bin-1.8.5/share/julia/stdlib/v1.8/Pkg/src/Types.jl:67
 [2] precompile(ctx::Pkg.Types.Context, pkgs::Vector{String}; internal_call::Bool, strict::Bool, warn_loaded::Bool, already_instantiated::Bool, kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
   @ Pkg.API /nix/store/i92h4wy9ay6iays1dsg99qsjsjybyli1-julia-bin-1.8.5/share/julia/stdlib/v1.8/Pkg/src/API.jl:1435
 [3] precompile
   @ /nix/store/i92h4wy9ay6iays1dsg99qsjsjybyli1-julia-bin-1.8.5/share/julia/stdlib/v1.8/Pkg/src/API.jl:1072 [inlined]
 [4] #precompile#225
   @ /nix/store/i92h4wy9ay6iays1dsg99qsjsjybyli1-julia-bin-1.8.5/share/julia/stdlib/v1.8/Pkg/src/API.jl:1071 [inlined]
 [5] precompile (repeats 2 times)
   @ /nix/store/i92h4wy9ay6iays1dsg99qsjsjybyli1-julia-bin-1.8.5/share/julia/stdlib/v1.8/Pkg/src/API.jl:1071 [inlined]
 [6] top-level scope
   @ ~/primal-caching-service/pkg.jl:1
in expression starting at /home/jg/primal-caching-service/pkg.jl:1
pritk commented 1 year ago

hi! don't forget to init git submodules after git clone:

git submodule update --init

or you can clone with --recursive flag in the first place:

git clone --recursive https://github.com/PrimalHQ/primal-caching-service

does it work after that?

erskingardner commented 1 year ago

Thanks @pritk – I had this comment written and forgot to submit...

I missed that there was a submodule in the repo so I tried to clone again with submodules and got the following permissions error...

git clone --recurse-submodules https://github.com/PrimalHQ/primal-caching-service.git
Cloning into 'primal-caching-service'...
remote: Enumerating objects: 139, done.
remote: Counting objects: 100% (27/27), done.
remote: Compressing objects: 100% (12/12), done.
remote: Total 139 (delta 16), reused 15 (delta 15), pack-reused 112
Receiving objects: 100% (139/139), 91.94 KiB | 1.96 MiB/s, done.
Resolving deltas: 100% (70/70), done.
Submodule 'bech32' (https://github.com/sipa/bech32) registered for path 'bech32'
Submodule 'dev/HTTP.jl' (git@github.com:PrimalHQ/HTTP.jl.git) registered for path 'dev/HTTP.jl'
Cloning into '/home/jg/primal-caching-service/bech32'...
remote: Enumerating objects: 340, done.
remote: Counting objects: 100% (72/72), done.
remote: Compressing objects: 100% (49/49), done.
remote: Total 340 (delta 25), reused 51 (delta 20), pack-reused 268
Receiving objects: 100% (340/340), 184.50 KiB | 2.75 MiB/s, done.
Resolving deltas: 100% (158/158), done.
Cloning into '/home/jg/primal-caching-service/dev/HTTP.jl'...
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
fatal: clone of 'git@github.com:PrimalHQ/HTTP.jl.git' into submodule path '/home/jg/primal-caching-service/dev/HTTP.jl' failed
Failed to clone 'dev/HTTP.jl'. Retry scheduled
Cloning into '/home/jg/primal-caching-service/dev/HTTP.jl'...
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
fatal: clone of 'git@github.com:PrimalHQ/HTTP.jl.git' into submodule path '/home/jg/primal-caching-service/dev/HTTP.jl' failed
Failed to clone 'dev/HTTP.jl' a second time, aborting
pritk commented 1 year ago

hi! git submodule url is fixed. can you try to run it again?

erskingardner commented 1 year ago

🎉 I was able to clone – going to try and build and see where we get. :)