I have just started to learn Ruby on Rails and in going through a tutorial I am not able to launch the rails project because of the following error.
-e:4:in `load': no such file to load -- script/server (LoadError)
from -e:4:in `<main>'
I have installed Ruby 1.9.2 and using RadRails as the IDE for creating and executing the Rails project. Any suggestions?
Most likely your tutorial refers to Rails 2 (for which given command works), while you're using Rails 3.
I'm not sure how exactly you start server in Rails 3 (edit see answer by jdl), but take my adice: find another tutorial. Otherwise, you'll have to create such questions here several times a day :)
If you just installed the latest Rails the the command has changed (as of Rails 3) to:
$ ./script/rails server
I think the best way to start a server in Rails 3 is to run this command from the root of the project:
rails server
You should have the rails executable in your path if you've installed the Rails 3 gem.
Related
I've been following Mike Hartl's excellent Ruby on Rails Tutorial`.
I had to make some decisions earlier about versions for gem files and ruby. I decided (after some problems getting Heroku to work that I'd directly mimic the tutorial and versions of ruby described - leading me to go with rvm use 2.0.0 to set my version of ruby.
All was great on chapter one but now I'm getting an error message when i try to create a new rails project:
$ rails new demo_app
/home/huw/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in require': cannot load such file -- rails/cli (LoadError)
from /home/huw/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:inrequire'
from /usr/bin/rails:9:in `'
I have no idea what that means... but as its referencing my ruby version I'm guessing that my rails and ruby versions are out of sync...
Could someone advise on possible courses of action?
I imagine possible options would be:
Reset my ruby version to the latest (but I don't know what clashes
that would create with gems!)
Downgrade from rails 4.1 to rails 4 (I believe that's Mike Hardl's version)
Force things through somehow
I'm a complete rails Noob however, and have no idea where to begin on any of those options - or if that error code even backs up my assumptions!
Forgive the "answer" but I don't have the rep to post a mere comment :-(
Have you tried looking at the RVM site? It has a troubleshooting page that may help you.
If not, have you tried get rvm stable and then typing in the rails new app_name command?
Other useful RVM commands are rvm list rubies and rvm gemset list. It may be the case that the ruby version you're using doesn't have rails for some reason.
As per zwippie's answer in the comment section, the solution was achieved as follows.
rails -v produced a very similar looking output to the error message above.
gem install rails after hanging for a second installed rails successfully. I am now able to add a new project.
I'm unsure why this has happened as I've been successfully making new rails projects both on this laptop and in this directory for the last two weeks, even up until this morning. However as zwippie notes perhaps this is an RVM setup issue. I'll go away and read up but if anyone had any additional pointers from documentation that might shed light on the issue I'm appreciate any links in the comment.
Many thanks all.
check for the rails is installed on your machine by the command bundle show rails.
If you get the version of rails and are still getting the above error, to resolve it you may have to use the command bundle exec before every rails command as in bundle exec rails s.
im really new to ruby and ROR and im having real trouble trying to get my directory that i created earlier to open in terminal (on a mac) and then start the rails server so i can preview it in the browser.
ive been trying :
cd /Users/sam/Documents/Pudle/Projects/treeb
and
ruby /Users/sam/Documents/Pudle/Projects/treeb
then running rails s
i think the problem im having is that im not loading in the directory correctly, appologies for it being such a simple question but ive been going round in circles with this for hours !
any helps much appreciated
Assuming you've created your new Rails application using rails new app_name, you can simply start the server by running cd /Users/sam/Documents/Pudle/Projects/treeb and rails s
Ref how to create a rails application
suppose your application path is cd /Users/sam/Documents/Pudle/Projects/treeb
then do following to start the server
cd /Users/sam/Documents/Pudle/Projects/treeb
rails server #or just rails s
NOTE:- Above will work only if you are using Rails 3
For Rails 2
ruby script/server
I have installed ruby193 and I've installed rails via the command prompt. However, whenever I try the command:
ruby script/server
I get this error:
ruby: No such file or directory -- script/server (LoadError)
I checked my script folder and all it has is a file called rails.
I'm very new to Ruby on Rails and I'm not entirely sure if I've installed everything correctly. Is there an easy way to check what I have installed?
To clarify on the existing answers, ruby script/server is no longer the proper way to start a server in Rails. In Rails 3, we use rails server, which can be shortened to rails s. See the Rails Guides for a more extensive rundown of the Rails 3 command line interface.
Try running rails server or rails s.
If you have Ruby & rails installed properly, then ruby -v would result in the version that you have installed and likewise rails -v would give the rails version installed.
To run a rails server try running rails server or rails s
Trying to follow the "Ruby on Rails 3 Tutorial" and running rails s, getting the following error:
[path]\config.ru:1 in 'require': no such file to load -- fake_app
I've got the location of fake_app.rb in the PATH (which I presume is what rails/rack is trying to find)
Contents of config.ru are the default generated:
require "fake_app"
run Rack::Test::FakeApp
I am running rails 3.0.8 and Windows 7
Thanks for helping this complete novice out!
Did you generate this with rails new [appname] command? A default Rails 3.0 config.ru file should look more like this:
require ::File.expand_path('../config/environment', __FILE__)
run ApplicationName::Application
If all you've done at this point is install Ruby and Rails, I'd re-run the generator to get something that works.
Also, since you're on Windows, I wanted to recommend Rails Installer for your environment installation and setup. It mitigates a lot of the startup pain.
This is probably the tutorial you are speaking of, but I also highly recommend Michael Hartl's Ruby on Rails Tutorial for a solid introduction to Rails 3. The section about generating your first application may be handy in this situation.
i am just starting with RoR and working through some tutorials, there is however a particular piece of code on github that i would like to look at, i have cloned it to my local and cd into the project but 'rails s' does not seem to start the server - any ideas what i need to do?
That's a Rails 2.3.2 app. rails s was introduced in Rails 3, so you'll have to use the older script/server start command.
Also, you're going to need rails 2.3.2, which you can install with gem install -v=2.3.2 rails. There's also the possibility that you're missing some required gems, which you'll find out about by running the app and watching for load errors.
Also, make sure you're running Ruby 1.8.7, not Ruby 1.9.2. Rails 2.3.2 does not work with Ruby 1.9.2