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.
Related
I removed the previous version of ruby I installed, ruby 1.9.1 to be precise, on my Ubuntu, and installed version 2.2.3. When I try to run bundle install on my terminal, I get this error
bash: /usr/local/bin/bundle: /usr/bin/ruby1.9.1: bad interpreter: No such file or directory.
Can anyone advice on how to fix it?
How did you remove the old version of Ruby?
It looks like it left the binary executable for bundler, so I'm guessing you just straight up deleted the usr/bin/ruby folder? Ruby installations (and most installations) tend to create executable binaries in other folders that need to be deleted as well.
I would highly recommend that you use something like rvm or rbenv to manage multiple versions of ruby on your system. Those tools are designed to do that sort of thing and are basically industry standard at this point.
My personal recommendation is rvm, although either is really fine. If you choose to go with that, check out rvm.io for installation instructions.
It'll install rvm with the latest ruby version. In addition to that you are free to install any other version of ruby or patch that you prefer, and you can easily switch between the two using rvm use <ruby version>
This is a beginner-level question.
I'm using Ubuntu 12.04
I copied a project (created on Rails 4 using the rails new command) from Dropbox to my local environment, where I have previously install Rails 4 and up-to-date Ruby and RVM, went to project's directory, typed rails server and got
The program 'rails' is currently not installed. You can install it by typing:
sudo apt-get install rails
I ran gem install rails instead.
Will I have to run gem install rails on every project's directory? I thought the Rails install was a general and accessible on my whole environment.
The project was created using the same Ruby version, but on a MacOS X system.
The project is a static web brochure and has no database configuration.
Thank you in advance.
Make sure you're using the correct version of Ruby - the same version that you'd installed Rails into - with rvm list.
You likely have two of them (since you have such an issue) - the system Ruby and the RVM-installed Ruby. And likely RVM didn't engage and hook up the correct path to the rails executable, thus the error.
This should fix the issue:
rvm use whatever-ruby-you-had-installed-rails-into
Where whatever-ruby-you-had-installed-rails-into is a string like ruby-2.1.0-p0 taken from the rvm list output.
To make RVM retain Ruby version for the project.
echo whatever-ruby-you-had-installed-into >.ruby-version
in your project's path.
So after a few hours of testing, reproducing the problem, and reading (the other answers inclusive) I got the solution as follows:
Short answer: No. Rails needs to be installed only once.
Long answer: This problem occurred because of a default setting on Terminal that prevents the system from using RVM installations of ruby and rails. The solution is to integrate RVM with gnome-terminal as described in the RVM website.
With terminal window active, go to the menu at the top bar
Edit > Profile Preferences > Title and Command tab
Check the Run command as a login shell box
Restart Terminal and make sure your gemset and ruby version are set
rails server should now work as expected (you might be prompted to run bundle install before Rails can actually run fine, follow the promtp).
I am still learning to work with Ruby on Rails, so any inputs, clarifications, or additional information on the issue is more than welcome.
You don't have to install Rails on every project, but the gems that you need for that project.
With bundle install you install all the gems that you specify in Gemfile.
If you want to avoid reinstall the gems every time you change project, I suggest you to have a better look to RVM: it has got an opt called gemset (https://rvm.io/gemsets), if you use it you just need to switch your gemset:
rvm gemset use yourgemset
I hope it can help you.
As I have started using Linux (Ubuntu) to broaden my knowledge, but the flow for ruby (rails) development does not feel so smooth as on Mac OSX.
Do you use rvm to manage ruby gems in Linux?
One particular issue I face is that I could install rails with only sudo command. But this forces me to use sudo for all the time under my rails project.
P.S.
Might be I am missing some point with the way you do things in Linux so it is not related to ruby (or rails) at all.
It is preferred to use rvm. we can install ruby and rails without rvm as well, but we can have only one version at a time. You can find the instructions to install rvm from following link - rvm installation.
If you are the only person working on ruby rails, install in single user mode(doesn't need to go with sudo)
Installing ruby and rails only using superuser privileges means you're installing it from distribution packages. That's not recommended, and you get unneeded overload writting sudo before any rails command.
Install rvm or rbenv in your home directory and things should be smooth.
I am running my rails 3 project under ruby 1.9.2 with rvm. I use vim through zsh which was compiled using ruby 1.8 (the system ruby that comes with mac osx).
What's the best way to get these two ruby versions to match up?
Option 1: I can have rvm use ruby 1.8 but I don't want to be "stuck" on 1.8. Plus my 'bundle exec rails' commands don't seem to work with this option.
Option 2: Compile vim with ruby 1.9.2. But will this work ok?
I know using macvim compiled with 1.9.2 is an option but I really prefer the terminal vim.
You would try one of these:
You can use MacVim in Terminal. Just alias vim='mvim -v' if you already have mvim in your $PATH. I use this method personally, and I think it's the easiest way.
Compile vim yourself, with --with-ruby-command=[PATH TO YOUR RUBY 1.9.2] configuration option. I have not tried it on Mac OS; However in Ubuntu Linux I did --with-ruby-command=/usr/bin/ruby1.9.2 and it worked.
FYI: In Ubuntu they keep every program with version number separated and use update-alternatives to switch the default. The /usr/bin/ruby is just a symlink to the default one.
Rather than recompile vim, the easier solution is to change the /usr/bin/ruby symlink to point to your desired version of ruby. I use RVM / mac OSX leopard, and this worked for me.
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.