I am trying to start a new rails project and I would like to stick with rails 3.1.3. However, when I run the command rails new projectname I get the following output:
create
create README.rdoc
create Rakefile
create config.ru
create .gitignore
create Gemfile
create app
...
create config
...
create config/database.yml
create db
...
create public/robots.txt
create script
create script/rails
create test/fixtures
create test/fixtures/.gitkeep
...
create tmp/cache
create tmp/cache/assets
create vendor/assets/javascripts
...
create vendor/plugins/.gitkeep
run bundle install
Fetching source index for https://rubygems.org/
Using rake (0.9.2.2)
Using i18n (0.6.0)
Using multi_json (1.0.4)
Using activesupport (3.2.0.rc2)
Using builder (3.0.0)
Using activemodel (3.2.0.rc2)
Using erubis (2.7.0)
Using journey (1.0.0)
Using rack (1.4.0)
Using rack-cache (1.1)
Using rack-test (0.6.1)
Using hike (1.2.1)
Using tilt (1.3.3)
Using sprockets (2.1.2)
Using actionpack (3.2.0.rc2)
Using mime-types (1.17.2)
Using polyglot (0.3.3)
Using treetop (1.4.10)
Using mail (2.3.0)
Using actionmailer (3.2.0.rc2)
Using arel (3.0.0)
Using tzinfo (0.3.31)
Using activerecord (3.2.0.rc2)
Using activeresource (3.2.0.rc2)
Using bundler (1.0.21)
Using coffee-script-source (1.2.0)
Using execjs (1.2.13)
Using coffee-script (2.2.0)
Using rack-ssl (1.3.2)
Using json (1.6.5)
Using rdoc (3.12)
Using thor (0.14.6)
Using railties (3.2.0.rc2)
Using coffee-rails (3.2.1)
Using jquery-rails (2.0.0)
Installing rails (3.2.0.rc2) # WTF?
Using sass (3.1.12)
Using sass-rails (3.2.3)
Using sqlite3 (1.3.5)
Using uglifier (1.2.2)
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
I'd like everything to remain version 3.1. Why does the rails command automatically update itself to 3.2.0.rc2? How can I make sure that everything I do is using 3.1.3 versions of everything?
Thanks.
It is relatively little known fact that you can specify the rails version for a new application _like.this_
rails _3.1.3_ projectname
will work assuming 3.1.3 is installed (gem install rails -v3.1.3 otherwise)
This also works with rails 2 apps, i.e. pre-bundler and will create a rails2 looking application in these cases, e.g. rails _2.3.8_ projectname Again gem install rails -v2.3.8 if necessary (i.e. first time usage on that machine).
Longer term make sure you are using rvm (now a defacto standard) and you can use that toset your default rails (as well as ruby).
Removing the old version can be done with sudo gem uninstall rails -v 3.2.0.rc2
Related
This is an update for the problem mentioned below:
I just found out that there is a Gemfile and Gemfile.lock in the root directory i.e system Home directory, and when ever i create a new gemset i believe it uses this gemfile. After installing rails in a newly created gemset, when check the rails version or try to create a new app, it shows the error Your ruby version is 2.2.0, but your Gemfile specifies 2.1.5, cause the Gemfile file in my home directory contains that ruby version, and if delete that Gemfile, and try to create a new rails app, it searches for that Gemfile.
I am current going through a hard time. I was starting a new project in ruby 2.2.0 and rails 4.2.0 and started by creating a gemset using RVM inside my project folder.
created gemset.
$rvm use ruby-2.2.0#myapp --ruby-version --create
Installed latest rails
$gem install rails
After that i checked the rails version just to verify
$rails -v
but instead i get a notification saying Your Ruby version in 2.2.0 but your Gemfile specified 2.1.5. I also don't have my application folder yet, cause i get the same output if i try to $rails new .
Following are the RVM related outputs
My RVM version is 1.26.10.
rvm gemset list
gemsets for ruby-2.2.0 (found in /Users/samy/.rvm/gems/ruby-2.2.0)
(default)
global
student-portal
=> myapp
gem list for global gemset
bigdecimal (1.2.7, 1.2.6)
bundler (1.7.13)
bundler-unload (1.0.2)
executable-hooks (1.3.2)
gem-wrappers (1.2.7)
io-console (0.4.3)
json (1.8.2, 1.8.1)
mini_portile (0.6.2)
minitest (5.5.1, 5.4.3)
nokogiri (1.6.6.2)
power_assert (0.2.2)
psych (2.0.12, 2.0.8)
rake (10.4.2)
rdoc (4.2.0)
rubygems-bundler (1.4.4)
rvm (1.11.3.9)
test-unit (3.0.9, 3.0.8)
gem list for myapp gemset
actionmailer (4.2.0)
actionpack (4.2.0)
actionview (4.2.0)
activejob (4.2.0)
activemodel (4.2.0)
activerecord (4.2.0)
activesupport (4.2.0)
arel (6.0.0)
bigdecimal (1.2.7, 1.2.6)
builder (3.2.2)
bundler (1.7.13)
bundler-unload (1.0.2)
erubis (2.7.0)
executable-hooks (1.3.2)
gem-wrappers (1.2.7)
globalid (0.3.2)
hike (1.2.3)
i18n (0.7.0)
io-console (0.4.3)
json (1.8.2, 1.8.1)
loofah (2.0.1)
mail (2.6.3)
mime-types (2.4.3)
mini_portile (0.6.2)
minitest (5.5.1, 5.4.3)
multi_json (1.10.1)
nokogiri (1.6.6.2)
power_assert (0.2.2)
psych (2.0.12, 2.0.8)
rack (1.6.0)
rack-test (0.6.3)
rails (4.2.0)
rails-deprecated_sanitizer (1.0.3)
rails-dom-testing (1.0.5)
rails-html-sanitizer (1.0.1)
railties (4.2.0)
rake (10.4.2)
rdoc (4.2.0)
rubygems-bundler (1.4.4)
rvm (1.11.3.9)
sprockets (2.12.3)
sprockets-rails (2.2.4)
test-unit (3.0.9, 3.0.8)
thor (0.19.1)
thread_safe (0.3.4)
tilt (1.4.1)
tzinfo (1.2.2)
which ruby gives
/Users/samy/.rvm/rubies/ruby-2.2.0/bin/ruby
which rails gives
/Users/samy/.rvm/gems/ruby-2.2.0#myapp/bin/rails
the file contains
#!/usr/bin/env ruby_executable_hooks
#
# This file was generated by RubyGems.
#
# The application 'railties' is installed as part of a gem, and
# this file is here to facilitate running it.
#
require 'rubygems'
version = ">= 0"
if ARGV.first
str = ARGV.first
str = str.dup.force_encoding("BINARY") if str.respond_to? :force_encoding
if str =~ /\A_(.*)_\z/ and Gem::Version.correct?($1) then
version = $1
ARGV.shift
end
end
gem 'railties', version
load Gem.bin_path('railties', 'rails', version)
I tried removing and reinstalling RVM but i did not work.
Also i tried making app with ruby 2.1.5 with different gemset and all, but there i get different error when i try to do rails new app. i get the Could not find slop-3.6.0 in any of the sources
Run 'bundle install' to install missing gems., but once i do the bundle install i cannot run the rails new app command as it notifies
Can't initialize a new Rails application within the directory
of another, please change to a non-Rails directory first.
Any help would be greatly appreciated. If you need any more info i am ready to provide it.
Thanks in advance.
Cheers.
I had similar issues and restarting from scratch using this guide helped a lot. Though it seemed yet another guide, I found it to be a bit more systematic and detailed than the others.
Rails Apps Guide: Install Ruby on Rails ยท Ubuntu Linux
Alternatively, try Rails Apps Guide: Updating to Rails 4.2
Note:
Rails is not just a Ruby gem, it is a complex and rapidly evolving
ecosystem. It is important to set up your development environment with
the most current version of all the gems that are needed for
development.
I have updated my system to Mountain Lion, built a new version of Ruby and, as far as I know, reinstalled all my old gems. However, whenever I cd into an old app and run the bundle command it takes an age because it is re-installing gems I know that I have on my system:
Using rake (0.9.2.2)
Using i18n (0.6.0)
Using multi_json (1.0.4)
Installing activesupport (3.2.1)
Using builder (3.0.0)
Installing activemodel (3.2.1)
Using erubis (2.7.0)
Installing journey (1.0.1)
Using rack (1.4.1)
Using rack-cache (1.1)
Using rack-test (0.6.1)
Using hike (1.2.1)
Using tilt (1.3.3)
Installing sprockets (2.1.2)
Installing actionpack (3.2.1)
Using mime-types (1.17.2)
Using polyglot (0.3.3)
Using treetop (1.4.10)
Installing mail (2.4.1)
Installing actionmailer (3.2.1)
Installing arel (3.0.0)
Using tzinfo (0.3.31)
Any thoughts, suggestions or ideas of what to look for would be really appreciated.
My first answer, but I would suggest using RVM to manage ruby versions and gemsets.
Check out RVM
After that, just create a .rvmrc file that you can find examples online. The power of the .rvmrc is that it runs whenever you "cd" into an app with that file present. So it will set your RVM with the appropriate Ruby Version and the appropriate Gemset (with all your gems) and never have to worry about versions and gems being conflicted or overlapped or not there etc...
Question regarding mountable engines on rails. First of all these are the versions I am using;
$ rails -v
Rails 3.2.1
$ ruby -v
ruby 1.8.7 (2010-01-10 patchlevel 249) [universal-darwin11.0]
I create the mountable engine with this:
$ rails plugin new testEngine --mountable
create
create README.rdoc
create Rakefile
create testEngine.gtestEnginepec
create MIT-LICENSE
create .gitignore
create Gemfile
create app
create app/controllers/testEngine/application_controller.rb
create app/helpers/testEngine/application_helper.rb
create app/mailers
create app/models
create app/views/layouts/testEngine/application.html.erb
create app/assets/images/testEngine
create app/assets/images/testEngine/.gitkeep
create config/routes.rb
create lib/testEngine.rb
create lib/tasks/testEngine_tasks.rake
create lib/testEngine/version.rb
create lib/testEngine/engine.rb
create app/assets/stylesheets/testEngine/application.css
create app/assets/javascripts/testEngine/application.js
create script
create script/rails
create test/test_helper.rb
create test/testEngine_test.rb
append Rakefile
create test/integration/navigation_test.rb
vendor_app test/dummy
run bundle install
Fetching source index for http://rubygtestEngine.org/
Using rake (0.9.2.2)
Using i18n (0.6.0)
Using multi_json (1.1.0)
Using activesupport (3.2.1)
Using builder (3.0.0)
Using activemodel (3.2.1)
Using erubis (2.7.0)
Using journey (1.0.3)
Using rack (1.4.1)
Using rack-cache (1.1)
Using rack-test (0.6.1)
Using hike (1.2.1)
Using tilt (1.3.3)
Using sprockets (2.1.2)
Using actionpack (3.2.1)
Using mime-types (1.17.2)
Using polyglot (0.3.3)
Using treetop (1.4.10)
Using mail (2.4.1)
Using actionmailer (3.2.1)
Using arel (3.0.2)
Using tzinfo (0.3.31)
Using activerecord (3.2.1)
Using activeresource (3.2.1)
Using bundler (1.0.22)
Using rack-ssl (1.3.2)
Using json (1.6.5)
Using rdoc (3.12)
Using thor (0.14.6)
Using railties (3.2.1)
Using rails (3.2.1)
Using testEngine (0.0.1) from source at /private/var/www/html/development/projects/testEngine
Using jquery-rails (2.0.0)
Using sqlite3 (1.3.5)
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
when I use the rails command within the engine root (not in the dummyapp) I receive the following error:
$ rails -v
script/rails:7:in `require': no such file to load -- rails/all (LoadError)
from script/rails:7
this is my rails file in script/rails:
$ cat script/rails
#!/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/ems/engine', __FILE__)
require 'rails/all'
require 'rails/engine/commands'
The error indicates that the problem stems from the two rails includes at the bottom. Is there anything I can do to fix this? Without the ability to use rails I'm unable to make use of any of the tools the rails command gives me such as scaffolding etc.
Any help is appreciated, and should you need any more information please let me know.
Try this:
script/rails console
Or:
bundle exec rails console
I'm following the Getting Started with Rails guide, but I ran into a problem:
bash-4.1$ bundle install
Using rake (0.8.7)
Using abstract (1.0.0)
Using activesupport (3.0.3)
Using builder (2.1.2)
Using i18n (0.5.0)
Using activemodel (3.0.3)
Using erubis (2.6.6)
Using rack (1.2.1)
Using rack-mount (0.6.13)
Using rack-test (0.5.7)
Using tzinfo (0.3.24)
Using actionpack (3.0.3)
Using mime-types (1.16)
Using polyglot (0.3.1)
Using treetop (1.4.9)
Using mail (2.2.14)
Using actionmailer (3.0.3)
Using arel (2.0.7)
Using activerecord (3.0.3)
Using activeresource (3.0.3)
Using bundler (1.0.7)
Using thor (0.14.6)
Using railties (3.0.3)
Using rails (3.0.3)
Using sqlite3-ruby (1.3.2)
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
bash-4.1$ rake db:create
(in /Users/user/Documents/blog)
Could not find builder-2.1.2 in any of the sources
Try running `bundle install`.
bash-4.1$ bundle show builder
/Users/user/.gem/ruby/1.8/gems/builder-2.1.2
I also tried installing Builder as a RubyGem, but that didn't change a thing.
Try running it through bundle exec to make sure all of the gems specified in your Gemfile are available at their correct versions: bundle exec rake db:create
You can verify the installed gem is visible to bundle like this:
bundle show builder
/usr/lib/ruby/gems/1.8/gems/builder-2.1.2
I have the same problem though, bundle exec rake still fails to see the installed gem.
My version of rake (installed at /usr/bin/rake) was pointing at an old version of Ruby 1.8.
Modify the first line of rake to point at the correct version of Ruby. You can also clear out the bundle cache under the 'vendor' directory or move bundle to another local directory:
bundle install --path gems
On the command line, locate your default 'ruby' and 'rake' commands and check the version of Ruby:
which ruby
which rake
ruby -v
In /usr/bin/rake (line #1):
#!/opt/local/bin/ruby
I have very simple (in fact empty ) project which i have created by rails new MyProject command from command-line. So, i want to import it to NetBeans IDE. I click "new project" -> "RoR" -> "from existing source", select Ruby 1.9.2 (instead of embedded JRuby) in the wizard form. After that i have got errors [see the picture below]:
So.. i click OK. And then try to run the RoR application from NetBeans clicking on the run-button and i got the following error in the log-panel:
/home/ses/.rvm/rubies/ruby-1.9.2-p136/bin/ruby: No such file or directory -- script/server (LoadError)
So how to handle these two problems?
p.s. my application is working when i launch it from the console.
i use ruby-1.9.2 and RoR 3.0 and Netbeans 6.9.1 and Ubuntu 10.10
and, replying the comment to my question. yes, i performed following commands:
bundle install
Using rake (0.8.7)
Using abstract (1.0.0)
Using activesupport (3.0.3)
Using builder (2.1.2)
Using i18n (0.5.0)
Using activemodel (3.0.3)
Using erubis (2.6.6)
Using rack (1.2.1)
Using rack-mount (0.6.13)
Using rack-test (0.5.7)
Using tzinfo (0.3.24)
Using actionpack (3.0.3)
Using mime-types (1.16)
Using polyglot (0.3.1)
Using treetop (1.4.9)
Using mail (2.2.15)
Using actionmailer (3.0.3)
Using arel (2.0.7)
Using activerecord (3.0.3)
Using activeresource (3.0.3)
Using bundler (1.0.10)
Using mysql2 (0.2.6)
Using thor (0.14.6)
Using railties (3.0.3)
Using rails (3.0.3)
bundle pack
Using rake (0.8.7)
Using abstract (1.0.0)
Using activesupport (3.0.3)
Using builder (2.1.2)
Using i18n (0.5.0)
Using activemodel (3.0.3)
Using erubis (2.6.6)
Using rack (1.2.1)
Using rack-mount (0.6.13)
Using rack-test (0.5.7)
Using tzinfo (0.3.24)
Using actionpack (3.0.3)
Using mime-types (1.16)
Using polyglot (0.3.1)
Using treetop (1.4.9)
Using mail (2.2.15)
Using actionmailer (3.0.3)
Using arel (2.0.7)
Using activerecord (3.0.3)
Using activeresource (3.0.3)
Using bundler (1.0.10)
Using mysql2 (0.2.6)
Using thor (0.14.6)
Using railties (3.0.3)
Using rails (3.0.3)
Updating .gem files in vendor/cache
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
Updating .gem files in vendor/cache
and following this page http://wiki.netbeans.org/FaqRubyRakeFetchingFailed
i did rake -D
this is what I did to get it working (had same problem):
New project > with existing sources
Tools > Ruby Platforms > select Ruby 1.9.2-p136 > Gem Manager > New Gems > rails > install
restart netbeans
open project (if it's not already opened) and right click > bundler > install
run
first of all, what you should't do is expect the debugger to work. because it's not going to work on netbeans, not on rails 3 (there are some hacks but they have problems).
secondly, Ruby on Rails Support Discontinued in NetBeans IDE. I loved the way Netbeans worked with rails 2.x, but I migrated to RubyMine because of it's support for Rails 3
hope this helps