gRPC-haskell icon indicating copy to clipboard operation
gRPC-haskell copied to clipboard

how to run exe's / examples

Open sboosali opened this issue 7 years ago • 15 comments

stack exec -- echo-server

errors with

You cannot have packages and a shell-file filled at the same time in your nix-shell configuration.

ditto under nix-shell. afaict, release.nix doesn't accept input. ghc obviously doesn't work, because they need the appropriate environment.

i don't know how i should run the examples, so i'm gonna try them in a separate package.

i'm on:


$ stack --version
Version 1.3.2 x86_64

$ nixos-version 
17.03.873.0c041520c3 (Gorilla)


if relevant.

sboosali avatar Apr 30 '17 03:04 sboosali

@sboosali nix-shell release.nix -A grpc-haskell.env worked okay for me; I'm on NixOS 17.03:

$ nix-shell release.nix -A grpc-haskell.env
$ # Lots of build activity...
[nix-shell:]$ echo-server --help
Runs the echo service

Usage: echo-server [--bind TEXT] [--port INT]

Available options:
  -h,--help                Show this help text
  --bind TEXT              grpc endpoint hostname (default "localhost")
  --port INT               grpc endpoint port (default 50051)

@sboosali what is in the nix section of your global user-level stack config? I've run into issues by putting too much in the user-level global stack config myself on NixOS. This project's nix: section in the stack.yaml does do a few things that might be interacting with your own configuration.

ixmatus avatar Apr 30 '17 17:04 ixmatus

I did have trouble running stack build within the nix-shell environment though. I might spend some time today on ironing out why.

ixmatus avatar Apr 30 '17 17:04 ixmatus

Yeah, I would recommend the nix + cabal combination. See this tutorial which explains the idioms we use for building Haskell projects with Nix

Gabriella439 avatar Apr 30 '17 19:04 Gabriella439

@ixmatus

nix:
  enable: true
  pure: true
  packages:
  - zlib

extra-include-dirs:
  - /home/sboo/.nix-profile/include

extra-lib-dirs:
  - /home/sboo/.nix-profile/lib

