Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to run exe's / examples #14

Open
sboosali opened this issue Apr 30, 2017 · 15 comments
Open

how to run exe's / examples #14

sboosali opened this issue Apr 30, 2017 · 15 comments

Comments

@sboosali
Copy link

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.

@ixmatus
Copy link
Contributor

ixmatus commented Apr 30, 2017

@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
Copy link
Contributor

ixmatus commented Apr 30, 2017

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

@Gabriella439
Copy link
Contributor

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

@sboosali
Copy link
Author

@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!

@ixmatus
Copy link
Contributor

ixmatus commented Apr 30, 2017

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?

@sboosali
Copy link
Author

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
Copy link
Author

@ixmatus

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

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

@sboosali
Copy link
Author

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

$ git rev-parse HEAD
b550607f60d4aeac3b6c8ecc316ff1147a81cf47

@sboosali
Copy link
Author

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

@roman
Copy link

roman commented Jun 3, 2017

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.

@sboosali
Copy link
Author

sboosali commented Jun 3, 2017 via email

@Gabriella439
Copy link
Contributor

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

@sboosali
Copy link
Author

sboosali commented Jun 3, 2017 via email

@roman
Copy link

roman commented Jun 3, 2017

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.

@Gabriella439
Copy link
Contributor

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

RichardWarfield pushed a commit to litxio/gRPC-haskell that referenced this issue Apr 25, 2023
RichardWarfield pushed a commit to litxio/gRPC-haskell that referenced this issue Apr 25, 2023
* Misc cleanup/refactor pass on test suite descriptions and structure (awakesecurity#13)

* Rename module TestTypes => OldTestTypes

* Rename test.proto and test_import.proto package names to GeneratedTestTypes and GeneratedImportedTestTypes respectively

* +tests/Generated{,Imported}TestTypes.hs and related changes

* Add (:: Int) annotation to enum bound to avoid default type warning in generated modules

* (qcPropDecEncId test) Replace OldTestTypes types with GeneratedTestTypes types

* Remove dependency on quickcheck-text

* Add and support additional fields for `WithNesting` in test.proto

We did this to match prior `NestedMsg` use in `OldTestTypes` as part of the
effort of redirecting the test suite to operate on code generated from .protos
rather than hand-rolled types.

* Use GeneratedTestTypes for remainder of the current types under test (after making small tweaks for type parity)

* Add pretty-show dep so it can be used in the repl

* Fix bug in the `MessageField` instance for `PackedVec Word32`

* Add helpers/instances for pprinting simplified, single-message DotProtos from corresponding Haskell types; comments

* Minor module reorg

* Remove warnings
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants