Rails - script/server boot up - ruby-on-rails

Can someone help me out with something seemingly simple? My newness to Ruby on Rails is the reason, no doubt. I cannot start up the server. It looks like the boot file cannot be located but I'm nor sure at all.
There are several versions of ruby here, related to installing rvm:
which -a ruby
/Users/me/.rvm/rubies/ruby-1.9.3-p327/bin/ruby
/Users/me/.rvm/bin/ruby
/usr/local/bin/ruby
/usr/bin/ruby
Probably need to remove some?
Using Rails 3.2.9 with Ruby 1.9.3 on a Mac Mini
Thanks!
cd [rails project dir]
$ script/server
/Users/me/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require':
cannot load such file -- script/../config/boot (LoadError)
from /Users/me/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from script/server:2:in `'

This isn't the issue you are getting. script/server still works, what you are experiencing is an issue with the gems you are trying to use. What you might try is running rails s --trace, see what gems are causing the issue and manually reinstalling them. From the looks of it, it's just an issue with a lone gem with dependencies in 1.9.1.

With Rails 3+ you get access to the rails command line scripts so instead of calling script/server you just run rails server or rails s for short.

Related

Issue With Starting Rails Server & Creating a New Rails Project

I am new to rails and have finally been able to install rails and follow along with a video tutorial. I am having a couple issues. Yesterday I was not having any major issues. Then this morning when I tried to create another rails project I get an error or when I try to run my rails server for my last first project I get an error. Any help would be greatly appreciated. Thank you!
/Users/lipmanb/.rvm/gems/ruby-2.0.0-p643/bin/rails:23:in `load': cannot load such file -- /Users/lipmanb/.rvm/gems/ruby-2.0.0-p643/gems/rails-4.2.3/bin/rails (LoadError)
from /Users/lipmanb/.rvm/gems/ruby-2.0.0-p643/bin/rails:23:in `<main>'
from /Users/lipmanb/.rvm/gems/ruby-2.0.0-p643/bin/ruby_executable_hooks:15:in `eval'
from /Users/lipmanb/.rvm/gems/ruby-2.0.0-p643/bin/ruby_executable_hooks:15:in `<main>'.
It looks like you don't have Rails installed on that environment. You may have installed Rails system wide, but since you are using RVM and you are within a Rails folder, you may be missing that specific Rails version.
Run bundler from within the Rails folder and install the required version.
$ bundler install
or simply
$ bundler
Navigate to your root directory cd ~ and type the following:
sudo gem install rails

Rails cannot load rubygems/defaults file on Windows

Versions, dependencies, and other information:
Ruby: 1.9.3p392 (2013-02-22) [i386-mingw32]
Rails: 3.2.13
Gemfile located at: http://pastebin.com/z9u40Jca
For some reason, whenever I run any gem based command, it gives me this error:
$ rails s
c:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/rubygems.rb:30:in `require': cannot l
oad such file -- rubygems/defaults (LoadError)
from c:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/rubygems.rb:30:in `<top
(required)>'
from <internal:gem_prelude>:1:in `require'
from <internal:gem_prelude>:1:in `<compiled>'
I have tried deleting ruby 2.0.0 from pik and the rails installer folder, because another SO thread said that would fix it. The commands were working as of 5 hours ago, and must have stopped right when I finished using the rails console (part of learning rails from this tutorial, it was just basic math and string manipulation, so I don't think I screwed something up). Any ideas on what I should do?
Try deleting 'ruby '1.9.3' ' from your gem file. It shouldn't be causing a problem, but I've seen situations where it has.
I don't know if I did something I don't know about, but to the best of my knowledge, adding the gem "bootstrap-sass" at version 2.3.2.0 got it working again. I doubt that it was adding that exact gem that was the solution, but you never know.

`require': cannot load such file on running rails --help on brand new install

This is getting quite frustrating. I've eventually resorted to completely removing RVM, and reinstalling from scratch, as a normal user, so restricted to my /home.
After reinstall, I've run gem update --system and gem install rails.
Then I run rails --help, and get the following error:
rails --help
/home/anthony/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- /home/anthony/config/boot (LoadError)
from /home/anthony/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from script/rails:5:in `<main>'
Apparently rails thinks it should be loading a file /home/anthony/config/boot. It looks like the load path is screwed.
I've searched this out, and most people getting this error solve it with gem update --system (which I've one as above), or can at lest run rails -- or rails new . None of these work.
Final System info:
https://gist.github.com/1424644
Please help!
This may be totally a red herring, but it looks like your rails is in a different gemset - "campingground" - than either gem or ruby, which are in your default gemset. I'm not sure if this will cause the issue you're seeing or not - I believe it's OK if you're using the campingground gemset rvm use ruby-1.9.3-p0#campingground, but not if you're using the default gemset rvm use ruby-1.9.3-p0 because I believe that gemsets all inherit the default gemset, but not vice versa. I've had some issues with the bin launchers of ruby helpers (like the rails command) barfing all sorts of confusing load errors, which are often this very issue. Again, not sure if helpful, but I'd share that shot in the dark.

Unable to run tests in a rails app due to rubygems (LoadError)

I am trying to run some basic tests in my rails app following the edgeguides.
My rails app is working fine, it's only when trying to run the tests.
When running a test, I get:
.../config/boot.rb:1:in `require': no such file to load -- rubygems (LoadError)
from /Users/olivier_ntk/Sites/tennis/config/boot.rb:1
from /Users/olivier_ntk/Sites/tennis/config/application.rb:1:in `require'
from /Users/olivier_ntk/Sites/tennis/config/application.rb:1
from /Users/olivier_ntk/Sites/tennis/config/environment.rb:2:in `require'
from /Users/olivier_ntk/Sites/tennis/config/environment.rb:2
from ./test/test_helper.rb:2:in `require'
from ./test/test_helper.rb:2
from test/unit/club_test.rb:1:in `require'
from test/unit/club_test.rb:1
$ ruby -v
ruby 1.8.7 (2010-08-16 patchlevel 302) [i686-darwin10]
$ rails -v
Rails 3.0.6
$ gem -v
1.3.7
However, when I run which -a ruby, I get:
/opt/local/bin/ruby
/opt/local/bin/ruby
/opt/local/bin/ruby
I am not sure why I get 3 lines and if that is affecting calling ruby ...
What command are you using to start the tests?
Try using "rake test" from your app's main directory (in your case that seems to be "/Users/olivier_ntk/Sites/tennis").
If you're already doing that, run:
head -1 `which rake`
and reply with what ruby path you see.
Try typing in gem env for more details.
I tried seeing if this question has been asked before. I don't think the following have the exact same problem as you do, but they may help you uncover what the problem is, or you may want to look for questions listed under "related" to these questions:
no such file to load -- rubygems (LoadError)
ruby gem not found although it is installed
Error loading rubygems

Rails 2.x mongrel won't start after upgrading to rails 3. -- mongrel_rails (MissingSourceFile)

