What’s wrong with my local Rails environment? - ruby-on-rails

There is a Rails application I started a full year ago. It’s a Rails 2.3 app.
Now, someone else has made remote changes (it’s on Github, sorry, but it’s private). And I have done
sudo gem update
that is, updated all my gems, including Rails (to 3).
Realizing this, I have done
rake:freeze:edge RELEASE=2.3.8
or whatever to make this release use that version of rails, hoping this was the solution.
however, no such luck so far.
I get errors trying to start the server, AND trying to run script/console (though it’s more successful).
Note that this exact application works just fine on EngineYard.
Server:
$ script/server
=> Booting Mongrel
=> Rails 2.3.8 application starting on http://0.0.0.0:3000
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/yaml.rb:133:in `load': syntax error on line 45, col 3: `' (ArgumentError)
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/yaml.rb:133:in `load'
from /Users/ajh/Sites/PROJECT_NAME/config/../vendor/rails/railties/lib/initializer.rb:902:in `database_configuration'
from /Users/ajh/Sites/PROJECT_NAME/config/../vendor/rails/railties/lib/initializer.rb:437:in `initialize_database'
from /Users/ajh/Sites/PROJECT_NAME/config/../vendor/rails/railties/lib/initializer.rb:141:in `process'
from /Users/ajh/Sites/PROJECT_NAME/config/../vendor/rails/railties/lib/initializer.rb:113:in `send'
from /Users/ajh/Sites/PROJECT_NAME/config/../vendor/rails/railties/lib/initializer.rb:113:in `run'
from /Users/ajh/Sites/PROJECT_NAME/config/environment.rb:11
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
from /Users/ajh/Sites/PROJECT_NAME/vendor/rails/activesupport/lib/active_support/dependencies.rb:156:in `require'
from /Users/ajh/Sites/PROJECT_NAME/vendor/rails/activesupport/lib/active_support/dependencies.rb:521:in `new_constants_in'
from /Users/ajh/Sites/PROJECT_NAME/vendor/rails/activesupport/lib/active_support/dependencies.rb:156:in `require'
from /Users/ajh/Sites/PROJECT_NAME/vendor/rails/railties/lib/commands/server.rb:84
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
from script/server:3
Console:
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/yaml.rb:133:in load':ArgumentError: syntax error on line 45, col 3:rai'
And when, in console, I try to use a defined model:
#mm = MyModel.find(:all)
NameError: uninitialized constant MyModel
from /Users/ajh/Sites/PROJECT_NAME/vendor/rails/activesupport/lib/active_support/dependencies.rb:443:in load_missing_constant'
from /Users/ajh/Sites/PROJECT_NAME/vendor/rails/activesupport/lib/active_support/dependencies.rb:80:inconst_missing'
from /Users/ajh/Sites/PROJECT_NAME/vendor/rails/activesupport/lib/active_support/dependencies.rb:92:in `const_missing'
from (irb):1

I just had this error, and the problem turned out to be that I'd used a tab instead of a double-space in the database.yml file. Thought I'd mention it, in case others have the same trouble.

My database.yml had a stray end keyword. Cleaning up that file solved my problems. Thanks to Garrett for pointing me in the right direction!

Related

can't start Rails server - bunch of errors

