rake, Could not find rails - ruby-on-rails

first of all I'm really not really friendly with ruby or with rails, so I got few issue when i try to install redmine.
In fact i have to type a rake commande :
rake generate_session_store
And server answers me :
"Could not find rails (=2.3.14) amongst [actionmail-2.3.11, actionmailer-2.3.5, actionpack..."
So i checked my rails version and i see that I got 2.3.11, I update it with gem, retry rake but the same error happends, I check again my rails version.
Suprise ! It's still 2.3.11.
I'm running on debian 6 with ruby 1.8.7, gem 1.8.19
What should i do ? Thx.

Have you tried this ?
gem install rails -v 2.3.14

Related

rails console fails with `Switch to inspect mode` in windows

I create a rails project by rails new foo, then cd foo, and run rails c.
Then I got message like this.
DL is deprecated, please use Fiddle
Loading development environment (Rails 4.0.2)
Switch to inspect mode.
That's all. I can't use rails console.
Have you any idea what am I doing wrong?
I'm using railsinstaller with ruby 1.9.3 and 2.0.0 both, and ruby 2.0.0p451 (2014-02-24) [i386-mingw32] from Rubyinstaller. All versions fails with same error.
There is no problem with simple irb command.
Edit
By following Graeme's advice, I updated rb-readline from 0.5.0 to 0.5.1. and uninstalled old one.
$ gem list | grep rb-readline
rb-readline (0.5.1)
But the message remains same.
In case anyone gets this error with Docker, I got it because I ran docker run rails but needed -it.
> docker run rails
Switch to inspect mode. # fail
> docker run -it rails
irb(main):001:0> # yay
This is a known problem caused by the rb-readline gem in version 0.5.0. It has been subsequently fixed in 0.5.1 which came out a few months ago.
You should therefore upgrade the rb-readline gem to v0.5.1 to fix this problem.
You can see here more details about the issue and the resolution.

Can't boot WEBrick, the folder for Rails gem is empty

I'm following Michael Hartl's Ruby on Rails tutorial, and I got stuck at trying to start rails server on my Windows 7 machine.
I'm trying to do this by following instructions in Chapter 1.2.5., i.e. by typing
rails server
However, instead of booting WEBrick, this returns the instructions for usage of 'rails' command. I've been googling this for a while, and some of the answers seem to have implied that something is wrong with the rails gem.
Now, I've found the rails gem folder ("C:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\rails-3.2.3"), and it's empty!
Also when I try
rails -v
it returns "Rails 3.2.16", although I've removed this version of the gem; if I try
gem list
it kept telling me that the version is 3.2.3.
This persisted until I deleted railties version 3.2.16, which resulted in
rails -v
returning 'Rails 3.2.3', but I still can't boot WEBrick.
Any help would be appreciated.
Did you run the installer?
At the time of this writing, I recommend using the Ruby 2.0.0-p353.
http://dl.bintray.com/oneclick/rubyinstaller/rubyinstaller-2.0.0-p353.exe?direct
Save yourself some future gem headaches and install the DevKit too.
http://rubyinstaller.org/downloads/
It should create a folder at C:\Ruby200. Start a new command prompt for the new paths to take affect.
Once Ruby is install, gem install Rails. From your other post, I recommend gem install rails -v 3.2.16
Then execute rails new project_name, then cd project_name. Then run rake db:migrate to create the initial database. At this point, you should be able to run rails server and visit localhost:3000 in your browser.
OK, I've managed to solve my problem.
I've seen a few more people having the same issue, but none of the solutions that I've found helped me, so here's what did it for me, though I'm not 100% sure what exactly was that one thing that actually did it...
I've followed the advice #scarver2 gave in response to my other question, and uninstalled both Rails and Railties gems from my crispy fresh installation of Ruby 1.9.3. (I've installed it using RailsInstaller). Then I've installed Rails 3.2.16 gem by typing
gem install rails -v 3.2.16
and this also installed the corresponding Railties 3.2.16 gem without my intervention.
Then I followed steps from chapters 1.2.3. and 1.2.5. of the tutorial, but making sure that line referencing ruby version in my Gemfile actually corresponds to the version of Ruby that I have installed.
I typed
ruby -v
in the console, to make sure that I have version 1.9.3. indeed. Confirming this, I've edited the Gemfile in my app so it says
ruby '1.9.3'
instead of ruby '2.0.0' line that's used in Listing 1.5. of the tutorial.
After that I've simply went to my app folder, and typed
bundle update
bundle install
in the console, and this time it did not return any errors as it did in my previous attempts. After that, typing
rails server
did what it should have, and my WEBrick server booted, allowing me to access my app on localhost. Yay!
Now, what I think may have gone wrong the last time was either me screwing up the Gemfile, so the gem versions and their dependencies got messed up. I also assume that ineptly trying to fix this by installing and uninstalling different versions of various gems did not quite help. What may have helped was uninstalling Rails and Railties gems, and installing Rails gem again.

'rails s' throwing error

