Im about to start work on another web application, I change directories to
/rails_projects
and enter
rails new blank
I then get this error
Error: Command not recognized
Usage: rails COMMAND [ARGS]
The common rails commands available for engines are:
generate Generate new code (short-cut alias: "g")
destroy Undo code generated with "generate" (short-cut alias: "d")
All commands can be run with -h for more information.
If you want to run any commands that need to be run in context
of the application, like `rails server` or `rails console`,
you should do it from application's directory (typically test/dummy).
I have reinstalled rails, and still same error, any ideas?
UPDATE:
It actually give me the same error when I type just
rails -h
rails
in cmd
For anyone with a similar error that may land here, this fixed it for me:
rake rails:update:bin
This will generate "new" versions of the binaries. Just say Yes when it inquires you to replace them.
I ran into a similar issue when trying to upgrade a Rails Engine from 3.2 to 4.1.
The culprit was the presence of script/rails which contained:
#!/usr/bin/env ruby
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
ENGINE_ROOT = File.expand_path('../..', __FILE__)
ENGINE_PATH = File.expand_path('../../lib/my_project/engine', __FILE__)
require 'rails/all'
require 'rails/engine/commands'
The problem line is there at the end: require 'rails/engine/commands. That was not allowing the full Rails CLI to load which omitted the new command. Removing that file solved my problem.
I'm pretty sure this wasn't the cause of your specific problem, but the symptoms were the same as mine and this was the first link in Google for the error message. Just passing along my findings to help anyone else that runs into this same situation.
It looks like the rails command believes it's inside of a rails engine, which is why a different set of commands are available to you. Notice the 'commands available for engines' text. New is not a command available for engines. I'm not sure why rails thinks the directory you're in is an engine, but likely your directory structure is mixed up somehow.
If anyone runs into this error and needs a last resort plan.
I ended up uninstalling rails, rvm, and installing a newer version of ruby and new gemset.
rvm implode
gem uninstall rails -v=4.0.2
gem uninstall railities
install rvm :
curl -L https://get.rvm.io | bash -s
rvm get stable
for mac:
brew install libtool libxslt libksba openssl
brew install libyaml
install ruby:
rvm install 2.0.0 --with-openssl-dir=$HOME/.rvm/usr
if you have error
rvm install 2.0.0 --with-openssl-dir=$HOME/.rvm/opt/openssl
install new ruby gems from website. Unpackage it then go to folder and run
ruby setup.rb
gem update --system 2.1.9
install rails (you can choose your version)
gem install rails --version 4.0.2
gem install railties
I did this, and now system is working normal again.
Create another directory and run $ruby -v, check which version is available. Now run rails new app_name. Try once after closing the terminal and restarting.
This happen to me when a require error occurred in a gem (dependency) while loading.
Related
Running OSX Mavericks, ruby 2.1.1p76 (2014-02-24 revision 45161) [x86_64-darwin13.0], rvm 1.25.23 (master), and rails-4.1.0 (allegedly)
I'm working through the railsapps.org book on learning rails and made it about 1/2 way through yesterday. When I stopped for the day, I closed out iTerm2 and shut off the Macbook Pro. Today, I powered up, opened iTerm, navigated to my working directory (~/rubyonrails/learn-ruby) and entered rails -v.
I see this:
`Rails is not currently installed on this system. To get the latest version, simply type:
$ sudo gem install rails
You can then rerun your "rails" command.`
So I run sudo gem install rails and it shows that it has installed rails-4.1.0. Now rails -v still gives me the same error message above.
I tried also running rvm use ruby-2.1.1#learn-rails first and I still get the error message.
So I'm a little stuck and I can't figure out what to do to get rails working. Also, how do I go about setting up the bash environment such that I don't have to go through this each time? It would be nice to nav to my working directory and just start work without having to do a bunch of re-installation and reconfiguration each time.
Regards,
Jeff
please type in your shell:
$ bash --login
and then repeat your commands.
rails -v
Also try to call it with the full path:
like:
/your/path/to/rails -v
I think that the shell just doesn't know where rvm/rails etc is located.
You can solve this by entering:
$ source ~/.rvm/scripts/rvm
When you switch to the ruby-2.1.1#learn-rails ruby/gemset combo, and do gem list, what do you see?
The way people usually use rvm is to have every project folder specify the ruby & gemset it uses (they don't all have to be different). This is done with files called .ruby-version and .ruby-gemset. These should contain, in your case, ruby-2.1.1 and learn-rails respectively.
Set these if you haven't already, then leave the folder and enter it again. Then do bundle install to install the gems for the project into the rvm/gemset combo.
Your problem is that you ran
sudo gem install rails
The error message telling you to do this comes from your system Ruby, which doesn't know that you want to use RVM.
RVM installs gems into your user-space directory. By using sudo, you're bypassing this and installing it into (effectively) the superuser space, i.e. globally.
If you instead just run
gem install rails
then you'll be using RVM's copy of the gem utility rather than the globally installed version.
I am trying to run a
rails new demo
But am told:
Rails is not currently installed on this system. To get the latest version, simply type:
$ sudo gem install rails
You can then rerun your "rails" command.
I run that command, and many 'fetching' lines followed by many 'Installing RDoc documentation for...' are run, but then the last lines say:
Installing RDoc documentation for rails-3.2.13...
file 'lib' not found
and then it stops running, and the 'rails' command (see above) doesn't work still. Why is Rails not installed? What else should I do? Thanks
Looks like this is rdoc related. Short version, try :
gem install rdoc
And then launch the install of rails again.
Look at this answer that seems to have helper a lot of people with this exact problem.
I solved it: apparently I was trying to install rails in the directory. I did the following and it worked well:
cd /
Then I ran
sudo gem install rails
Then I cd into the relevant directory again and now
rails new demo
worked!
It's not a good idea to do a 'sudo gem install rails' since you may experience permission problems with your applications in the future.
I would recommend you using RVM which is a ruby version manager. You can easily install different versions of Rubies, you can create application specific gemset's and minimize possible futuristic 'rails is not currently installed' errors.
I highly recommend you searching and reading about these concepts:
RVM
Gemsets
.rvmrc
.bashrc and .bash_profile
I'm working on Bluehost. I installed the 3.2.8 gem of rails, and now I get this:
> gem list --local | grep rails
rails (3.2.8)
But:
rails --version
Rails 2.3.11
How can I make the "rails" command use the latest gem? I guess it has something to do with my $PATH variable but I'm pretty much clueless about it.
Also, the gem and rails command give rise to some errors that look like this:
Invalid gemspec in [XXX]: invalid date format in specification: "YYY"
I'm not sure if that's connected (and I'm wondering what causes such errors anyway).
Try running this command:
curl -L https://get.rvm.io | bash -s stable --ruby --rails
What it does is install RVM, which maintains separate gems for each version of Ruby installed. The --ruby and --rails arguments tell it to install ruby and rails while installing RVM. RVM installation automatically updates $PATH and any other necessary environment variables.
At the end of installation, it should prompt you to run:
source ~/.rvm/scripts/rvm
which will make those environment variable changes effective immediately. Alternatively, you can log out and then log right back in.
Run rails -v and ruby -v at that point, and you should see them pointing to the new version. Run bundle install from your RoR app's directory and all the gems you need should install in ~/.rvm/gems/ruby-/gems.
At that point, you can delete/uninstall any gems/rails/ruby from before installing RVM.
EDIT on 10/17/2012:
Nevermind my answer. Even though it might be possible to get Rails 3.x running with the currently installed Ruby 1.8 (see this Stackoverflow question), you won't be able to run Ruby 1.9.x using Bluehost Shared Hosting. Your only choice (for now) is VPS Hosting.
The reason is that Passenger Phusion is tied to the version of Ruby installed in /usr/lib, which you can't change without root access. Even though you can install any version of Ruby with RVM, you won't get Passenger to talk to it and therefore your rails project won't use its gems.
I've installed rails using rvm and everything works well in the out of the box terminal using zsh. I thought i'd simplify things a bit and bring out Coda's terminal but for some reason when I run
$ rails --version
I get errors saying there are missing dependencies or when using $ rails new new_app Coda terminal tells me that rails isn't installed. running $ gem list and $ gem environment give me the same output in both terminals.
you need to load rvm before using it
load rvm script with
source ~/.rvm/bin/rvm
Hi there thanks for looking into this.
after a clean install of Linux ubuntu 10.10 i tried to re-install rails.
after doing sudo gem install rails, I can see I am returned version 3.2.3 of rails
But after generating a new project i couldn't find my gemfile so i tried ruby -v which returns 2.3.4 wich is odd since I know I got the latest.
Also when trying sudo gem update --system I get an error because I might override system files. any solution here?
I'd recommend using rvm to manage your ruby sets -- as well as defining gemsets for each project that will allow you to make sure each project has just the gems it needs.
Here's a link to the rvm installation instructions (they should work with ubuntu):
https://rvm.io/rvm/install/
Here's some info on basic use of gemsets with rvm:
https://rvm.io/gemsets/basics/
Also, when using rails 3+, you should make a practice of typing bundle exec rails -v -- that way you'll use the gems defined for the project you're in.
Can you try typing bundle exec rails -v and letting us know what you see?