I'm new on Ruby on Rails (actualy I'm new programming in general) and I tried to start a new server for my web app. I followed all the rules that were in the book, installed everything required (I hope I've installed it correctly), but it keeps giving me the following error:
My command ->
C:\Users\Júlia\work\demo>ruby bin/rails server
C:/Ruby30-x64/lib/ruby/3.0.0/pathname.rb:50:in `match?': invalid byte sequence in UTF-8 (ArgumentError)
from C:/Ruby30-x64/lib/ruby/3.0.0/pathname.rb:50:in `chop_basename'
from C:/Ruby30-x64/lib/ruby/3.0.0/pathname.rb:374:in `plus'
from C:/Ruby30-x64/lib/ruby/3.0.0/pathname.rb:354:in `+'
from C:/Ruby30-x64/lib/ruby/3.0.0/pathname.rb:420:in `join'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bundler-2.2.28/lib/bundler/settings.rb:444:in `global_config_file'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bundler-2.2.28/lib/bundler/settings.rb:93:in `initialize'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bundler-2.2.28/lib/bundler.rb:330:in `new'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bundler-2.2.28/lib/bundler.rb:330:in `settings'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bundler-2.2.28/lib/bundler.rb:99:in `configured_bundle_path'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bundler-2.2.28/lib/bundler.rb:95:in `bundle_path'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bundler-2.2.28/lib/bundler.rb:639:in `configure_gem_home_and_path'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bundler-2.2.28/lib/bundler.rb:81:in `configure'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bundler-2.2.28/lib/bundler.rb:194:in `definition'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bundler-2.2.28/lib/bundler.rb:143:in `setup'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bundler-2.2.28/lib/bundler/setup.rb:10:in `block in <top (required)>'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bundler-2.2.28/lib/bundler/ui/shell.rb:136:in `with_level'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bundler-2.2.28/lib/bundler/ui/shell.rb:88:in `silence'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bundler-2.2.28/lib/bundler/setup.rb:10:in `<top (required)>'
from <internal:C:/Ruby30-x64/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
from <internal:C:/Ruby30-x64/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
from C:/Users/Júlia/work/demo/config/boot.rb:3:in `<top (required)>'
from bin/rails:3:in `require_relative'
from bin/rails:3:in `<main>'
I'm so frustrated right now, I keep doing things apparently right but something always has to go wrong! Anyways, I hope someone will be able to help me here :(
You can follow GoRails guide to install RoR on windows it will be much easier.
Here it is: Install Ruby On Rails on Windows 10
Also after installing it you may face some other issues related to your database ( whatever database you use) like you may have installed Postgresql on windows, so when after installing it on WSL you need to kill the one running on the port that WSL will use, and similar issues, all solved across the internet

Ruby1.8 Rails2.3 ./script/server producing error

I have been assigned a projected that was written in Ruby1.8 and Rails2.3. We can't upgrade at the moment. I have successfully installed ruby and rails and installed all needed gems for the project on a ubuntu machine. I have received success messages while installing everything.
However, when I run the command ./script/server I received the output:
/var/lib/gems/1.8/gems/activesupport-2.3.18/lib/active_support/dependencies.rb:182:in `require': no such file to load -- sentry (MissingSourceFile)
from /var/lib/gems/1.8/gems/activesupport-2.3.18/lib/active_support/dependencies.rb:182:in `require'
from /var/lib/gems/1.8/gems/activesupport-2.3.18/lib/active_support/dependencies.rb:547:in `new_constants_in'
from /var/lib/gems/1.8/gems/activesupport-2.3.18/lib/active_support/dependencies.rb:182:in `require'
from /home/robotmaster/Documents/Source/agile/config/initializers/sentry.rb:1
from /var/lib/gems/1.8/gems/activesupport-2.3.18/lib/active_support/dependencies.rb:171:in `load_without_new_constant_marking'
from /var/lib/gems/1.8/gems/activesupport-2.3.18/lib/active_support/dependencies.rb:171:in `load'
from /var/lib/gems/1.8/gems/activesupport-2.3.18/lib/active_support/dependencies.rb:547:in `new_constants_in'
from /var/lib/gems/1.8/gems/activesupport-2.3.18/lib/active_support/dependencies.rb:171:in `load'
from /var/lib/gems/1.8/gems/rails-2.3.18/lib/initializer.rb:622:in `load_application_initializers'
from /var/lib/gems/1.8/gems/rails-2.3.18/lib/initializer.rb:621:in `each'
from /var/lib/gems/1.8/gems/rails-2.3.18/lib/initializer.rb:621:in `load_application_initializers'
from /var/lib/gems/1.8/gems/rails-2.3.18/lib/initializer.rb:176:in `process'
from /var/lib/gems/1.8/gems/rails-2.3.18/lib/initializer.rb:113:in `send'
from /var/lib/gems/1.8/gems/rails-2.3.18/lib/initializer.rb:113:in `run'
from /home/robotmaster/Documents/Source/agile/config/environment.rb:42
from /var/lib/gems/1.8/gems/activesupport-2.3.18/lib/active_support/dependencies.rb:182:in `require'
from /var/lib/gems/1.8/gems/activesupport-2.3.18/lib/active_support/dependencies.rb:182:in `require'
from /var/lib/gems/1.8/gems/activesupport-2.3.18/lib/active_support/dependencies.rb:547:in `new_constants_in'
from /var/lib/gems/1.8/gems/activesupport-2.3.18/lib/active_support/dependencies.rb:182:in `require'
from /var/lib/gems/1.8/gems/rails-2.3.18/lib/commands/server.rb:84
from ./script/server:4:in `require'
from ./script/server:4
I am new to the Rails and would appreciate any help with this error message. Thanks
The key to the issue is here:
sentry (MissingSourceFile)
I'm really not familiar with that particular file (and Rail 2.3 is several major revisions behind...) but it indicates to me that there's something incomplete about your Gem set.
gem update
This would be my first attempt. Verify that all of the referenced gems in your Gemfile are present on the system. If at all possible, I'd really look to upgrade to at least Rail 3, preferably 4.
EDIT:
Reading this again, why are you executing ./script/server? You should be executing:
rails s

Webrick Rails server won't start?

I'm using Rails 4.0.0, and successfully installed the mysql2 gem yesterday (mysql-0.3.15) using mysql-connector-c-6.1.3.winx64. I created a new Rails project called "simple_cms" using rails new simple_cms -d mysql which worked, and then ran bundle install which was also fine.
When I try to run rails server I get the following errors:
C:\Users\Hans>cd sites
C:\Users\Hans\Sites>cd simple_cms
C:\Users\Hans\Sites\simple_cms>rails server
C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/mysql2-0.3.15/lib/mysql2.rb:8:in
`requir e': 126: The specified module could not be found. -
C:/Ruby200-x64/lib/ruby/ge
ms/2.0.0/extensions/x64-mingw32/2.0.0/mysql2-0.3.15/mysql2/mysql2.so
(LoadError)
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/mysql2-0.3.15/lib/mysql2.rb :8:in `<top (required)>'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.6.0.rc2/lib/bundler/runtime.rb:76:in `require'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.6.0.rc2/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.6.0.rc2/lib/bundler/runtime.rb:72:in `each'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.6.0.rc2/lib/bundler/runtime.rb:72:in `block in require'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.6.0.rc2/lib/bundler/runtime.rb:61:in `each'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.6.0.rc2/lib/bundler/runtime.rb:61:in `require'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.6.0.rc2/lib/bundler.rb:132:in `require'
from C:/Users/Hans/Sites/simple_cms/config/application.rb:7:in `<top (required)>'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/commands.rb:76:in `require'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/commands.rb:76:in `block in <top (required)>'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/commands.rb:73:in `tap'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/commands.rb:73:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
C:\Users\Hans\Sites\simple_cms>
What can I do about this? By the way, the module it cannot find is in fact there.
28-Mar-2014 After all the problems I had installing and re-installing, I still could not get rails server to run. As I mainly want this installation to learn Ruby on Rails, I have instead installed the Bitnami Ruby stack, which installs everything automatically. This seems to work fine, and I've got Ruby, MySQL and the Apache Web Server working.
I had similar problems configuring the Lynda course on learning Ruby on Rails. I found an additional step that seemed to work for me. Since the error was complaining about the lack of a database in mysql, I created the missing database and that fixed the problem.
Log into mysql as root and prompt for password:
mysql -u root -p
Then:
SHOW DATABASES;
CREATE DATABASE simple_cms_development;
exit;

Ruby Gems dependency error

I am very very very new to RoR and I'm doing this on my windows 7 environment.
Yeah I know, "why not ubuntu?" We tried..performance was dog slow.
Anyway, I have RoR running on my machine and I created a test app aptly named, "testApp".
I run it in the browser..voila! No biggie. I have my basic website.
Now when I try and run it with a checked out website on my desktop, I get this
C:\devApp>ruby script/server
=> Booting WEBrick
=> Rails 2.3.5 application starting on http://0.0.0.0:3000
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rails-2.3.5/lib/rails/gem_dependency.rb:119:in `requirement': undefined local variable or method `version_requirements' for
#<Rails::GemDependency:0x35eae38> (NameError)
from C:/Ruby192/lib/ruby/site_ruby/1.9.1/rubygems.rb:254:in `activate'
from C:/Ruby192/lib/ruby/site_ruby/1.9.1/rubygems.rb:1204:in `gem'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rails-2.3.5/lib/rails/gem_dependency.rb:73:in `add_load_paths'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rails-2.3.5/lib/initializer.rb:301:in `block in add_gem_load_paths'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rails-2.3.5/lib/initializer.rb:301:in `each'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rails-2.3.5/lib/initializer.rb:301:in `add_gem_load_paths'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rails-2.3.5/lib/initializer.rb:132:in `process'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rails-2.3.5/lib/initializer.rb:113:in `run'
from C:/srw/config/environment.rb:12:in `<top (required)>'
from <internal:lib/rubygems/custom_require>:29:in `require'
from <internal:lib/rubygems/custom_require>:29:in `require'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:in `block in require'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:521:in `new_constants_in'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:in `require'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rails-2.3.5/lib/commands/server.rb:84:in `<top (required)>'
from <internal:lib/rubygems/custom_require>:29:in `require'
from <internal:lib/rubygems/custom_require>:29:in `require'
from script/server:3:in `<main>'
And no server is started. I've gone through all my gems to make sure I have the right versions as per my lead developer tells me. And we both are scratching our heads now.
Can someone help me figure out what dependency I'm missing?
Thanks!
I think this is happening because your RubyGems version is out of date. Try running gem update --system to update it to the latest version
Just update your bundler, maybe of any-one of the older gem is conflicting with latest one, this type of issues arises.
'gem install bundler'
and then 'bundler install'
If you find again error, then delete GEM.lock file, then run bundler install. It may resolve the issue.
Seems like you are trying to run an application without all the required gems, I would try installing all the gems that are mentioned in the "Gemfile" (root of the app), and running the application again.
As a Windows user, I would really suggest that you try to do your rails learning and development in Ubuntu (like I do). It is much easier to install, mantain, test applications and get help.

Upgrading rails / reloadable

I have tried to upgrade my rails in order to deploy a old RoR app into Heroku,
Unfortunately I'm getting some errors and I have no clue how to fix this. It seems that include Reloadable from my model isn't working anymore:
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:105:in `const_missing': uninitialized constant Artist::Reloadable (NameError)
from /disk1/home/slugs/123146_6bfd10b_0628/mnt/app/models/artist.rb:2
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:158:in `require'
from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:265:in `require_or_load'
from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:224:in `depend_on'
from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:136:in `require_dependency'
from /usr/local/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/initializer.rb:414:in `load_application_classes'
... 23 levels...
My previous install was using RAILS_GEM_VERSION = '1.1.2'.
Have you tried deleting the include Reloadable
Reloaded has been deprecated for a long time. Check this out: http://weblog.rubyonrails.org/2006/8/11/reloading-revamped
The functionality you're looking for may now be automatically built into rails.

Resources