Installing nginx as a ruby gem vs using apt-get - ruby

I'm new to running a Linux server and slowly getting up to speed with things.
I have already installed nginx via the apt-get function, although I'm following a tutorial which recommends installing it as a ruby gem instead.
Is there any difference in the functionality/limitations to installing it as a gem than by using apt-get? - I'm worried that it won't work for non-ruby applications if it is gem installed?

Is there any difference in the functionality/limitations to installing it as a gem than by using apt-get? - I'm worried that it won't work for non-ruby applications if it is gem installed?
There aren't any limitations on the version of Nginx that Passenger installs for you. You should be able to use it with other languages as you normally would (providing you know how to configure Nginx.) I was able to use it to connect to both Ruby and Node.js sites with no problems.
The people at Phusion have a nice page explaining why they are forced to provide their own version of Nginx (rather than using the standalone one) and it comes down to the fact that Nginx does not allow to be extended at runtime. Extensions like Passenger must be compiled into it. See this page for more information on it: https://github.com/phusion/passenger/wiki/Why-can%27t-Phusion-Passenger-extend-my-existing-Nginx%3F
(Note: When I tested this I used the installation instructions from the Phusion web site https://www.phusionpassenger.com/documentation/Users%20guide%20Nginx.html#install_on_debian_ubuntu , rather than the gem that is indicated in your tutorial, but I suspect they are both equivalent.)

I have run into this too. Where I am recommended to use one package manager over the other. I would question the age of the tutorial first, if it is not relatively recent you may want to consider if the information is no longer up to date. The libraries installed with that method may not be up to date.
However, if you intend to follow through with the tutorial you may end up needing it installed as the tutorial describes.
The difference is that one may not have all the libraries that are required or may not have the most up to date version. One tool could be buggy, I don't think this is the case in your situation but it is in Macports v.s Homebrew in my opinion. It might install to a different directory based on what install method you use, if you use a method off the web and then go back to the tutorial it could be installed to a different location then your tutorial expects.
If you have to follow the tutorial then I would all the way through, but if you don't need to use the preferred method that the program/library maintainers recommend. If the tutorial is out of date you could try to find an up to date tutorial.
good luck!

Related

Is there a possibility to install Ruby with all deps like zlib without active internet access?

the question seems to be weird, but it's a part of long story to install Fluentd on sles11 sp4, actually.
I've seen success story of Fluentd on sles11 sp3 here, by #ab77
https://serverfault.com/questions/539307/installing-fluentd-kibana-elastic-search-on-suse-enterprise-linux-11/540521#540521
Unfortunately, I can't follow the way above because of my company security policy : git clone from github via https is disabled, so all dynamic deps via rbenv fail.
So I got an idea to install Ruby 2.1.0 (Fluentd requirements) from an isolated package on JBoss of my company, which should contain all the dependencies.
For the moment I'm struggling with numerous dependencies and not sure if this is possible at all or not (I'm completely new in Ruby).
If you were facing something similar, could you please share your experience?
Thank you for the help!
There is some tutorial for RVM (Ruby version manager) rvm.io/rvm/offline
I've seen companies putting gems to their own gem servers and installing them from there directly guides.rubygems.org/run-your-own-gem-server

Rubymine use local gem configuration

I'm running Ruby mine 7.1.2 on Windows and I'm having difficulty with it because it seems to want to use its own gems and version of fun where. My application works fine from the command line if I do bundle install or bundle exec rails script but when I try to run from the IDE it complains about missing gems.
I could just try to reinstall all the gems via ruby mine but some of the gems require special customization in Windows and doing that from the command line is much easier. Is there anyway I can have ruby mine just use the gems which are already installed?
Rubymine will usually bundle your ruby SDK (i.e. ruby itself) and all it's associated gems so that you don't end up with weird configuration dependencies.
If you want to circumvent that then follow an official guide. In addition to that guide, be aware that there are also per-run SDK settings. These kick in when running or debugging a RubyMine project and need to be configured in the run -> configuration settings dialog.
My (unsolicited) additional advice is that I'd recommend figuring out what aspects of your global ruby installation are causing issues with RubyMine's bundle installer. The reason RubyMine sandboxes several SDKs is to reduce major headaches when you go to deploy your applications. Without it, you might encounter dependency hell when you deploy your application. From my personal (and extremely annoying) experience, rushing these initial set-up steps tend to come back with vengeance when you want to run ruby apps elsewhere.

Benefits of RVM

