Calling 'rails new demo' created a folder named "new"? - ruby-on-rails

I installed Ruby and Rails using apt-get in Ubuntu. Then when I test my installation, this thing happen.
When I call rails server inside a rails-created-folder, rails created a new folder called "server" for me, with a correct folders structure, including controller folder, app folder, gemlock file, etc.
How could it possibly happen? I will try reinstalling RoR, but has anyone encountered this?
Last time, I used RVM, but whenever I create a new app, I will have to waith for rails to redownload all the bundle file, but in this installation, I don't have to. Can you help me explaining it?
Thank you and best regards

As pointed out in the comments, it sounds like your rails executable is rails 2.
Try gem uninstall rails, select all versions.
Run rails -v. If this command works you've got a system version of rails that isn't being handled by RVM. BTW, this is why many rails devs are shifting from RVM toward rbenv + bundler.
If you still have rails after gem uninstall, run sudo gem uninstall rails. On RVM, sudo gets to your system gems. You might want to sudo gem uninstall everything, so you don't have this conflict in the future.
gem install rails, you should get version 3.2.8.
Try rails new my_app again. It should work. If this doesn't work, try the following:
Create a parent directory for your rails projects, like ~/rails. Then create a GEMFILE that looks like this:
source :rubygems
gem 'rails', '~>3.2.8'
Then inside ~/rails run bundle exec rails new app_name.
If that doesn't work... you've got a bigger system config problem of some kind I guess.

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.

Rails not working on Mac in new terminal window

I have been using RVM (Rails 2.0.0) for a project in the terminal doing commands etc. and have noticed that when I opened a new terminal page the rails command didn't work it just shot back the error:
Rails is not currently installed on this system. To get the latest version, simply type:
$ sudo gem install rails
But I had it installed and have even built half an app using it so far... what happened all of a sudden and how do I fix it to keep going with my project.
I was having the same problem on with the Rails tutorial. It looks like rvm is using the gemset defined in the Gemfile to override the default gemset. You should see this if you execute:
rvm gemset list_all
What I saw was this:
(default)
global
=> railstutorial_rails_4_0
So rails is fully installed in rvm's default gemset, but not in the new one ("railstutorial_rails_4_0" in this case). I solved this with the following commands:
bundle install --without production
bundle update
bundle install
This solution appears to have persisted across terminal sessions.
Okay so I got it to work by simple removing the code in the Gemfile that states the version of Ruby the app is to use and then it worked fine. Must of been some conflict with RVM installed on my machine and the Gemfile.

Rails app cant detect local gems

This is a very odd one and I'm not sure how to proceed.
Basically, I am able to install gems and use them normally within any folder except those created with rails. It's very very odd. It's difficult to explain so maybe this console output will explain
passenger#rubyserve:~/railsapps$ ls
app test_application testing
passenger#rubyserve:~/railsapps$ rails -v
Rails 3.2.2
passenger#rubyserve:~/railsapps$
passenger#rubyserve:~/railsapps$
passenger#rubyserve:~/railsapps$ cd app/
passenger#rubyserve:~/railsapps/app$ ls -a
. app config.ru doc Gemfile.lock lib public README.rdoc test vendor
.. config db Gemfile .gitignore log Rakefile script tmp
passenger#rubyserve:~/railsapps/app$
passenger#rubyserve:~/railsapps/app$
passenger#rubyserve:~/railsapps/app$ rails -v
The program 'rails' is currently not installed. To run 'rails' please ask your administrator to install the package 'rails'
passenger#rubyserve:~/railsapps/app$
It makes bugger all sense. When outside my rails folder, I can call rails to make a new application but once within, rails isn't detected. This is the same for all gems including bundler.
My first thought was that somehow, rails had some specific gem folder hidden away, so I done my gem install from within the rails project, however this didn't work either.
Any thoughts?
My setup is ubuntu server 10.10 (I know, i know)
Ruby 1.9.2
gem 1.8.17
and I'm using the latest rvm from wayneeseguin.enter code here
This type of problem some time occurs i think u can save a lot of time by installing and using RVM
After installing RVM create gemset directory every time whenever you create separate project. e.g you create application blog first you create gemset directory with giving this command
rvm gemset create blog
then you should use this gemset directory and also ruby version as well e.g you have install ruby 1.9.2 then use this command
rvm use ruby-1.9.2#blog
after that go into directory of blog application and install this gem
gem install bundler
and also then bundle install. so all local gem will be installed into this blog directory under rvm and there will be no conflicts will be appear.But keep one thing in mind if your platform is ubuntu then this will work

Rails Server Command

I am new to Ruby on Rails and am following a tutorial to create a class project.
I can generate a new rails project with
$ rails project
The problem Im having is when I try to start my server, It will generate a project called server:
$ rails server
or
$ rails s
I figured out that I need to install/update rails to 3.0.3 to use this command every time I open terminal. I find myself having to install gems(bundle, etc) every time I need to work on my project.
Is there anyway to save this terminal session or profile for later use?
Is it user error?
Im new to Rails and about the same with terminal.
Any help would be greatly appreciated. I have resorted to leaving my computer and terminal open for about a week...
Welcome on board! - You'll have fun, I found setting up the environment the most difficult thing.
in rails 2 you start the server with ruby script/server.
to upgrade to rails 3 try gem install rails -v=3.0.4
I put the version but it's not a mandatory option.
To uninstall a gem (as rails is) is gem uninstall gemname -v=x.x.x. -
gem list will tell you the version of each gem.
I hope you've got rvm, if not I strongly sugget you to install it, this will allow you not only to use different versions of ruby but also to set different gemsets, therefor one each project, you'll find it useful.
Once in rails 3 you can use bundler, have a look at this episode of railscasts, by the way this is a very good site, but you may know it already.
another edit...
I don't know the behavior you're describing, looks like something is wrong with your environment, but I need to know if you have rvm to solve this, if so try rvm list and rvm gemset, With the first you get the list of installed ruby, you can switch between them with rvm 1.9.2 i.e. and rvm 1.9.2#gemdirname with the gemdir coming from the second list. You should find your configuration in one of those list.
Hi if you are using rails 2.8 or lesser use this to start the server
ruby script/server
rails new project is for new rails project n rails s is for starting server

Resources