Rails 3.1 - rails not resolving (windows) - ruby-on-rails

I setup rails 3.1.0.rc5 on my friends vista machine last week. Everything installed and i can run an application we're working on just fine, however, the rails command does not resolve. To start the server, i had to do the old fashioned: ruby script/rails s style. He has the ruby bin on his path, as ruby -v resolves fine. Any ideas on what to check?
Note i downloaded a 1.9.2 installer from rubyinstaller.org, setup the dev pack, and installed rails through bundler.

It sounds like your path isn't pointing to your rails gem bin.
My first suggestion was going to be use rvm but since you're on windows that won't be an option. RVM suggested pik for windows users, and if it works similar to RVM, you'll save yourself a ton of headaches.

Related

Rubymine can't find Rails on osx

I've upgraded ruby with homebrew. Current version is 2.2.2. Installed Rails by gem. Version is 4.2.4.
Trying to build an empty rails project RubyMine stops soon saying
Can't run 'rails'. Can't find 'rails'.
I've tried both with RubyMine 7.1 and RubyMine Eap 8.
In the shell, obviously everything works perfectly. I think this happens because RubyMine uses ruby in /usr/local/Cellar/ruby/bin instead of /user/local/bin. I've tried to export "cellar" folder in $PATH, but that doesn't work. Any Ideas?
I think this happens because RubyMine uses ruby in /usr/local/Cellar/ruby/bin instead of /usr/local/bin
That sounds right. Each Ruby install has its own set of (global) gems. Make sure you have rails installed using the Ruby installed by Homebrew (not just the system Ruby).

After Setting Up Ruby Installer What Command line tools do you use?

I've installed Ruby on a Windows computer
After Setting Up Ruby Installer What Command line tools do you use?
http://railsinstaller.org/en
I've tried the command
rvm use 1.9.3
using the command prompt ruby and rails
I get the error message
rvm is not a recognised command
From RVM’s FAQ:
Does RVM work on windows? Will it in the future?
NO. If you would like to manage multiple versions of ruby on windows please use pik which is an excellent tool by Gordon Thiesfeld. You can find it on GitHub. There are plans to include windows support in RVM 2.0.
https://rvm.io/support/faq#does-rvm-work-on-windows-will-it-in-the-future
Doing Rails development on Windows is a little bit more of a challenge and you may run into some annoyances, but it's definitely possible.
Uru worked well for me as a nice alternative to RVM, which doesn't run on Windows. However, if you just want to have one version of Ruby installed on your computer and work with it, you don't even need to bother with Uru.
Windows is not the best environment to develop with Ruby ...
RVM doesn't work and PIK hasn't updated for more than 2 years..
Github of Pik
This installer doesn't install RVM. It installs Ruby interpreter and Rails.
Since you've installed it, I assume you have your Ruby and libraries for it (called gems) rails and bundler. Execute gem list in your shell to verify (it should output a looong list).
Then you should create a new Rails project:
rails new project_name
...and then go into the folder that got created
cd project_name
bundle what you have:
bundle install
...and launch the server to see if it works:
rails server
or
rails s
You will likely run into issues with tzinfo gem if you're on 64-bit Windows, but that can be easily fixed by searching around StackOverflow, it's been discussed.
Gool luck to you. Developing Rails applications in Windows proved to be hard to me. Consider launching a virtual machine (using, for example, VirtualBox) with Linux aboard. That's what you could do in Linux:
install RVM as the site suggests:
curl -sSL https://get.rvm.io | bash -s stable
install the latest MRI available - feel free to replace ruby with the version you need, like rvm install 2.0.0
rvm install ruby
select and set as default the Ruby you need, you've tried a similar line apparently with Ruby 1.9.3
rvm --default use ruby
another long process
gem install rails
rails new project_name
(same as described above)
cd project_name
bundle install
rails s
That should work, and that's what you've probably seen. Again, I highly recommend using Linux in VirtualBox (or anything similar) for Rails development. A native Linux installation could only be a better environment, but most people are not ready for this just yet.

Getting Rails 1.1.2 server running on Mac script/server