Why should I/should I not use RVM?
I'm new to the ruby language and servers as a whole. I've had some trouble installing using RVM...so I'm inclined to not use it right now, but it seems like it may make installations down the road easier?
I'm interested to hear about your experience with RVM and your thoughts as it pertains to maintaining a server.
RVM is useful even if you don't want to install multiple versions at the same time. I'm a ruby hobbyist (PHP during the day :(), and I have no reason to want to use old versions, but I still use RVM.
Installing ruby is a pain. Getting it from the package manager (at least in ubuntu) gives you an outdated version that changes installation directories from the defaults. I've had nothing but problems with it.
So you think, "I'll just build it from source". Building from source requires getting a load of dependencies and configuring options. Often times I've built ruby only to find out I forgot to enable SSL support or readline support.
RVM takes care of all of this. In 3 or so commands, you have a perfectly built version of ruby.
And I didn't even cover how RVM manages multiple ruby installations for you, which is its killer feature. If you have that need, there is really no other sane solution.
RVM is great as this allows your to install different versions without touching your system's default Ruby install. It is rather similar to virtualenv's in Python.
Another great advantage to having RVM are the gemsets - you can create as many gemsets that are unique to the version, and patch level, of ruby.
I've extolled some of its virtues here and you should also see this blog post.
In terms of maintaining a server - let's take a Passenger install for example; do remember that Passenger is installed as a gem, so with rvm the benefit here is that you can have multiple installs of passenger, tied to a different version of ruby. Of course, typically, you'll have Passenger running on one version at a time, although there are ways to have Passenger, in particular, running on different ruby versions.
I use different Ruby versions for different projects (that's where .rvmrc is really handy). Some deployment environments are happy with 1.9, while there are a couple of legacy servers using 1.8 for some reasons. Also, occasionally I want to launch a specific version of ruby to compare how they work. RVM does all that for me.
When you are first getting used to Ruby, it may not entirely be necessary. That said, what it does is set you up for success in the future. Because once you get hooked, you may end up playing with projects that need to move from, say, MRI 1.8.x to 1.9.x. Or from 1.9.x, to JRuby 1.6.x. My experience is that this happens irregularly, but when it does, there's no substitute for RVM.
Outside of that, the other biggest feature that I use regularly, is the ability to segment one particular release. So I can have an environment for 'stable' gems, and an environment for 'unstable' gems. For instance, while Rails 3.1 has been in release candidate mode, I've had one main workspace for 1.9.2 and a separate space for Rails 3.1.rc? gems on 1.9.2. That makes it possible for me to keep developing my main Rails 3.0 stuff (with one command at the CLI), without having to specify full file paths to the appropriate rails bin files in order to use the older files.
If you're using a Debian based platform where the packagers/policy leads to a really bad default installation you'll have a way better experience using rvm.

Are the svn ruby bindings provided as a gem?

I see a couple dozen gems that relate to svn, but what little documentation I can find on any of them shows that they are command-line wrappers and misc helpers. (svn-command, svn-hooks, etc.)
I've seen code in the wild that does things like: require 'svn/core' and SVN.Repos.add(...), but the author of that module pulled his svn ruby tools via apt-get. This would not be an option for me, as I'm developing a windows/osx tool.
This page lists a number of projects, but in particular, I'm in need of something that will make it possible to access an svn+ssh repository and I don't have the kind of time it would take to dig through docs on a half-dozen projects, trying to bootstrap each one.
Which gem am I after? From there, I'm happy to dig through code in lieu of documents, but with a call to gem query --name-matches svn --remote returning about 30 hits, I need to narrow it down a bit first.
Exactly what was being pulled by the apt-get command? Was it the bindings themselves (apt-get install libsvn-ruby) or the ruby modules? Since the bindings aren't ruby modules, they can't be pulled in by the gem command. You have to install them via apt-get or manually download them and install them into your system.
You can try svn_wc which requires svn_core. And, I believe svn_core uses the SWIG bindings and the Ruby bindings are included when you install Subversion. You can also try svn_tools which was created by Mark Bates who wrote Distributed Programming with Ruby. I haven't found any documentation on svn_tools though.
I noticed that the RSCM module, which is a unified way of interfacing to various SCM tools, uses the Subversion command line. If there was one tool I thought would use Subversion's API bindings, I thought this would be it, but it too uses the Subversion command line.

Packaging precompiled binaries inside of a gem

I've got a ruby web app that uses lilypond to generate sheet music based on user input. I'd like to move the hosting to heroku (I've recently used heroku on a few projects and really liked it, plus my traffic is low enough that it'd be free host it on heroku, for a while at least). However, heroku's dyno architecture doesn't allow you to ssh in and install whatever packages you want...instead, you give it a gems manifest, and it will install the gems for you.
So, if I'm going to deploy to heroku, I'm going to need to package lilypond as a gem. I've released a few pure-ruby gems, but haven't dealt with native extensions or precompiled binaries, or anything like that.
Is it possible to take some precompiled binaries and package it inside a gem? Ideally, this would include binaries for OS X (which I develop on) and debian linux (which is what's running on heroku), and would install the proper binary when the gem was installed.
it is possible, since precompiled binary gems for windows are the norm. Take a look at rake compiler, perhaps.
also https://github.com/rdp/ruby_tutorials_core/wiki/gem (https://en.wikibooks.org/wiki/Ruby_Programming/RubyGems) might help
-r
I think you've got a few options here:
You could get the Lilypond source and package it into a gem with a native C extension. There are some useful guides on how to do that at http://guides.rubygems.org/c-extensions/ and http://patshaughnessy.net/2011/10/31/dont-be-terrified-of-building-native-extensions
There's also a gem called gitara but I haven't been able to find any information about using it on Heroku. It might be worth emailing the author and asking if he knows anything about that.
You could create a Heroku buildpack that installs Lilypond as part of your deployment. I wasn't able to find any for Lilypond, but there are plenty of examples that do similar things - for example, this one installs Imagemagick (which is included by default on Heroku, so probably not necessary anymore - but hopefully the code is helpful). More documentation at https://devcenter.heroku.com/articles/buildpack-api and https://devcenter.heroku.com/articles/buildpack-binaries
Based on my reading, I think the buildpack option is the best way to go.
Hopefully this helps!
Instead of precompiling, you should be able to just list the gem in your .gems file, see the Heroku documentation. Of course, this requires your gem builds the native code correctly - this is still a task, but hopefully an easier one.

Resources