Rails command not working on Windows command line - ruby-on-rails

I installed Ruby and Rails and set-up the PATH to "C:\Rails\Ruby2.3.0\bin", but when I try to run commands with rails, I get the error message:
The System cannot find the path specified.
I am able to run commands using ruby, and rails works if I use GitBash. How do I make it work on my normal command line?

Had the same problem here, installed the same way. Couldn't even run rails commands on GitBash, only way was going in C:\Rails\Ruby2.3.0\binthrough cmd and typing, for example, ruby rails new projectname. The rails new projectnamewouldn't work even in these conditions.
What I did was going in the Command Prompt with Ruby and Rails and entered gem install rails (which did not work on cmd). I also did gem install bundle. Both installed successfully and that fixed all consoles for me: cmd, GitBash (wasn't working for me), Command Prompt with Ruby and Rails and even cmder works with Rails now.
Hope this helps you.
Cheers.

If it's a simple question of locating the rails executable on Windows, then on later installs that use msys64 instead of DevKit, you'll find rails at the following folder:
c:\msys64\o-rdoc
Add this to your PATH or execute from that folder.
Your path may vary on 32-bit systems or if you changed the default install folder.

Related

copies a rails app to a new computer: rails command not found

I have just set up ruby and rails on a freshly installed freeBSD. It works great. I can do rails new blabla mv into blabla and do rails s and it just works.
I had an up and running rails app on another computer. I copied the repertory that contained the app to the new computer running freeBSD. However, when I mv into that repertory of the rails app and to rails server I get -bash: rails: command not found
I have tried creating a new app with the same name and let rails create all the repertories and then copy the files of the existing rails app therein but no success.
I can run rails -v and rails s from within any repertory and get correct answer, but when I move into that specific repertory I get that command not found.
You're probably using a ruby version manager I suspect (rbenv/rvm)? Check the ruby version in your Gemfile (top of the file). It probably isn't the same as the ruby version you have installed. If you're using one of the above mentioned version managers than install the correct ruby for your rails project. After that you can do a gem install bundler in the project directory and after run bundle install which will install rails and all dependencies.
Which version you are using? It happens with earlier versions. Try updating your gems and bundler. And try again. Hope it helps.
Did you try running bin/rails s? I think tha you need run bundle install too.

Do I have to install Rails on every new project?

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.

How to find my rails path?

I have rails 3 installed with rvm and today i tried to add the alias 'subl' (from Sublime Text 2) to use on terminal. The problem is the 'subl' command works and i think i messed up with the paths, because the rails command is not found anymore.
How do I find the correct rails path and fix this problem?
Thanks in advance.
Depends on your setup. If you're using rvm, it will probably be
~/.rvm/gems/<ruby version that you use>/bin/rails
If you're using the system ruby, then have a look in the gems folder of wherever your ruby install is, and add that to the path. On windows, the ruby installer generally puts it in
C:\Ruby
Or something like that. On Mac, the default system ruby is
/usr/bin/ruby

Aptana Ruby on Rails Problem, rails: command not found

I installed Aptana Studio 3 and attempted to create my first Rails file, only to receive the error
sh.exe: rails: command not found
Am I supposed to edit my System Variables to include the Path? If so, where the heck is rails.exe because I cannot find that directory.
Based on your "sh.exe" filename, I am assuming you are running Windows. You will need to verify that the command "rails" is accessible in your system path so that Aptana can find it. Do this by modifying the "PATH" system variable to include the directory to your Ruby installation (this may require a restart to take affect).
Instructions for modifying the system path can be found here: http://www.computerhope.com/issues/ch000549.htm
If you used an installer of Ruby packaged for Windows such as Railsinstaller, point to the path of this installation. Gems will place executable files in the "\bin" folder. The "rails" executable is a script from the rails gem.
I have the same problem and I have solved it. I am using Windows 7 with Aptana Studio 3. The problem is that actually Rails is not installed on my Computer after I installed Aptana Studio 3.
Basically I follow the instructions given by this website
First you need a ruby installer for windows. After installation, Click on Start Command Prompt with Ruby from Start->All program->ruby folder and type gem install rails in command line and you are done. Wish that you can solve your problem as well.
Aptana Studio 3 does not install rails for you by default. You will need to download a rails installer as mentioned here:
http://wiki.appcelerator.org/display/tis/Rails+Development

Rubymine doesn't detect Imagemagick install?

I just installed Rubymine, and Imagemagick through the terminal for use with Rails Papercilp. For some reason if I run the Rails server through terminal everything works, but if I run the server through Rubymine, it says Imagemagick is missing.
Anyone have any thoughts? I've been trying to figure out this config issue for hours now.
It is most likely that imagemagick is not in your PATH in Rubymine. The Rubymine environment is different from shell. See http://devnet.jetbrains.net/docs/DOC-1160;jsessionid=1858A969645F39423219A415388AF557 for how to do this.
probably, not the best way to handle it in general, but quick-n-dirty solution is
from terminal:
$ rvm use [environment#you_want]
(or just cd into ruby app folder if you use .rvmrc)
$ open /Applications/RubyMine.app
(or any other valid path to RubyMine installation)
this will load all necessary environment...
cheers

Resources