So I'm a rails developer familiar with Rails 3 and 4. I'm taking on a Rails 1.1.2 project, and the first problem I'm having is getting the server running.
I'd really love some help figuring out what I'm missing setting up the environment. When I run script/server, I get:
-bash: script/server: /Users/michael/.rvm/gems/ruby-1.9.3-p545: bad interpreter: Permission denied
This is after noting that at the top of the script/server file, there's an opportunity to define the location of the ruby install with a ruby comment:
#!/Users/michael/.rvm/gems/ruby-1.9.3-p545
At least, this is how I understand it. What should this comment point to? Does this look correct? I've installed ruby 1.9.3 using rvm and installed rails V 1.1.2 through sudo gem install rails. Everything seemed to work fine.
Is this some kind of bash permissions issue? I really don't understand what's going on. Any help would be appreciated!
I believe a rails project that old will require Ruby 1.8.7, so you should start with an older version of Ruby just to be sure. Once you get it running with the older ruby version, you can try 1.9 again, but trying it with 1.8.7 should help you out a bit. Your shebang should be able to do this though:
#!/usr/bin/env ruby
It needs the path of the ruby interpreter, which can be obtained dynamically via the above line.

rails is not found when trying to start a new rails project

I just installed Eclipse, then Ruby 1.9.2 then RailsInstaller. I then installed Aptana plugin for eclipse.
My directory setup are as follows:
C:\Ruby192
C:\RailsInstaller\Ruby1.8.7
When I create a new rails project in Eclipse, It throws this error:
LOL#LOL-PC /d/Projects/rail
$ rails .
sh.exe": rails: command not found
I found this solution, but it seems its for linux. I'm using Windows 7.
I reinstalled rails and ruby but its the same thing. I also had installed GitBash and GitExtensions a few months ago and had this problem. I solved it by pointing to the directory where Git was and setting the Default environment to HOME.
I now have no idea what to do to use ruby on rails in this error.
Add the place where you installed rails to your PATH environment variable. (Presumably C:\Ruby192\lib\ruby\gems\1.9.1\gems\rails*\bin)
I also noticed you are using the RailsInstaller for ruby 1.8.7 but seem to have installed ruby 1.9.2. This may cause trouble in the future.
Try following this guide for installing rails on windows. It uses gem install instead of the out dated RailsInstaller.

Ruby & Rails installation on a Mac

I used railstutorial.org to install the latest version of ruby and the latest version of rails on my machine.
at the end of the installation I checked
ruby -v ==> 1.9.2 (great)
rails -v ==> 3.0.1 (great)
this morning I opened up terminal
ruby -v
ruby 1.8.6 (2009-06-08 patchlevel 369) [universal-darwin9.0]
rails -v
Rails 1.2.6
what happened?
My advice for people who are installing ruby is to use RVM. It makes managing your ruby versions and gem versions really simple and you can install multiple ruby versions side by side.
You might want to read this post:
http://rubylearning.com/blog/2010/12/20/how-do-i-keep-multiple-ruby-projects-separate/
You can use Cinderalla to the whole ruby/rvm/mysql/redis/git/... stack set up properly. Cinderella installs everything in ~/Developer and fixes up your PATH as well. I had some issues with a corrupt git mirror last time I used Cinderalla though so YMMV.
With many unix variants, you are likely to have multiple versions of Ruby--particularly if you installed Ruby 1.9 and the system already had 1.8 installed. Essentially, the 1.8 version of Ruby has a higher precedence in your PATH than the 1.9 version. The Ruby Gems command keeps the libraries separate between 1.8 and 1.9 so that the platform will be reasonably stable.
To correct the problem, you have to find where ruby 1.9 is installed. Once you do that, you'll need to override your PATH variable. Assuming 1.9 is installed in the path: /opt/ruby-1.9.2, you will need to set your PATH like this:
PATH=/opt/ruby-1.9.2/bin:$PATH
export PATH
To make the path respect what you want every time, add that to your ~/.profile file (create it if necessary). Once the path has been set, it sould be able to find the correct version of Rails again.
I cannot say for certain because I cannot debug you OSX machine from here, however, I had a very similar occurrence. The problem was caused because I had installed ruby and then rails on my machine using sudo or from the root account. Then when I discovered rvm I installed everything in my user account. When I logged off and back in I appeared to lose everything. I was pulling out my hair. I was pissed that I was going to have to reinstall everything again... when I found the magic.
from the command line execute the command:
rvm list
you'll see that your new version of ruby is there. you'll also notice the tokens that indicate that it is just a normal version. It is not current or default. (see it yet)
Now if you run the command:
rvm use 1.9.2 --default
then every time you login/off and restart your machine your user account will default to that version of ruby and all of the gems that you installed against that version.

Resources