I am configuring a Rails APP. I did bundle install properly. Also using ruby 1.8.7 using RVM. Now after bundle install, it is throwing the below given error while doing rails s.
/usr/local/lib/site_ruby/1.8/rubygems.rb:335:in `bin_path': can't find
executable rails for rails-3.2.9 (Gem::Exception)
Can anyone help me to sort out this?
Using ruby: 1.8.7
Rails Version: 3.0.3
After running bundle install, your Gemfile.lock has a list of all the gems and their versions that are needed.
However, you need to run bundle exec in order for bundler to make those gem versions available to you.
The rails script is an exception, as it invokes bundler for you, but it sounds like something isn't working in your environment.
Try executing the rails script using bundle exec like so:
bundle exec rails s
And see if that helps. Also, from the man who wrote bundler: http://yehudakatz.com/2011/05/30/gem-versioning-and-bundler-doing-it-right/
You have two rails gem versions in same gemset so it is picking latest version. So you need to specify rails version for rails commands.
Try this:
$ rails _3.0.3_ server

Rails Server Error: Ruby version is 1.8.7, but your Gemfile specified 1.9.3

I entered a existing ruby application, and type:
$ rails s
wanted to start rails server here.
but it said:
Your Ruby version is 1.8.7, but your Gemfile specified 1.9.3
Actually, I had a 1.8.7, but I deleted it. And if I do:
$ ruby -v
it said:
ruby 1.9.3p286 (2012-10-12 revision 37165) [x86_64-darwin11.4.2]
So I don't know how can I fix it. Can you give me a help?
If you are using rvm, run this:
$ rvm use 1.9.3
try using bundler
bundle exec rails s
I had similar problem:
$ bundle install
Your Ruby version is 2.1.0, but your Gemfile specified 1.9.3
but:
$ ruby -v
1.9.3-p484
$ which ruby
/home/malo/.rvm/rubies/ruby-1.9.3-p484/bin/ruby
I've found five answers: 1, 2, 3, 4, 5. Also it was open issue on github. However, I've resolved the problem as follows:
Got path to my bundler:
$ which bundle
/home/malo/.rvm/gems/ruby-1.9.3-p484#global/bin/bundle
Opened it to edit (or just cat it), and saw that it has invalid link to ruby in the first line:
$ cat $(which bundler)|head -n 1
#!/home/malo/.rvm/rubies/ruby-2.1.0/bin/ruby
Then I get the path to current valid ruby, and just replaced that invalid with it:
$ which ruby
/home/malo/.rvm/rubies/ruby-1.9.3-p484/bin/ruby
Of course you can also try replace it with the common form:
#!/usr/bin/env ruby
This should pick up the currently used ruby version.
I found out the reason I was getting this error was that I was shelling out to a Heroku command line program inside of my configuration files and Heroku Toolbelt comes with it's own version of Ruby.
The two solutions to that problem are to either not shell out to Heroku or use a Bundler.with_clean_env block instead of the backticks to shell out the heroku command.
Please try this:
1. Open your gemfile
2. Specify rails version
3. Run bundle update
4. Run rails server - rails s
Every now and then this happens with me. However I often don't like switching ruby versions here and there. So instead what I do is I just go to the Gemfile and switch the ruby version to the one that I am using. Doing this allows me to fire up my server and keep working on things.
so for instance, right now for the app i'm working on, my Gemfile is at
ruby ENV["CUSTOM_RUBY_VERSION"] || "2.1.6"
and I would just alter it to
ruby ENV["CUSTOM_RUBY_VERSION"] || "1.9.3"

How do I upgrade from Rails 2.3.5 to Rails 2.3.8?

I've got a Rails 2.3.5 app that I want to upgrade to Rails 3. In the Rails 3 upgrade Railscast, they suggest upgrading to 2.3.8 before going to 3. I've tried Googling but the information I find is all about upgrading to Rails 3. I found this question, which seems to suggest doing gem update rails and rake rails:update, but wouldn't these commands upgrade to Rails 3, as it's the latest version? How do I upgrade to Rails 2.3.8? Thanks for reading.
There's not much difference between 2.3.5 and 2.3.8 (also, 2.3.10 is the latest version on the 2.3 branch - you should upgrade to that).
Install Rails 2.3.10:
gem install rails -v=2.3.10
Then edit config/environment.rb and change your Rails version to 2.3.10 near the top of the file. Start up webrick, deal with any deprecation warnings it throws at you while you click through your app, and you're pretty much done.
Citation from the Rails blog:
"We’ve released Ruby on Rails 2.3.9
(gem and git tag) to extend the 2.3.8
bridge a few steps closer to Rails 3
and Ruby 1.9. If your app runs on
Rails 2.3.9 without deprecation
warnings, you’re looking good for an
upgrade to Rails 3."
Edit:
Jeremy is on the money. Don't install 2.3.9, it has a serious security flaw. I've updated my answer to 2.3.10.
You can run rake rails:update - this updates the stock javascripts and config files. However, they probably won't need to be changed from 2.3.5 to 2.3.10.
$ gem install rails -v 2.3.8
Then change the RAILS_VERSION in your environment.rb file and run
$ rake rails:update

Resources