#ruby - 27 June 2018
« Back 1 day Forward 1 day »
[06:27:37] mikhael_k33hl: Is there an article/documentation for best practices pertaining model creation in Ruby?
[09:53:31] grr12314: hello. how do you guys usually use ruby on ubuntu? there are ruby-somthing-or-other packages in apt-get repos for things that are installed with gem install on other distros... but they are often lower versions.
[09:53:57] grr12314: so is there a ppa or something that lets me use apt-get or should i just ignore apt-get and install everything with gem?
[09:54:37] cdunklau: grr12314: i'm still a babe-in-the-woods with ruby, but ISTM sudo gem install is something to be avoided
[09:55:13] elomatreb: The most common way to use Ruby if you want to do development instead of just running some packaged ruby software is to install a local ruby environment
[09:55:41] cdunklau: grr12314: https://github.com/airbnb/synapse#installation has an example of how to install a thing without using root
[09:56:01] elomatreb: You can build a custom ruby and install it to your home directory with a variety of tools, a popular choice is https://github.com/postmodern/ruby-install
[09:57:46] grr12314: the ruby-compass package from apt-get repo pulls an old ruby-chunky-png version
[09:58:05] elomatreb: You can install a one-off gem to your user directory with `gem install --user-install <gemname>`
[09:58:31] elomatreb: If you want to use an executable provided a gem you may also need to adjust your PATH variable
[09:59:11] grr12314: will user-installed chunky_png get used by the apt version of compass tho? or do i need to install the whole compass as --user-install?
[10:01:04] elomatreb: Global gems probably won't pick up the user-local version, but if you're installing locally anyway there's no good reason not to install the entire gem and its dependencies locally
[10:01:38] elomatreb: If there are gems with native extensions you may need to install some build dependencies with apt though
[10:01:51] grr12314: its really confusing. ok i gem install compass --user-install. but now it probably sees the global chunky_png and doesnt pull a local one
[10:04:16] grr12314: hm. ok installing both compass and chunky_png seems to have worked. as in, at least the original bug i was fighting is gone. now compass throws some new errors at me though
[10:11:25] elomatreb: ruby-install + https://github.com/postmodern/chruby gets you a really comfortable setup, the only downside is that your ruby is not shared across users
[10:14:07] grr12314: "can't find header files for ruby at /usr/lib/ruby/include/ruby.h" do you know what package i need so i have those header files?
[11:12:25] grr12314: is there some gem command that can "clean" unneeded packages? i see there is gem cleanup but it seems it only removes older versions.
[11:13:15] grr12314: like if i 'gem install compass' it pulls a dozen gems, but 'gem uninstall compass' only removes the compass one
[11:13:37] grr12314: keep a list of "manually installed" gems vs ones that got pulled due to dependency i guess
[11:14:40] grr12314: ok. can i uninstall absolutely all that were installed with --user-install then?
[11:14:41] elomatreb: It does not make a distinction between that, but if you want to start fresh you can just delete the gem folder in your home directory
[11:16:27] Bish: elomatreb: well, docker is always the cannon shooting sparrows, because if coding was done correctly from bottom up, there was no need for docker
[11:17:45] elomatreb: But certainly there is a more reasonable middle ground between "no containers" and "basically everything except the kernel", to install a single gem :)
[11:18:27] Bish: well, ruby could be able to create virtual environments on it's own, that'd be cool
[11:25:46] grr12314: ok thanks all, i can say issues have been resolved. i had a globally installed alpha version of compass too that didnt work and confused me for a moment, but after cleaning that up all is well now
[11:28:56] grr12314: speaking of, is there some tool that adds the locally-installed bin to PATH? i could do it manually but if i have to recommend this solution to others, it'd be good if there was some easier way
[11:30:53] elomatreb: No specific tool per se, but Ruby environment managers like e.g. chruby (linked above somewhere) take care of the necessary variables for you
[12:09:21] za1b1tsu: can you use rvm to install multiple versions of rubies at once? from the same command?
[13:11:31] grr12314: if i use `gem install something --user-install --bindir somewritabledir` it installs a script that later looks for the gem bin in the global gem dir and not the user gem dir. wouldn't you say this seems like a bug?
[13:22:37] grr12314: it seems ubuntu has ~/bin and ~/.local/bin in my PATH already (3 times in fact, wtf) even tho those dirs didnt even exist
[13:25:36] konsolebox: grr12314: that's more about how the shell works. command paths are cached, and the shell skips looking for executables when the command path is already known for a specific command. new executable files placed in paths that appear earlier in $PATH are skipped until the cache is cleared with `hash`, or until a new instance of the shell is instantiated.
[16:57:19] plujon: https://guides.rubygems.org/security/ references a "conversation" about gem trust that seems to have fizzled out in 2013.
[17:01:30] havenwood: plujon: There was work done adding TUF to RubyGems, with the help of the TUF folk: https://theupdateframework.github.io/
[17:06:39] havenwood: https://medium.com/square-corner-blog/securing-rubygems-with-tuf-part-1-d374fdd05d85
[17:38:59] Zarthus: For one, apt can download just about anything, whereas gems only really work as ruby gems.
[17:39:39] Zarthus: eh, ruby code can be malicious anyway. you should always check your dependencies :P
[18:29:30] ebye: could someone help out with the code for TryRub lesson "All together now" on the website? it doesn't seem to work?
[18:58:00] ebye: cthulchu_: aye, it did work. i think i suffered from some kind of temporary numbers dyslexia
[18:59:00] cthulchu_: I am working on a function that checks if a number is between two other numbers
[18:59:21] cthulchu_: if one or both of the numbers are nil (which is the default), it will not do the check
[20:11:09] balr0g: hello im trying to excute the following command on Windows with error showed, is there any other way to pass command line arguments on windows? thanks. gem install iconv -v '1.0.5' --source 'http://rubygems.org/' --with-iconv-dir=C:\GnuWin32 ||| ERROR: While executing gem ... (OptionParser::InvalidOption) invalid option: --with-iconv-dir=C:\GnuWin32
[20:13:18] samosaphile: anyone have the solutions to these: https://pine.fm/LearnToProgram/chap_06.html not sure if am doing it right. so far done: https://repl.it/repls/GiantLimpingRoute https://repl.it/repls/AngryGoldenrodWaterfall kinda stuck on how to do third one
[20:17:34] samosaphile: well, i just dunno how to make something which asks for same input 3 times...and when condition met exists..
[20:18:20] balr0g: konsolebox, i got that from this: https://gist.github.com/da8y01/73a51d33dc9b721a0c47883bdddb73f6
[20:20:22] samosaphile: also, does the term 'command' have special meaning in ruby? cuz i've found if i replace word with another word, it doesn't work .. or starts to show errors / warnings(?)
[20:22:51] konsolebox: balr0g: i haven't really tried installing gems in windows yet; especially through gnuwin32
[20:26:15] samosaphile: had to change all my variable names from 'Talk' to 'command' to make warnings go away on repl.it... :S wtf
[20:38:04] balr0g: elomatreb, i've already tried the bash.exe good thing, but i gave up because the path were getting complicted
[22:41:46] havenwood: Anyone want to help fill in any of the purple squares on the Ruby HTTP clients spreadsheet?: https://docs.google.com/spreadsheets/d/1vPlk6nMIFa3sI5ISl7zZ5r6lDNpVQX6Jxi3ksXCyVbs/edit?usp=sharing
[22:43:03] memo1: hi friends. Im using rvm to ruby and gemset control. Im trying to control a ruby script suing unit file (systemd), but it fails, cant find require eventmachine. Is a problem with path?
[22:47:58] havenwood: memo1: These RVM docs are from days long gone by, but they'd apply to SystemD as well: https://rvm.io/integration/init-d
[22:48:32] havenwood: There should be an RVM docs section explaining wrappers. There isn't a dedicated section on it and I see people get confused all the time.
[22:52:29] havenwood: memo1: Here's a bit more written about wrappers: https://rvm.io/deployment/god
[22:53:32] memo1: havenwood: im gonna try, thank you. 1 day trying to run the script using systemd :/
[23:01:57] havenwood: cthulchu_: https://tenderlovemaking.com/2016/02/05/i-am-a-puts-debuggerer.html
[23:12:17] havenwood: cthulchu_: but yeah, pry-byebug if i want to step - which is actually not all that often
[23:24:30] memo1: havenwood: rvm alias create my_app ruby-2.0.0-p247@my_app, this is the help you sent me. my_app is the script name=, and ruby2..@my_app is the gemset?
[23:39:16] memo1: havenwood: it fails. Can you help me. Look, my script is name gps_tracker.rb. I create a ruby2.3.2@gps_tracker gemset. My script is located at /home/ubuntu/gps_tracker.rb.
[23:40:23] memo1: havenwood: i use the rvm alias gpstracker ruby2.3.1@gps_tracker. It creates the wrappers on .rvm/wrappers.
[23:41:41] memo1: havenwood: on the unifile, i set ExecStart=/home/.rvm/wrapper/gpstracker/gps_tracker.rb. But it fails
[23:49:27] havenwood: memo1: is that an executable file? i don't have time to help you debug at the moment, but someone else might. what's the error? what are the systemd logs showing?
[23:52:00] havenwood: memo1: You've said it "fails" but we need more to go off of. Try without SystemD, make sure the Ruby works. Try SystemD with a non-Ruby script, make sure that works. La méthode scientifique!
[23:55:42] memo1: havenwood: sure, it has sheband, it runs alone ./gps_server.rb. But whre trying unit file, it can find the require packages i use.
[23:57:46] memo1: havenwood: wrappers "wrappes" ruby enviroment. so in the unir file i have to set wrapper.ruby /path/to/script