#ruby - 08 April 2019
« Back 1 day Forward 1 day »
[00:57:46] quarters: hello. I'm having an issue with running pry without readline and was wondering what the standard solution for this si
[01:17:09] thejamespinto: adam12: Did you use RVM or RBENV to install your Ruby? It's quite useful and by the amount of information I have I can't fully assess your level
[01:18:47] adam12: I always just ensure that readline is available (or libedit :\) so I haven't ran into this case before.
[01:20:37] quarters: kind of different, but the underlying error is the same I think: libreadline.so.7: cannot open shared object file: No such file or directory - /home/quarters/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/x86_64-linux/readline.so (LoadError)
[01:21:53] thejamespinto: adam12: as I said, I can't fully assess your level with of skill with Ruby. I can tell you're skilled at Linux. Please, take no offense
[01:22:33] adam12: thejamespinto: No offese taken, just confusion. I'm familiar with Ruby. I've published some things. github.com/adam12
[01:23:23] adam12: quarters: Recent install of Ruby via RVM? Is there a reason why you can't install libreadline? Did this ever work?
[01:24:05] adam12: quarters: The fact that readline.so exists but libreadline.so.7 doesn't isn't right. I don't think readline.so would ever exist without the Ruby compiler detecting libreadline during the running of configure/autoconf.
[01:24:24] quarters: adam12, it's been awhile since I've touched ruby. is libreadline also a ruby gem?
[01:24:45] adam12: quarters: The way Ruby works is, it tries the $LOAD_PATH for files matching $name.rb or $name.so. Your $name.so is conflicting with the Ruby gem you installed that's called readline.rb.
[01:27:06] adam12: quarters: If you for sure have libreadline installed, then a reinstall of Ruby is likely easiest.
[01:28:35] thejamespinto: adam12: I'm a community manager myself and I can't tell you how many weird cases I've seen of people who've been tasked with making a ruby project run and they get lost in the details of installation. :( You're an awesome minority when it comes to having actual relevant questions when it comes to readline :)
[01:32:17] adam12: thejamespinto: All I had to do was give my head a shake and some painful memories about readline came falling out.
[01:32:51] adam12: thejamespinto: I'm excited for the work on the new edit mode one of the Ruby core members is working on to replace readline with a better line editor (multi line editor?)
[01:34:37] adam12: quarters: Just out of curiosity, would you mind running this inside pry? $LOADED_FEATURES.grep(/readline/)
[01:35:20] adam12: quarters: Yeah. Borked Ruby install. You could likely uninstall rb-readline to avoid any confusion in the future.
[01:35:29] thejamespinto: adam12: personally, the sounds on the shower scene from Psycho take over me for a few seconds
[01:39:54] adam12: thejamespinto: Just realised I never answered your question. I normally use ruby-install from postmodern to install my Rubies, and then use direnv with PATH_add to setup load path (and sometimes I'll set GEM_HOME/etc).
[01:40:50] adam12: thejamespinto: But after realizing a few weeks ago that truffleruby was getting along fairly well, I upgraded ruby-install to try installing truffleruby which turned into a) truffleruby not working on FreeBSD and b) new ruby-install being borked on FreeBSD. So I am just fetching/compiling manually.
[01:41:48] thejamespinto: adam12: I've handled a few Postgrad students who firmly believed Ruby is an academic language and they were shocked when I gave them a link to the ROR and RUBYGEMS sites :)
[02:27:19] thejamespinto: OMG! Does anybody remember how to make an attr_reader for class variables?
[02:29:54] adam12: thejamespinto: Presumably you're talking about class variables and not class instance variables `class << self; attr_accessor :some_method; end`
[02:31:42] thejamespinto: I've been stuck at a silly job for the past two years while I finish my masters/phd
[12:17:28] ryouba: i want to `class MyDoc < Sequel; ...; def self.first_by_title(q); ...; end; end` and then use that like `entry = MyDoc.first_by_title('foobar')` and have `entry.class` be "MyDoc". but how do i return an "object of myself" at the end of that static class method? *confused*
[12:44:55] dionysus69: any good resources where I can play with interfacing ruby with C or Rust? let's say I write hello_world method in either of them, just dont know where to start
[13:01:42] ryouba: phaul: so, http://sequel.jeremyevans.net/rdoc/files/doc/object_model_rdoc.html#label-Sequel-3A-3AModel holds the answer. it *magically* assumes that the table name is the same as its own name in underscorized writing style.
[13:15:27] mnemon: dionysus69: https://www.amberbit.com/blog/2014/6/12/calling-c-cpp-from-ruby/ various other methods without gem native exts
[13:15:35] ryouba: phaul: my solution was to rename the table. it's kind of nice for them to be having matching names. i did add a comment inside the model class, though. otherwise it's a little *too* magic.
[13:19:26] dionysus69: thanks mnemon just found this too https://www.youtube.com/watch?v=Ms3EifxZopg&t=1796s
[15:00:33] mad_hatter: what do you guys recommend as the best book for learning ruby coming from other languages such as perl and python
[18:49:24] marz_d`ghostman: If I'm running rails with puma, which is the default, will I need nginx or apache?
[18:50:39] havenwood: marz_d`ghostman: You don't need either, but it's common to use one or the other and reverse proxy to the Puma socket.
[18:53:23] havenwood: marz_d`ghostman: assuming you want to use ssl, you'll also need: -b 'ssl:...crt'
[18:58:25] havenwood: marz_d`ghostman: There are various reasons you might want to put NGINX in front. You can serve static files directly (not through Rack), it provides HTTP/2 support, SSL works easily with certbot, etc. But of course Apache and NGINX are a huge pain to configure. ¯\_(ツ)_/¯
[18:58:50] havenwood: marz_d`ghostman: You can basically get those same benefits by putting Cloudflare in front too.
[18:59:13] marz_d`ghostman: havenwood: I agree, I'm currently running my rails app inside docker and setup nginx on this server
[18:59:23] adam12: I've become preferential to Caddy, tho they can't seem to decide how they want to license it. Building from source (or using a package manager) gets you the Apache license tho, which is decent.
[19:00:29] adam12: havenwood: Reverse proxy + auto ssl is super simple. Most of my Caddyfile configs are 2-4 lines.
[19:04:05] adam12: havenwood: It supports on-demand TLS negotiation as well, which is nice if you offer custom domains+SSL on projects. You can setup a hook in Caddy to ask your app if it's a legit hostname that requires TLS, and if it is, Caddy handles the LetsEncrypt request and live reloading / serving of the new certificate during the TLS handshake.
[19:06:34] Zarthus: adam12: I used to be a caddy fanatic but the fact they ever thought sponsoring in their headers was a good idea kinda ruined my trust in them
[19:07:19] adam12: Zarthus: To some degree I'm with ya. I'm not sure why it's taken so long for everyone to catch up to them in regards to configuration + auto SSL tho. Maybe the new Passenger will get there.
[19:09:06] havenwood: Falcon is a really interesting contender on the Rack webserver side of things: https://github.com/socketry/falcon
[19:24:19] brool: if i have a string like "R and G and Blue" can i use a single regexp to get an array like ["R", "G", "B"] or do i have to iterate over the string's characters to do that?
[19:57:21] brool: is there a way i can quickly convert a string into a regexp like "abcde" -> /[abcde]/ ?
[20:37:03] TheSin: anyone have any idea how to fix "LoadError: cannot load such file -- kubeclient/oidc_auth_provider" when it's kubeclient.rb that is calling a require on kubeclient/oidc_auth_provider and it's present?
[20:43:31] leftylink: to see where ruby is looking for files that are `require`d, you may find it useful to look at the value of $LOAD_PATH . it sounds like a directory is not in there that should be.
[21:14:02] TheSin: leftylink, I can't see that cause there are like 8 includes in kubeclient.h before that one from the same dir is that one since it's part of the package, it's making me nuts though
[21:27:58] cthulchu_: hahuang65, have you ever felt either that the flush changes the output, either the timing or the order OR that flush causes any measurable performance issues?
[21:32:43] hahuang65: cthulchu_ I don't use flush in anything production. i mainly use it in local scripts. I've never noticed it change the timing or order of logs, but I suppose it's possible.
[21:34:22] cthulchu_: I'm about to use it just to have the parent process reading the output line by line
[22:25:15] cthu|: my lovely folks, there's -u key in Python. If you run a py script with it, it disables stdout buffering. Is there a similar solution for Ruby?