i tried enable: false and pure: false` (in the global stack.yaml), with the same issues:

[nix-shell:~/gRPC-haskell]$ stack build
You cannot have packages and a shell-file filled at the same time in your nix-shell configuration.
[nix-shell:~/gRPC-haskell]$ echo-server --help
echo-server: command not found
[nix-shell:~/gRPC-haskell]$ stack exec -- echo-server --help
You cannot have packages and a shell-file filled at the same time in your nix-shell configuration.

i'll try cabal, thanks for the link!

sboosali avatar Apr 30 '17 19:04 sboosali

Boy that's weird. I get a no compiler found error and when I try to run stack setup I get another very arcane error (all from within the nix-shell environment) but I think following @Gabriel439's advice of using cabal makes sense to me.

What is strange though is that echo-server is not found on your path! Could you show the nix-shell invocation you're running?

ixmatus avatar Apr 30 '17 19:04 ixmatus

i tried cabal but got:

[nix-shell:~/gRPC-haskell]$ cabal configure --with-gcc=clang --enable-tests && cabal build && cabal test
Resolving dependencies...
Configuring grpc-haskell-0.0.0.0...
cabal: Missing dependency on a foreign library:
* Missing (or bad) header file: include/grpc_haskell.h
* Missing C library: grpc
This problem can usually be solved by installing the system package that
provides this library (you may need the "-dev" version). If the library is
already installed but in a non-standard location then you can use the flags
--extra-include-dirs= and --extra-lib-dirs= to specify where it is.
If the header file does exist, it may contain errors that are caught by the C
compiler at the preprocessing stage. In this case you can re-run configure
with the verbosity flag -v3 to see the error messages.

these options --extra-include-dirs=include/ --extra-lib-dirs=cbits/ --extra-lib-dirs=cbits/ give the same error (and just might not be wrong).

btw, what version of clang works for you? mine seems to be 3.9. i've built several packages with foreign code on my system, so my configuration should(?) be okay. could the C be using older (or newer) features? (i've gotten this error on windows before, when trying to include/process windows headers with ghc's gcc.)

it builds with the default gcc:

[nix-shell:~/gRPC-haskell]$ cabal configure --enable-tests -fwith-examples && cabal build 
Resolving dependencies...
Configuring grpc-haskell-0.0.0.0...
Building grpc-haskell-0.0.0.0...
Preprocessing library grpc-haskell-0.0.0.0...
Preprocessing executable 'compile-proto-file' for grpc-haskell-0.0.0.0...
Preprocessing executable 'hellos-server' for grpc-haskell-0.0.0.0...
Preprocessing executable 'hellos-client' for grpc-haskell-0.0.0.0...
Preprocessing executable 'echo-server' for grpc-haskell-0.0.0.0...
Preprocessing executable 'echo-client' for grpc-haskell-0.0.0.0...
Preprocessing test suite 'test' for grpc-haskell-0.0.0.0...

[nix-shell:~/gRPC-haskell]$ cabal exec -- echo-server --help
cabal: The program 'echo-server' is required but it could not be found.

[nix-shell:~/gRPC-haskell]$ echo-server --help
echo-server: command not found

but the exe's themselves seems to work:

$ dist/build/echo-client/echo-client --help
Runs the echo client
...

$ dist/build/echo-server/echo-server --help
Runs the echo service
...

either way, i'll read through the tutorial you linked.

sboosali avatar Apr 30 '17 19:04 sboosali

@ixmatus

yeah, it's the same as the readme (unless i have a typo?)

nix-shell release.nix -A grpc-haskell.env

sboosali avatar Apr 30 '17 19:04 sboosali

and i'm pretty sure i'm on the latest version:

$ git rev-parse HEAD
b550607f60d4aeac3b6c8ecc316ff1147a81cf47

sboosali avatar Apr 30 '17 19:04 sboosali

btw, one issue was that the examples are disabled by default. but then when built with -fwith-examples, there still was the path error.

sboosali avatar Apr 30 '17 20:04 sboosali

Is there any way to use this library without using Nix? Are there plans to remove that dependency later on in the roadmap? Just wondering.

roman avatar Jun 03 '17 17:06 roman

(I'm not part of that group, but since you're asking on this thread...)

I hope not. It's the dependency that manages all other dependencies. nix is probably the easiest / most reliable way for them to get software with these complicated external dependencies installable by others.

On Sat, Jun 3, 2017 at 1:24 PM, Roman Gonzalez [email protected] wrote:

Is there any way to use this library without using Nix? Are there plans to remove that dependency later on in the roadmap? Just wondering.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/awakenetworks/gRPC-haskell/issues/14#issuecomment-305989245, or mute the thread https://github.com/notifications/unsubscribe-auth/ACNoMZs3AhB5mlqSOO7FykRwG9pLxmMCks5sAZbXgaJpZM4NMdcM .

--

(this message was composed with dictation: charitably interpret typos)Sam Boosalis

sboosali avatar Jun 03 '17 17:06 sboosali

There's nothing preventing you from using this library without Nix. It's an ordinary Haskell library that we will eventually upload to Hackage once we are done polishing the library. The only manual bit you would need to manager yourself is installing the grpc library dependency

The main benefit of using Nix is that it takes care of installing exactly the right version of the grpc dependency for you without contaminating global install paths

Gabriella439 avatar Jun 03 '17 17:06 Gabriella439

yeah, the haskell library has the default Setup.hs, so its normal if it can link. (i thought they meant a non-nix build script).

On Sat, Jun 3, 2017 at 1:44 PM, Gabriel Gonzalez [email protected] wrote:

There's nothing preventing you from using this library without Nix. It's an ordinary Haskell library that we will eventually upload to Hackage once we are done polishing the library. The only manual bit you would need to manager yourself is installing the grpc library dependency

The main benefit of using Nix is that it takes care of installing exactly the right version of the grpc dependency for you without contaminating global install paths

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/awakenetworks/gRPC-haskell/issues/14#issuecomment-305990425, or mute the thread https://github.com/notifications/unsubscribe-auth/ACNoMX8EFIATmJSrW7Cf7xvJb7djGx2zks5sAZt-gaJpZM4NMdcM .

--

(this message was composed with dictation: charitably interpret typos)Sam Boosalis

sboosali avatar Jun 03 '17 17:06 sboosali

Thanks for your prompt reply Gabriel, I was not understanding what was the scope of the nix script, not familiar with the language and cannot easily infer the extent of what this nix scripts do.

Perhaps having a place on the README.md that says what the nix file is installing for developers that are unfamiliar with Nix might help? Not a priority I understand, just my 2 cents... really looking forward to trying out this and the proto3-suite package.

Cheers.

roman avatar Jun 03 '17 17:06 roman

The README does clarify what is being installed:

Run the following command from the root of this repository to install the compile-proto-file executable

Gabriella439 avatar Jun 05 '17 15:06 Gabriella439