Why doesn't rails.vim recognize any gems that I install? - ruby

I'm a ruby and vim newbie. I recently installed the rails.vim plugin and all the commands work fine apart from the commands to create a new Rails project. Every time I do this it says rails is not installed on my system, but it is! It also acts up when I create a class that requires a gem that I've installed. Can anyone help with this?

Did you rvm use system before building / brew install-ing macvim? I didn't and got many errors. Doing rvm use system beforehand fixed things up for me.

Related

Specify ruby version to use with Pik

I need to run two Ruby apps on a Windows 2008 server. So, I'm thinking to install Pik for the job (I understand I could use also RVM but the install process doesn't seem very 'stable' to me).
Before installing Pik, however, I'd like to know if there is a way to specify which Ruby version should be used for each app. Something like a .ruby-version file. I have looked for the answer on the official Pik repo but I couldn't find anything about it.
In my opinion, Ref 1, Ref 2 are the two simple references you could have to install different ruby versions using Pik in Windows.
After setting up the environment correctly, you could just use the command similar to RVM.
pik use ruby-2.0.0-p0
Then ruby -v will show ruby 2.0.0p0. So, for different projects, from with in each project folder choose which ruby you want to have.
Hope it helps :)

Installing portable ruby and portable xampp in order to use compass and sass in my windows machine: Is that possible?

I want to try using SASS and compass. As I´ve read that compass runs in ruby, I need to install ruby on my local windows machine in order to go and play with it.
I thought on installing everything in a portable way, I mean in my pendrive.
I´ve download a portable ruby version and a portable xampp version, and I´ve installed both in my pendrive.
My question is: As I´ve haven´t worked with ruby ever, should I just run the ruby app and the xamp app and then just install compass in there?
I´ve read compass installing version, but I don´t know how to install it using the command line inside the pendrive.
Thanks for your help!
I´ve found somewhere else the reply to this, and just in case anyone wonders the same thing, here´s the fastest way to use SASS when you have windows and don´t know a word about ruby, but you read that you need it in order to use compass:
You can install ruby in your windows pc using this. I´ve tried the portable one but didn´t worked in my case.
After that you have to open a special console window (the one with ruby activated). There´s this icon called "start commend promt with ruby" that does exactly that. It is in the same folder as your ruby installation.
You just type this: gem install compass
No, you don´t have to download nothing, it just installs the application.
You don´t need to use the command line anymore, nor you have to pay for the compass.app: You have the free alternative Scout. You install it and from that moment you can work with it.
Maybe you should read these aswell:
http://thesassway.com/beginner/getting-started-with-sass-and-compass
http://andrewpwatson.com/posts/how-set-compass-sass-windows-aptana-studio-3

RVM causing path issues with installed gems on Ruby 1.9.2 - unable to annotate, etc, do I need to reinstall RVM?

I'm on Mac OSX Snow Leopard. I tried to post a similar question to the RVM Google group but it did not seem to get posted.
I'm worried that I've done something fundamentally wrong with my RVM install that's causing these errors, that seems to be related to paths, at each step of the way. Have any of you seen this behavior before?
I started to teach myself Rails programming as of about two months ago with a working environment of Ruby 1.9.1 and Rails 3.0.3, based on a hivelogic install tutorial that had me modify my ~/.profile file and install the relevant bits to ~/usr/local/src/. For reference, the line in my ~/.profile file was this when I installed RVM, if that makes any difference:
export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/usr/local/src:$PATH"
In my terminal I installed RVM as a user using the standard user github bash script.
I tried to install Ruby 1.9.2, which kept running into a weird error about a libfile somewhere. After much Googling I found someone on Stack Overflow that recommended renaming the ~/usr/local directory while performing the Ruby install -- I did this, and the install complete.
Then I did gem install rails and tried to do bundle install in my app, which gave an error when trying to install the SQLite3 gem (even though I already had SQLite3 installed and working). Again, I spent a day Googling this and eventually found "Unable to install sqlite3-ruby gem" that said if I used Macports to sudo port install sqlite3 it would work.
I tried that from the base directory, and Macports did its thing but it didn't fix the problem. Then I did the same thing from my app directory and it fixed the SQLite3 error I was getting.
Now I am able to run rails server and rails generate again, which is great, but then I tried to "annotate" my new model, and I get this error: http://pastie.org/1481570
I have not yet solved this issue, and have looked at many threads of similar issues. This, for example, did not solve my problem: https://github.com/james2m/annotate_models/commit/5997da9692c9b222e8d1be22dfad6ed8638c16a1
I even tried copying my source code directly into the rvm/user/ directory in case that relative path was causing problems, but it doesn't seem to have fixed anything. Maybe I need to uninstall RVM and re-install it as root instead of a user-level thing?
What do you think is the best way to get annotate to work and hopefully get RVM to play nice with my gems going forward?
I'm unfortunately REALLY new to terminal, code, etc, so any help would be much appreciated.
On Snow Leopard you should modify either ~/.bashrc or ~/.bash_profile, preferably the later. Also, RVM will not need anything in ~/usr/local since it's entirely self-contained in ~/.rvm.
RVM uses a nice little shell function to sense the needed directories and desired default Ruby. I suspect either the instructions you followed were very out of date, or poor recommendations. The current RVM installation requests you add:
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # This loads RVM into a shell session.
to your ~/.bash_profile
The RVM site has lots of troubleshooting tips for things like MySQL. I'd strongly recommend backing out of the things those other tutorials had you do, and refer to the instructions on RVM's site. It is very easy to get things working right if you do it the RVM-way.
Download and install Apple's latest version of XCode from their Developer site if you haven't already. There have been some broken versions shipped on the DVDs.
Install. In particular follow the "Post Installation" section.
Following that, do whatever rvm notes says to do as far as libraries. Following that, you should be able to use rvm info to gather useful info about your installation. It is your best friend.
Database integration will point you to how to fix MySQL's wagon.
RVM development happens fast. Keep it updated, at least once a week using rvm get head.
At that point you should be in a good place to start reinstalling gems.

