Rails cannot load rubygems/defaults file on Windows - ruby-on-rails

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.

Related

Ruby failing to run after upgrading (sqlite3_native LoadError); sqlite3 not upgrading properly

I have upgraded to ruby 2.5.0 but I am having conflicts everywhere. I have checked previous posts on stack overflow such as:
Ruby on Rails - "Add 'gem sqlite3'' to your Gemfile"
cannot load such file — sqlite3/sqlite3_native
cannot load such file -- sqlite3/sqlite3_native (LoadError) on ruby on rails
https://github.com/sparklemotion/sqlite3-ruby/issues/137
But none of them are working for me. My issue is similar to these posts in that after I run rails server after a long error message the last few lines read:
1: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:287:in 'block in require'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in 'require': cannot load such file -- sqlite3/sqlite3_native (LoadError)
I have tried creating a new project, reinstalling sqlite3 through gem and minigw itself, reinstalling rails and ruby. I have tried most of the instructions in the previous questions but nothing works. SQLite3 version 3.25.2, Ruby 2.5.3, rails 5.2.1
Sorry, this might be a simple fix but I am a complete beginner to ruby and I have been trying different things for a few hours now. Any help is appreciated.
As explained in this answer https://stackoverflow.com/a/49736971/4685144, you should now be able to install sqlite3 using git:
gem 'sqlite3', git: 'https://github.com/sparklemotion/sqlite3-ruby'
Then bundle install

Running local server for Rails 2.3 app?

I am trying to run a Rails 2.3 app locally.
script/server gives me these errors:
bash: script/server: Permission denied
bash: parse_git_branch: command not found
script/server gives me the error:
/Users/stevenbrooks1111/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in `require': cannot load such file -- initializer (LoadError)
from /Users/stevenbrooks1111/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in `require'
from /Users/stevenbrooks1111/Desktop/cssmixonline/cssweb/config/boot.rb:55:in `load_initializer'
from /Users/stevenbrooks1111/Desktop/cssmixonline/cssweb/config/boot.rb:38:in `run'
from /Users/stevenbrooks1111/Desktop/cssmixonline/cssweb/config/boot.rb:11:in `boot!'
from /Users/stevenbrooks1111/Desktop/cssmixonline/cssweb/config/boot.rb:110:in `<top (required)>'
from /Users/stevenbrooks1111/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /Users/stevenbrooks1111/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from script/server:2:in `<main>'
bash: parse_git_branch: command not found
Any ideas of how I can get this to run locally?
This question is what I've been doing for the past month. I would have loved to use Rails 4, but I know better than to try it!
Install rvm or rbenv, then get into a server that correctly runs this app, and run
ruby --version
gem list > ~/myGems.txt
Using rvm or rbenv, install the exact same version of Ruby.
(Tip: whenever I say "exact same", you can fudge by bumping the revision. For example, given a gem with version 0.1.4, if it has subsequent versions 0.1.5, 0.1.6, and 0.2.0, you can bump to 0.1.6, if that will save you some grief. The revision numbers, 0.1.*, are supposed to be only bug fixes. But a minor version bump, 0.2.0, has higher odds of breaking things. I kept the same version of Ruby, but I bumped rails to 2.3.14.)
Using rvm or rbenv, install the same version of Ruby as currently runs on this app's main server.
Inside this Ruby environment (with both which ruby and ruby --version reporting the correct answers), install each gem in myGems.txt, like this:
gem install --ignore-dependencies --no-rdoc --no-ri my_gem -v=0.1.4
The --ignore-dependencies is critical, because some gems from the Pleistocene Epoch, 2009, don't specify their dependencies' versions. When some dumb 2009 gem pulls in the 2013 rake, you will be utterly screwed, because reverting that rake is really hard. And don't forget to set the -v to the same value as myGems.txt reports!
After all that, try simple rake commands like rake routes. Post any bugs you get as fresh questions, but remember to point out Rails 2.3 in the subject so nobody mis-answers with the modern fixes.
And if this app has tests or specs, getting them running should be a top priority, so you can resume TDD, leaning on the tests to allow you to make sick changes.

Rails - script/server boot up

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.

Error with new Rails 3.2.8 project - `require': cannot load such file -- sqlite3/sqlite3_native (LoadError)

I've just created a new amazon Linux instance and installed ruby 1.9.3 and rails 3.2.8.
Upon creating a new project I immediately receive failures due to sqlite3. The error is:
[root#xxxxx fun]# rails server
/usr/local/share/gems/gems/sqlite3-1.3.6/lib/sqlite3.rb:6:in `require': cannot load such file -- sqlite3/sqlite3_native (LoadError)
from /usr/local/share/gems/gems/sqlite3-1.3.6/lib/sqlite3.rb:6:in `rescue in <top (required)>'
from /usr/local/share/gems/gems/sqlite3-1.3.6/lib/sqlite3.rb:2:in `<top (required)>'
I have confirmed that sqlite3 is working just fine outside of rails (i.e. I successfully created a database, did inserts/reads using ruby code). Here is a quick show of loading sqlite3 in irb:
irb(main):001:0> require 'sqlite3'
=> true
I'm all up to date with bundle install. sqlite3 is at version 1.3.6
I have the following packages installed:
ruby19-1.9.3.0-7.17.amzn1.i686
ruby19-devel-1.9.3.0-7.17.amzn1.i686
ruby19-irb-1.9.3.0-7.17.amzn1.noarch
ruby19-libs-1.9.3.0-7.17.amzn1.i686
rubygem19-io-console-0.3-7.17.amzn1.i686
rubygem19-rdoc-3.9.4-7.17.amzn1.i686
rubygems19-1.8.11-7.17.amzn1.noarch
sqlite-3.6.20-1.8.amzn1.i686
sqlite-devel-3.6.20-1.8.amzn1.i686
Any ideas on what I could try to get things working? Thanks!
Update
For "fun" I commented out the gem sqlite3 line from my Gemfile and tried "rails server" again. First it complained about not having a javascript runtime (which I could fix) but then it is getting the following. There seems to be something royally wrong with my install.
[root#xxxx fun]# rails server
/usr/local/share/gems/gems/railties-3.2.8/lib/rails/railtie/configuration.rb:85:in `method_missing': undefined method `active_record' for #<Rails::Application::Configuration:0x9e68f58> (NoMethodError)
from /srv/rails/fun/config/application.rb:54:in `<class:Application>'
from /srv/rails/fun/config/application.rb:13:in `<module:Fun>'
from /srv/rails/fun/config/application.rb:12:in `<top (required)>'
You may have a path problem.
To see if you have more than one version of Ruby, Rails, or gem installed:
find / | grep bin/ruby
    find / | grep bin/rails
    find / | grep bin/gem
On Amazon servers, I typically keep the system Ruby as is, and install my own current Ruby by using the excellent ruby-build script (better than RVM, in my opinon).
https://github.com/sstephenson/ruby-build
If you do have more than one Ruby, I suggest that you set your environment to choose one, for example by using ruby-build or by setting your PATH in your .bashrc file or /etc/environment file something like this:
PATH=/opt/ruby/1.9.1-p134/bin;$PATH
If you're using RVM, I suggest you uninstall it and change to use ruby-build.
To uninstall RVM, I use this script:
https://github.com/SixArm/sixarm_unix_shell_scripts/blob/master/rvm-uninstall-danger

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