After upgrading my Rails install to Rails 3 on OS X, I’ve had problems running my Rails 2.x development sites with Mongrel. WEBrick seems to work, but I really would like to have the nice output of Mongrel for debugging.
After running $ script/server I get this:
/Library/Ruby/Gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:489:in `load': no such file to load -- mongrel_rails (MissingSourceFile)
from /Library/Ruby/Gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:489:in `load'
from /Library/Ruby/Gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:342:in `new_constants_in'
from /Library/Ruby/Gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:489:in `load'
from /Library/Ruby/Gems/1.8/gems/rails-2.0.2/lib/commands/servers/mongrel.rb:64
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:49:in `gem_original_require'
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:49:in `require'
from /Library/Ruby/Gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:496:in `require'
from /Library/Ruby/Gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:342:in `new_constants_in'
from /Library/Ruby/Gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:496:in `require'
from /Library/Ruby/Gems/1.8/gems/rails-2.0.2/lib/commands/server.rb:39
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:49:in `gem_original_require'
So far, here’s what I’ve tried:
$ sudo gem update system
$ sudo gem update
$ sudo gem uninstall mongrel
$ sudo gem install mongrel --include-dependencies
$ which mongrel_rails
→ /usr/bin/mongrel_rails
$ mongrel_rails start
→ Success, but no stdout
$ which mongrel_rails
→ /usr/bin/mongrel_rails
$ rails _2.0.2_ test
→ Fresh application has same problem.
OS: OS X.6.x
Rails: 3.0.5 (problems are with Rails 2.x apps)
gem -v: 1.6.1
Mongrel: mongrel (1.1.5)
I’ve read EVERY Google result on "-- mongrel_rails (MissingSourceFile)"; there aren’t many.
Can anyone here tell me how to proceed in debugging this? Thanks!
UPDATE:
I’ve now tried installing older versions of the gem and specifying those in my Rails 2.x site’s config/environment.rb file. I’ve tried 1.1.5, 1.1.4, and 1.2.0pre.
None of these makes the slightest bit of difference.
Since the executable in in usr/bin I’m wondering if it’s a file ownership issue that got screwed up on my Rails 3 install and if one of the files isn’t getting my paths when it runs?
/Library/Ruby/Gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb
is owned by admin / root, so that should be OK, right?
Could it be a problem with active_support!?
Here’s the code from dependencies.rb that’s throwing the error:
484 class Object
485
486 alias_method :load_without_new_constant_marking, :load
487
488 def load(file, *extras) #:nodoc:
489 Dependencies.new_constants_in(Object) { super(file, *extras) }
490 rescue Exception => exception # errors from loading file
491 exception.blame_file! file
492 raise
493 end
...
This is getting a file not found error, so it’s not looking where I know the file to be…
Running mongrel_rails on command line works…
Which mongrel_rails shows it in usr/bin,
So what’s the problem?
I have got the same problem and found the reason.
This happens because new version of RubyGems(1.6.2) does not add 'any_gem/bin' to ruby load path ($LOAD_PATH) when you require "any_gem".
For example in RubyGems version = 1.4.1 this works fine. After I require 'mongrel' I can see in load path next:
...rvm/gems/ruby-1.8.7-p330/gems/mongrel-1.1.5/bin
...rvm/gems/ruby-1.8.7-p330/gems/mongrel-1.1.5/lib
...rvm/gems/ruby-1.8.7-p330/gems/mongrel-1.1.5/ext
With new version (1.6.2) I can see only:
...rvm/gems/ruby-1.8.7-p330/gems/mongrel-1.1.5/lib
...rvm/gems/ruby-1.8.7-p330/gems/mongrel-1.1.5/ext
That's why ruby cannot find 'mongrel_rails'.
You need to add "/usr/bin" to your load path. Perhaps something broke in it?
The best way to fix it is to add:
$:.push("/usr/bin/")
Somewhere before it breaks. Probably by itself in a config/preinitializer.rb file if you don't have one.
OK, here's ONE answer. I got mongrel to boot...but it's hacky, and doesn't solve the real problem...but at least for NOW I can get back to work on this project.
Here's what I did...YES..it's HACKY.
I edited the file throwing the error...dependencies.rb
I added a hook to call out the specific path to mongrel rails if that was the file it was trying to load.
def load(file, *extras) #:nodoc:
if file == "mongrel_rails"
file ="/usr/bin/mongrel_rails"
end
Dependencies.new_constants_in(Object) { super(file, *extras) }
rescue Exception => exception # errors from loading file
exception.blame_file! file
raise
end
Again, I would really like to fix the underlying problem here...but this at least let me boot up.
I would definitely look in to using RVM for running multiple gem versions simultaneously locally. I ran into a lot of quirks when I was attempting to run multiple versions like you are with sudo gem installs of everything.
Now it's as simple as rvm ree#my_app_1, and installing completely separate gems there, then switching to a different app and using rvm ree#my_app_2
ree is an alias for my install of ruby enterprise version, you could just as easily do it with ruby 1.9, 1.8.x, etc.
In each of my application's root directories I have a .rvmrc file that reads simply:
rvm ree#my_app --create
So that every time I switch to that directory, the gemset is automatically swapped for me.
I wasn't aware there was Rails 3 mongrel support.
Most people use Thin (you can enable it by specifying gem 'thin' in your Gemfile then launching rails server thin / Webrick these days.
If this is for hosting then there's nginx and Passenger that'll help with that.
I ran into the same problem -- got my app going by running "mongrel_rails" from the project directory (instead of "script/server").
This is the thread where you are able to find the best answer to the mongrel_rails (MissingSourceFile) error. I just want to conclude here how I solved the problem, using stuff in this thread.
The simplest solution I could figure out how to do was to downgrade RubyGems by typing
(sudo) gem update --system 1.4.1
This lets me run the old 2.1.0 app (thanks Max Shytikov), but there's probably a lot of bugfixes that I'm missing by running the old version of rubygems. The error is probably a blunder by the mongrel gem developers (I guess).
Anyway if you just want to run your app using mongrel do it like this. If you insist on having the newest version of rubygems, you can just run your app with
script/server webrick
But I've found that webrick is a fair bit slower, so I prefer mongrel. If anyone has got a better solution for this problem, please let me know.
I ran into the same error. The fix is to add the mongrel "bin" directory to the $LOAD_PATH. Other posts describe how to do it by modifying source code, but since I share source code with other developers, I prefer to set the RUBYLIB environment variable instead.
$ export RUBYLIB=/Users/edwingo/.rvm/gems/ruby-1.8.7-p302#junction/gems/mongrel-1.1.5/bin
This causes the MRI ruby runtime to prepend that to the $LOAD_PATH.
Detailed explanation: MRI is unable to find 'mongrel_rails' because it is not on the $LOAD_PATH. I am using RVM and when I installed mongrel into a gemset, for some reason the $LOAD_PATH does not include the corresponding "bin" directory where 'mongrel_rails' lives. When not using RVM and after installing mongrel into the system gems, the "bin" directory does appear on the $LOAD_PATH so it all works.

Resources