I am running RHEL 6.2 on a VM (I have no control over it). I would like to use Ruby along with Mysql to do the work I need to do. But right now the server does not have the mysql gem installed. It doesn't even have ruby gems installed. So I can't simply do gem install mysql. The people maintaining the server suggested I do local install of ruby gems. Is there a benefit to this? What if the server is hosting a web application that consists of code depending on a gem? Will this effect anything?
Either in ~/.gem (local) or in /usr/lib/ruby (system). Locally installed gems are accessible by you only, system gems everyone can use.
Related
I am trying to make an CLI tool with ruby.
My tool require some library in bundle (log4r, ...). So problem appear when i switch my ruby version (2.0.0 -> 2.1.2) or when switch gemset, some gem are not install in new ruby environment.
So how can i make my app work like vagrant, which work in every version of ruby i am using?
If you package your application as a Gem, you can include a Gemspec that describes your application. One of the things you can specify is its runtime dependencies; when the user runs gem install myapp, then the gem command will make sure it includes everything you specified (like log4r).
It will be harder to make this happen without Rubygems. You can package your application along with a defined version of Ruby and all its requirements - that's what Vagrant does - but that makes your application a larger download and means you have more to maintain. It's going to be hard work if you want to install your app system-wide and have it work with every single Ruby environment. It's far better to let the gem application install your app (whether systemwide, or via rbenv/rvm) and let that manage your dependencies for you. There's the default gems plugin for rbenv and rvm gemsets to help manage this.
Well, I have to admit, that I'm down today. I've updated my Ubuntu and that rendered Redmine 2.1.2 completely dead. Any suggestions as of to what should I update or reconfigure? I'm trying not to use Ruby/Rails/Passenger blindly but it's tough as it's not my expertise. I'd like to USE Redmine instead.
Top of the Passenger error log is below, but feel free to check whole page at http://redmine.teacloud.net:
It looks like Bundler could not find a gem. Maybe you didn't install all the gems that this application needs. To install your gems, please run:
bundle install
If that didn't work, then the problem is probably caused by your application being run under a different environment than it's supposed to. Please check the following:
Is this app supposed to be run as the nobody user?
Is this app being run on the correct Ruby interpreter? Below you will see which Ruby interpreter Phusion Passenger attempted to use.
-------- The exception is as follows: -------
Could not find rake-10.3.2 in any of the sources (Bundler::GemNotFound)
/var/lib/gems/1.8/gems/bundler-1.3.4/lib/bundler/spec_set.rb:92:in `block in materialize'
• I have no idea, what user should this app supposed to be run as. Everything else uses www-data by default, however the redmine application folder in filesystem is owner by root.
• Everything was working for two years on ruby 1.8 that is not on my system now. I've managed to install lowest version 1.8.7, latest 2.1.2... and I have no idea where does the 1.9.1 get from.
• I don't understand how 'bundle install' and 'bundle update' is related to current ruby version switched to using rvm.
• I am not sure, at what point will my Redmine MySQL database be migrated or destroyed if I'll need to upgrade Redmine (so I have backup).
• bundle install didn't help, Apache runs ruby 1.9.1
Solution was simply as follows (whole failure path is documented here http://www.redmine.orgenter code here/boards/2/topics/43500?r=43514):
• Everything happens in the Redmine's installation folder:
• Went to GitHub (https://github.com/redmine/redmine/blob/master/Gemfile) and copied fresh database section to Redmine's Gemfile (ignoring the fact that I have Redmine 2.1.2 and Gemfile is far newer)
$ rvm use system
$ bundle install
What is the difference between a ruby library installed from a tarball versus through a gem install?
My machine can't connect to rubygems.org because of a university proxy, so all my installations happen locally. I have some gems that I've installed using a gem local install, and others where I've downloaded a tarball and run setup.rb or some such. In my newbie-ish state when messing around with Ruby I wasn't too phased about this inconsistency, but it bothers me now.
I assume rubygems is the preferred method, but I'd like to understand the exact pitfalls so that I can know what to watch out for when I try clean out my machine.
The most important difference is that Ruby extensions installed without the gem mechanism cannot be easily uninstalled or updated (except they provide their own mechanism for that). Automatic installation of dependencies is also largely simplified with gems.
If you are behind a proxy, you can tell gem to use that proxy as well, e.g.
gem install foo --http-proxy http://192.168.0.1:81
or define the environment variable HTTP_PROXY like
export HTTP_PROXY=http://192.168.0.1:81
Look into your browser/network settings to find the proxy address.
I am currently running a gem server for our company that stores our local in house gems. We are currently using the default rubygems server that is invoked with gem server. However whenever we fetch from this server (using bundler) we get:
Could not fetch prerelease specs from rubygems repository http://rubygems.myserver.org
The server works fine otherwise, but we would actually like to have our server support prerelease anyhow. Is anyone running a gem server successfully with prerelease? If so what server are you using and how? I cannot seem to find any documentation on this.
The solution to this is not to use gem server, but use a regular web server then execute gem generate_index. This successfully built prerelease and regular indexes.
http://docs.rubygems.org/read/chapter/18 section 4.2
Our server has ruby 1.8.7 and i have 1.8.6 locally. I want to upgrade my local machine (which has ubuntu 9.10) to ruby 1.8.7 - NOT to 1.9 or any later versions. I tried sudo apt-get install ruby1.8.7 but there's no package for that.
Have you tried RVM? There is also a system-wide installation available for servers.
http://rvm.io/
http://rvm.io/deployment/system-wide/
I would highly recommend using RVM.
RVM is a system wide or user wide service (depending on your preference) that allows you to install multiple versions of Ruby without causing problems. Installation is very easy to get started with and since it allows for different versions of Ruby to be installed, you could easily continue programming in 1.8.6 for one project and seamlessly switch to 1.8.7 to program for the server you are working with. You can even set different users to have different versions of Ruby set as their default if you go the user-wide way.
Make sure you have git and curl installed.
https://rvm.io
https://rvm.io/rvm/install/
It does take a little getting used to but it is a very powerful tool for developing with different versions of Ruby and even different versions of the Rails Gem. This is great too, you can have multiple Gemsets as well. So, for instance, if you need to test a new Gem or version of a Gem without mucking up a stable one you already have installed, you can create a separate Gemset and play around with it and switch back at your convenience.
Has saved me from having a lot of headaches in the past.