<jokke>
mps: ah ok. alpine is very popular as base for docker images since it's very light weight. with muslibc it's even possible to statically link crystal builds which makes it even more interesting for docker since you can just use "scrach" as base image for your final build (a container containing nothing (no pun intended :)) and copy the statically linked binary in there.
<FromGitter>
<dscottboggs_gitlab> good night mps!
<jokke>
night mps and thanks for the great work!
<mps>
you are welcome :)
<FromGitter>
<dscottboggs_gitlab> what prevents statically linking glibc stuff?
<rkeene>
discottboggs_gitlab, glibc supports NSS, which are dynamic, and statically linking to it requires that the same versions be used since they haven't defined a stable ABI for NSS modules
<rkeene>
jokke, glibc is LGPL, which allows you to statically link as long as you make available the unlinked objects to replace the LGPL parts and relink
<jokke>
that's true
<jokke>
but it's a bit unpractical
<jokke>
oh it's LGPL
<jokke>
thought it was GPL
<FromGitter>
<dscottboggs_gitlab> rkeene what is NSS?
<FromGitter>
<dscottboggs_gitlab> that is kind of essential, yes
<FromGitter>
<dscottboggs_gitlab> I'm gonna be honest I still don't get how that prevents static linking but if you don't want to explain it to me that's ok haah
<rkeene>
Because NSS modules are shared objects (i.e., can't be statically linked in) and lack a stable ABI (i.e., the ones on the system may not match the ones compiled against) if you statically link glibc then you can't reliably use NSS
<FromGitter>
<dscottboggs_gitlab> > NSS modules are shared objects (i.e., can't be statically linked in) ⏎ ⏎ I see...why can't they be linked in?
<rkeene>
Because they're shared objects :-D
<rkeene>
They're defined by the fact that they are linked in at runtime
<rkeene>
Since the running system could be configured for arbitrary NSS module usage -- there are MySQL NSS modules, for example
<FromGitter>
<dscottboggs_gitlab> Oh I think I get it now
<FromGitter>
<dscottboggs_gitlab> Jeeze
<rkeene>
It's the identification counterpart to PAM
<FromGitter>
<dscottboggs_gitlab> So is there no way we could get around using NSS or would it not be worth it to do so?
<rkeene>
You can always not use NSS as part of your program -- don't try to resolve hostnames, or lookup users, etc
<rkeene>
Then there's no problem -- same as if you don't try to authenticate users (e.g., PAM)
<FromGitter>
<dscottboggs_gitlab> oh, so even though the compiler gives you warnings it'll still run
<rkeene>
If you don't use those functions it won't give you the warning
<FromGitter>
<dscottboggs_gitlab> oh I see
<rkeene>
It'll still run with the warning, it might just crash if the ABI's mismatch
<rkeene>
:-D
<FromGitter>
<dscottboggs_gitlab> It would be nice if the warnings also told you what you did that caused the warning. Like, does `File.open` implicitly call something in NSS? or `HTTP::Server`? Tjere
<rkeene>
musl-libc just doesn't care about supporting arbitrary NSS modules, so only the ones you link in will be used
<FromGitter>
<dscottboggs_gitlab> except reading the source of course..
<rkeene>
It'll tell you the name of the object file that tried to use the symbol, IIRC
<FromGitter>
<dscottboggs_gitlab> hm...
<rkeene>
$ cat foo.c
<rkeene>
int main(int argc, char **argv) { getaddrinfo(); }
<rkeene>
$ cc -o foo -static foo.c
<rkeene>
foo.c:(.text+0x15): warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
<FromGitter>
<dscottboggs_gitlab> yeah it looks like using a TCP Server uses `getaddrinfo` at least so anything to do with HTTP serving will implicitly bring that into scope
<rkeene>
You could always modify glibc to not link them dynamically but instead statically, like musl-libc
<rkeene>
And then be sad when users have weird systems
<FromGitter>
<dscottboggs_gitlab> hahah yeah that's pretty much what I figured :p
<FromGitter>
<bew> @j8r you're looking into NixOS? me too since 3days :)
<rkeene>
AppFS man, I'm telling you
<jokke>
j8r: about nixos: it's roughly 2-3 years ago since i tried it, so things might be much smoother now
<FromGitter>
<bew> you did appfs right?
<rkeene>
Yes
<FromGitter>
<bew> how is it different from Nix?
<rkeene>
I thought about rewriting it in Crystal but I wasn't sure how FUSE's insetence on creating threads would work with it
<FromGitter>
<bew> beside it's fuse and everything that goes with it
<rkeene>
AppFS is on-demand lazy caching of packages rather than including an additional "install" step
<FromGitter>
<bew> caching only? I'm mainly interested in Nix for the 'create your own environment in code' thing, and the 'track everything you do on the system in config files' and also 'keep track of all the change you do when doing a custom package, reproducible build' etc.. (most of what Nix & NixOS highlights actually)
<rkeene>
Yeah, all writes go to your home directory so it's not perscriptive like NixOS
<FromGitter>
<bew> it looks interesting for non-root package install though, easier than organize everything yourself like I did up until now^^
<rkeene>
Yeah, and you only have to build the package once and then everywhere has the new package/update without having to install/update/distribute, etc
ashirase has joined #crystal-lang
<rkeene>
I used to maintain a few thousand Slackware packages (counting revisions as separate packages)
<FromGitter>
<Blacksmoke16> `SELECT * FROM contacts e JOIN settings s ON s.id = e.id WHERE (e.age = ? AND e.role = ?); [30, "'foo'"]` is from the example as it requires DB shad now
<FromGitter>
<Blacksmoke16> shard
<rkeene>
bew, I'll publish something next
ashirase has quit [Client Quit]
<FromGitter>
<bew> how do you the live sharing like that??
<rkeene>
I need to upgrade my Go-lang package
<rkeene>
bew, GoTTY
ashirase has joined #crystal-lang
<FromGitter>
<dscottboggs_gitlab> @Blacksmoke16 that's nice but I am tired
<rkeene>
I don't feel like verifying the SHA256 right now, so I'm going to trust it
<jokke>
rkeene: gotty.. nice
<jokke>
really nice
<rkeene>
bew, Go is building -- I'll be right back, gotta pick up food
<jokke>
didn't know this existed
<FromGitter>
<bew> it's pretty cool, really
<jokke>
yeah
<FromGitter>
<bew> I reaally need to setup a server for my stuff...
johndescs has quit [Ping timeout: 268 seconds]
<FromGitter>
<Blacksmoke16> well now just gotta write tests
johndescs has joined #crystal-lang
<FromGitter>
<Blacksmoke16> just requires that a model has a class method called `table` which returns the table name
<FromGitter>
<Blacksmoke16> possibly could provide some extensions/adapters for various ORMs
<FromGitter>
<dscottboggs_gitlab> yes, mine required a `#table_name` as well
<FromGitter>
<Blacksmoke16> maybe eventually can include some fancier API methods that other ORMs can implement
<FromGitter>
<Blacksmoke16> to turn like `Model.where(id: 1)` into spec under the hood
<rkeene>
I think I'll package something simpler than Go it's not working out for me
<FromGitter>
<bew> gotta go, byee
<FromGitter>
<Blacksmoke16> o/
<rkeene>
bew, Doh
<rkeene>
bew, I was going to jq real quck
<FromGitter>
<Blacksmoke16> @dscottboggs_gitlab yea is kinda required, *could* base it off class name but thats not really representative of what the model's name would be
<FromGitter>
<Blacksmoke16> table's name*
<FromGitter>
<dscottboggs_gitlab> it could be, why not?
<FromGitter>
<dscottboggs_gitlab> but I think `#underscore` would be adequate, as long as you could use it only if `#table` isn't defined, but it's your library and if you don't want that then don't do it :p
<FromGitter>
<Blacksmoke16> wanna write some tests for me? :trollface:
<FromGitter>
<dscottboggs_gitlab> I'll consider it :p
<FromGitter>
<dscottboggs_gitlab> is the repo public?
<FromGitter>
<Blacksmoke16> not yet, didnt push anything yet
<FromGitter>
<Blacksmoke16> while everything was still influx
<FromGitter>
<Blacksmoke16> the one major thing i still need to solve is the param placeholders
<FromGitter>
<Blacksmoke16> grr PG
<FromGitter>
<Blacksmoke16> might make this modular in like
<FromGitter>
<Blacksmoke16> `require "specify"`
<FromGitter>
<Blacksmoke16> `require "specify/pg"` for the pg specific stuff etc
<FromGitter>
<Blacksmoke16> didnt get that far yet
<FromGitter>
<dscottboggs_gitlab> I was considering different backends for storing config data for flix, and I think I'm going to use compile-time flags to generate different sections.
<FromGitter>
<Blacksmoke16> Oh?
<FromGitter>
<Blacksmoke16> That would be an option
<FromGitter>
<dscottboggs_gitlab> I think that would make it compile differently based on compile_time environment flags but I haven't played with it yet
<FromGitter>
<Blacksmoke16> flag?
<FromGitter>
<Blacksmoke16> That would look for env variables ATM
<FromGitter>
<dscottboggs_gitlab> I mean environment variables
<FromGitter>
<dscottboggs_gitlab> yeah
<FromGitter>
<Blacksmoke16> Ah gotcha
<FromGitter>
<Blacksmoke16> Going to throw an error if none is provided? Or have a default?
<FromGitter>
<dscottboggs_gitlab> default will be flat yaml file in `$XDG_CONFIG_HOME`, with PG or redis options
<FromGitter>
<Ronaq13> Hey guys. I love crystal. ⏎ ⏎ I was looking for some meet-up group in my city (Delhi, India), but there is none. So I thought to start one. Is there anything I need to do before? Need to register somewhere or tell someone?
<FromGitter>
<proyb6> But have you consider making your repo in Crystal first?
<FromGitter>
<proyb6> @Ronaq13
<oprypin>
Ronaq13: if nothing commercial is involved then i don't see why it wouldn't be allowed. i mean, people start meetups about all kinds of programming languages
_whitelogger has joined #crystal-lang
<FromGitter>
<sam0x17> how can I xor two Slice(UInt8)'s ?
<FromGitter>
<sam0x17> compiler is saying operator `^` is undefined for `Slice(UInt8)`
<FromGitter>
<sam0x17> that should definitely be a thing looks like it might not be though without converting to some type of Int
cyberarm has quit [Ping timeout: 268 seconds]
cyberarm has joined #crystal-lang
<FromGitter>
<j8r> @bew yes I need to try it soon. I'm working on an installer for server apps, that will have an API in the future to modify their configuration, install, remove etc
<FromGitter>
<j8r> What worries me is the configuration format pf .nix files – they aren't simply parsable. They may provides bindings, though
<FromGitter>
<j8r> Another thing is I don't know if system users share the library packages, and if I can install the same package X time
<FromGitter>
<j8r> (Like installing N wordpress). I need to try all of this soon
<FromGitter>
<mavu> @j8r Why do you need an installer for server apps? Why not use the systems package manager? Build a debian package for example and use the existing infrastructure.
<FromGitter>
<j8r> @mavu because debian packages only works on debian. They can't be installed multiple times. They are system-wide by default
<FromGitter>
<j8r> For now my install handle the creation of a dedicated user, the configuration through an unified CLI (`port=3000 name=mygiteaserver`)
<FromGitter>
<j8r> Little change is required to support BSD and MacOS too.
<FromGitter>
<j8r> I'm thinking about opening an RFC in crystal issues
ternarysolo has joined #crystal-lang
<mps>
j8r: could that be used to 'self exec'? i.e. running app start self again
<mps>
I'm working on graceful restart app and trying to find elegant solution
<FromGitter>
<j8r> like https://crystal-lang.org/api/master/Process.html#exec%28command%3AString%2Cargs%3Dnil%2Cenv%3AEnv%3Dnil%2Cclear_env%3ABool%3Dfalse%2Cshell%3ABool%3Dfalse%2Cinput%3AExecStdio%3DRedirect%3A%3AInherit%2Coutput%3AExecStdio%3DRedirect%3A%3AInherit%2Cerror%3AExecStdio%3DRedirect%3A%3AInherit%2Cchdir%3AString%3F%3Dnil%29-class-method ?
<FromGitter>
<j8r> no, this lib is just a thin elegant wrapper around `Process.new`
<FromGitter>
<j8r> I'm finding Process.new, Process.run and Process.run &block confusing.Internally, their logic are more/less duplicated
<mps>
eh, looked there but missed self.executable_path
<mps>
that is what I need. thanks for hint
<FromGitter>
<j8r> They are not easy to use because if we want to put the result in a string, we have to create a `IO::Memory.new` and pass it as stdout argument
<FromGitter>
<r00ster91> why not `String::Builder.new`?
<FromGitter>
<j8r> The point is we have to pass something
<FromGitter>
<j8r> this isn't just `result=$(ls /tmp)`
<FromGitter>
<j8r> Personally I also confuse .run and .new :/
<jokke>
rkeene: you don't use base16 by any chance?
<jokke>
i have a problem with gotty (and also asciinema) messing up the colors in vim
<rkeene>
base16 ?
<rkeene>
jokke, If your colors are messed up then maybe TERM is being mangled ?
<rkeene>
jokke, Make sure you have LANG=en_US.UTF-8 (or equiv.) and TERM=xterm-256color
<rkeene>
jokke, Any info on TERM and LANG fixing your gotty issue ?
<jokke>
gotta look at it later
ternarysolo has quit [Ping timeout: 268 seconds]
jemc has joined #crystal-lang
jemc has quit [Client Quit]
DTZUZO_ has joined #crystal-lang
<jokke>
rkeene: didn't help
<rkeene>
Can you show me an example ?
<FromGitter>
<vivus-ignis> hi! anyone using openssl with static builds? i'm having this ⏎ `Unhandled exception: SSL_connect: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed (OpenSSL::SSL::Error)` ⏎ when crest tries to get an https endpoint
<FromGitter>
<vivus-ignis> i'm building statically on alpine with openssl 1.0.2
<FromGitter>
<vivus-ignis> openssl is built from source
<FromGitter>
<Prutheus> Hello. I wanna mmap a file in crystal. I tried this: ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ but how to print the content of the `map` pointer now? with .value, I just get a nil back ... [https://gitter.im/crystal-lang/crystal?at=5c50849eca428b0645203d8e]
<rkeene>
Maybe `mmap()` is failing ? Check errno ? Maybe `file` failed, or isn't a valid file descriptor ?
rohitpaulk has joined #crystal-lang
<FromGitter>
<Prutheus> I get back a pointer, but its value is nil
rohitpaulk has quit [Ping timeout: 245 seconds]
g- has quit [Quit: leaving]
eisque has joined #crystal-lang
<eisque>
Heyo
<eisque>
have a /cmds directory with commands in the module Commands. What will be the best way to load them all into a hash map.
<FromGitter>
<Blacksmoke16> hm?
<FromGitter>
<r00ster91> it was Discord-related, he already got his answer
<FromGitter>
<Blacksmoke16> 👍
eisque has quit [Quit: Page closed]
<FromGitter>
<Prutheus> can anybody please still help me?
<FromGitter>
<franciscoadasme> hi everyone, could anyone explain to me why the following multiple chained nil check does not restrict the types after the first one:
<FromGitter>
<Blacksmoke16> ehh sorry, i know pretty much nothing about pointers and C :/
<FromGitter>
<franciscoadasme> hey everyone, could anyone explain why chained nil checks do not restrict the types in a guard clause except for the first check? ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ Here only `a` is restricted to `Int32` [https://gitter.im/crystal-lang/crystal?at=5c50bff854f21a71a1c80ec2]
<z64>
you need to pass it a pointer for it to write into of `length` size. then you could read from that memory later
<z64>
or `Pointer.null` i guess, if you want the other behavior
<FromGitter>
<asterite> @franciscoadasme probably a compiler bug or enhancement. It works if you move the assignments out of the `if` (which is probably a bit clearer too)
<FromGitter>
<franciscoadasme> I'm aware that it works if I use `if ... end`instead, but I've encountered some cases where this leads to deep nested `if`s, in which case I rather use guard clauses like the above
<Yxhuvud>
@fransicoadasme: Perhaps you can turn your if statements around and do early returns instead of deep nesting?
<FromGitter>
<franciscoadasme> That's my idea... but I'd like to check several variables in one guard clause instead of doing one per each variable (I'd have many consecutive returns), but it doesn't work right now
<FromGitter>
<Blacksmoke16> what about `((a = ary[0]?) && (b = ary[1]?) && (c = ary[2]?)) ? a + b +c : nil`
DTZUZO_ has quit [Quit: WeeChat 2.0]
DTZUZO has joined #crystal-lang
moei has quit [Quit: Leaving...]
<FromGitter>
<franciscoadasme> Regardless of which is your preferred style to do such thing, the important point is that `return unless (a = foo) && (b = foo)` should restrict `a` and `b` to be not nil and it's currently not working
<FromGitter>
<franciscoadasme> thanks for the ideas... I'll see how to apply them to my code
<FromGitter>
<Blacksmoke16> Also worth looking if you can do the check further up in the code