I'm trying to create a new rails 4 app with this system setup:
OSX Mavericks
zsh
rvm 1.23.13
bundler 1.3.5
ruby 2.0.0-p247
I've installed bundler and rake in the global gemset for ruby 2
After I have installed rails 4 in the gemset I execute
rails new testapp
I get the the error:
Looks like your app's ./bin/rails is a stub that was generated by Bundler.
All of the references to this I've found are in relation to upgrading 3.2 to 4. I'm wondering if anyone has any suggestions in this situation.
The full sequence is in this gist
is it possible that ~/dev/eit is already an rails application?
try this:
mkdir -p ~/dev
rails new rails4app
cd rails4app
Related
I have rails 5 installed on my machine, but now I want to create a rails 4 app.
I use this code: rails 4.2.6 app_name
But these errors come out:
/home/jeff/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/dependency.rb:319:in to_specs': Could not find 'railties' (= 4.2.6) - did find: [railties-5.0.0.1] (Gem::LoadError)
Checked in 'GEM_PATH=/home/jeff/.rvm/gems/ruby-2.3.0:/home/jeff/.rvm/gems/ruby-2.3.0#global', executegem envfor more information
from /home/jeff/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/dependency.rb:328:into_spec'
from /home/jeff/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_gem.rb:65:in gem'
from /home/jeff/.rvm/gems/ruby-2.3.0/bin/rails:22:in'
from /home/jeff/.rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in eval'
from /home/jeff/.rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in'
Hope someone could help me
It looks like you are using RVM. So if I were you I would create a new gemset and install whatever version of Rails you want to work with.
For example
$ rvm gemset create new_gemset
$ rvm gemset use new_gemset
$ gem install rails -v 4.2.6
Now you should be able to create a new rails app with your rails new app_name command.
following http://railsapps.github.io/installrubyonrails-mac.html , I encounter the following commands
rvm use ruby-2.1.3#rails4.1 --create
gem install rails # installs the latest rails version
rails -v # returns 4.1.6
however, I can also do the following, which would add rails version to 4.0.8
rvm use ruby-2.1.3#rails4.0 --create
gem install rails --version=4.0.8 # installs the latest rails version
rails -v # returns 4.0.8
What is the point of this? Somewhere in the text it's said that this method is to prevent global gem-set and instead install rails based on project-specific gemsets? What does that even mean?
And this is the instructions on how to create a new rails project
$ mkdir myapp
$ cd myapp
$ rvm use ruby-2.1.3#myapp --ruby-version --create
$ gem install rails
$ rails new .
why not just call rails new myapp? The text says it's to "create a project-specific gemset", but I have no idea what that means. Wouldn't this just install rails 4.1.6 (newest version) ? why not just install rails 4.1.6 globally in the first place then?
Imagine you are a Rails developer in a company that has been doing Rails apps for the last 4 years. You have apps on Rails 2, Rails 3, Rails 4 - as new versions come out, you upgrade your toolset because, why not? Each new version is better.
However, they are not downward compatible. The Rails 2 app will not work with Rails 4.1. What if you are asked to urgently debug the Rails 2 app while hacking on Rails 4 one? Uninstall global Rails, install Rails 2, make the hack, then uninstall Rails 2 and reinstall the new one again, just so you can run the tests for your one-line bug fix?
That's where gemsets come in. You have environment per-application so that each application can be run self-sufficiently, with no versioning conflicts.
If you don't envision such scenarios of version conflict on your machine (i.e. if you can only imagine working on one project), gemsets are completely irrelevant.
EDIT after some confusion still in comments :) Let's go step by step, see what happens exactly.
$ mkdir myapp
$ cd myapp
You're now in an empty directory.
$ rvm use ruby-2.1.3#myapp --ruby-version --create
rvm creates a new gemset, named ruby-2.1.3#myapp, which will be run with Ruby 2.1.3. As a consequence, you have a new directory at ~/.rvm/gems/ruby-2.1.3#myapp, where your gemset will be. You also have two new files in your previously empty myapp directory: .ruby-version (which contains a single line saying ruby-2.1.3) and .ruby-version (containing the line myapp). These two lines are read by rvm every time you enter the myapp directory: it sets the current Ruby and gemset for you.
$ gem install rails
Having recognised that the current gemset is now ruby-2.1.3#myapp, the gem install command will download the newest rails gem, as well as all its dependencies, and put them in your gemset directory (~/.rvm/gems/ruby-2.1.3#myapp/).
$ get install rails --version=4.0.8
If you try this, it will dutifully install Rails 4.0.8, but since you have a newer version in your gemset and your application is not specifically having any requirements, the newer one will take precedence. This is normally not what you want; and anyway, there is rarely a reason to develop a project to comply with two different versions of a library (unless you're developing a library or a plugin; that's a different story).
$ rails new .
rails is actually executing ~/.rvm/gems/ruby-2.1.3#myapp/bin/rails. If you were not in myapp directory, linked to the gemset, this command would have failed (if you didn't have Rails installed in the global environment), or executed globally installed Rails (if you did).
So, it's not really designed to have two versions of Rails simultaneously in the same project. But when you make another project, with another gemset (say, ruby-2.1.3#myotherapp), you could have a different version of Rails while you're there. The version automagically changes just based on which directory you cd into.
rails s
command creating new project inside project directory instead of starting server.
I installed rails in my system but it is showing unexpected behavior, as creating project instead of starting server.
I see in my system by running gem list | grep rails command it shows rails 3.2.11 but when I see using rails -v then it shows rails 2.3.11
SO on running rails s it picks rails 2
Please check Your version of rails. It is definitely < 3.
So use ruby script/server instead of rails s.
You will be running the first version of rails that is found in your PATH. You can always change your path environment variable so it finds rails 3.2.11 first, but if you are trying to manage several versions of rails/ruby on your system I recommend you use rvm or rbenv.
Thanks #Gosavi and #boulder
Your solutions are also worthy, but my prbolem was resolved doing this
My app was poiniting to default gemset so I created new gemset for my app
To create new gemset
rvm --rvmrc --create 1.9.3#project_name
To list avaliable gemsets:
rvm gemset list
My terminal is showing this at the start of the command line:
subalcharla#subal-charlas-macbook ~ $
And as a consequence when try to create a new app using rails with the command:
subalcharla#subal-charlas-macbook ~ $ rails new sample_app --skip-test-unit
The app that appears in Finder in my Mac 10.5.8 is named new instead of sample_app. Also, --skip-test-unit does not seem to be working.
Please help.
Looks like you have an older version of rails installed to check the version in you terminal type
rails -v
if the version is < 3.0, update rails to 3.2
gem install rails -v 3.2
I've just upgraded my rails version to rails 3.0.
But suddenly I need a new rails app with old version of rails.
I know the new version of rails change command line usage with rails new.
How can I create an old version of Rails in this new Rails 3 environment?
Use the following command:
rails _2.3.5_ new APP_NAME
This will create a rails project with version 2.3.5
Leonid Shevtsov provided instructions for how to do this here.
The easiest way to do it was:
Create the directory for the project
Create a Gemfile there containing
gem "rails", "2.3.9"
gem "sqlite3-ruby", :require => "sqlite3"
Runbundle install
Run bundle exec rails . to create an app in the current path
You don't even need rvm to do this.
If you need to switch back and forth, I would recommend using RVM. You can install different versions of Ruby and each can have its own set of gems. I use my system installed ruby (1.8.6?) on my Mac for Rails 2 dev, and then I installed Ruby 1.9.2 with RVM for my Rails 3 dev. Its as simple as doing this after you have RVM installed:
#install and use 1.9.2 for Rails 3
rvm install 1.9.2
rvm 1.9.2
rails new whatever
#switch back to system installed ruby for Rails 2
rvm system
rails whatever