Upgrading Ruby on Mac OS X

I am reading the book Programming Ruby and am looking to upgrade the version of Ruby on my computer. I run Mac OS X Snow Leopard and doing ruby -v in the command line shows I am running Ruby 1.8.7.
I installed MacPorts and ran the sudo port install ruby19 command but whenever I type ruby -v, it still shows Ruby 1.8.7.
Could anyone help with this? Thank you.
The tool "rvm" is pretty good. It stands for Ruby Verson Manager I think, and the developer is good at support in the irc channels. You can install multiple versions of ruby along side each other pick the ones you want to use.
http://rvm.io
You have to use ruby19 to run ruby if you installed it that way. You can also use irb19, and ri19.
I updated the link to RVM in one of the answers, but also a quick poll of some friends doing Ruby dev currently revealed a preference for rbenv as a ruby environment manager: http://github.com/sstephenson/rbenv/
As mentioned in hvgotcodes answer, RVM seems to be a great way of handling this.
I recently started learning Ruby (and Rails) myself, and this[1] tutorial has a great section on using RVM. I'd highly recommend you give it a go, it's especially handy so that you can follow different tutorials on different versions of Ruby if you wish.
[1] http://railstutorial.org/book#sec:rubygems
As #Andrew Grimm eluded, the problem you are having is likely due to a problem in your $PATH variable. Since macports typically installs stuff in /opt, modifying your $PATH variable to:
$ export PATH=/opt/local/bin:$PATH
Will most likely help. However, I would urge you to look into RVM as #hvgotcodes recommends.

RubyGems via MacPorts a good idea?

Upon upgrading from a MB to a new MBP, Apple's migration assistant didn't move my gems.
I'm installing rubygems via macports this time, hoping to avoid this upon next upgrade.
Are there any pitfalls I should be aware of?
If you want your gems installed in your home directory (which should copy over during a transfer, and, as a side benefit, will let you run gem install as yourself, rather than root), set the gemhome: key to a path in your home directory in your ~/.gemrc.
Where were your gems installed? The migration assistant only moves files in certain areas; I'm not sure if it copies files from places like /usr/local or /opt/local, you may have to do that manually (in which case, you can just copy the entire tree over to your new machine).
That said, you shouldn't have a problem installing gems using the version of RubyGems installed by MacPorts.
Installing a package manager via a package manager seems like it should be wrong.
Assuming you are not going to use the system ruby, and will only be using ruby installed via MacPorts; it should not be a problem.
If you plan on using gems with system ruby, you might have problems when Apple upgrades the system version of ruby, unless you are installing your gems in /Library/Ruby/Gems/
I'm going to assume you can just copy the gems to /Library/Ruby/Gems/1.8/gems from /opt/local/lib/ruby/gems but I wouldn't count on it working 100% with every gem.
The migration assistant doesn't move a lot of unix level stuff. This will be true of the macports installed gems as well (which typically live in /opt/local/lib/ruby/gems).
I use macports gem, and this generally works fine with the macports ruby. Be sure you know which ruby executable your shell ends up using, and perhaps use symlinks to control it specifically. I prefer using the macports version so that I'm not beholden to Apple's update schedule. Sadly macports iteself is somewhat inferior to package managers offered on bsd/linux distributions.
I would say don't use MacPorts. People that use their operating systems version of RubyGems often end up with an out of date gem version and then run into problems when they try to update their version of rubygems. Installing Rubygems from source is easy, and it's not hard to install gems when you get a new machine, I mean how often does that really happen????
I just installed ruby 1.8.7 with macport and when I launch scripts with gems, it complains that it doesn't know them.
Anyway to add cleanly the gems in the path of my macport ruby?
Gam
PS: I installed the gems via system gem
What no one mentioned rvm?
Use rvm to manage all of your ruby issues - seriously!

Resources