I'm a newb to rails, so please excuse this question but I've been searching everywhere for how to do it. I have a github project I cloaned that I'm going to have to eventually work on, but need to view it now in the browser (will be crash coursing to get up to speed the next couple months). I've downloaded the directory and ran bundle install. Now I'm trying to start the rails server and I get this:
Chriss-MacBook-Pro:chris cgood$ rails server
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.11/lib/rails/railtie/configuration.rb:85:in `method_missing': undefined method `active_record' for #<Rails::Application::Configuration:0x007fc07b649c48> (NoMethodError)
from /Users/cgood/event/chris/config/application.rb:69:in `<class:Application>'
from /Users/cgood/event/chris/config/application.rb:25:in `<module:ChrisGood>'
from /Users/cgood/event/chris/config/application.rb:24:in `<top (required)>'
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.11/lib/rails/commands.rb:53:in `require'
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.11/lib/rails/commands.rb:53:in `block in <top (required)>'
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.11/lib/rails/commands.rb:50:in `tap'
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.11/lib/rails/commands.rb:50:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
Any help would be really appreciated! I've been pulling out hair for hours tackling error message after error message. This one has me stuck as hard to find anything on the internet about it.
I have xcode, rails installer, homebrew and postgreSQL installed. Thanks.
2 things:
upgrade rails!! there's a post about the dangers of using 3.2.11
your app needs a file called database.yml, read this and this to find out what to put in it
Normally your app would have that file in it already, but since it usually contains sensitive data, like database user passwords, people tend to leave it out of their github repos. So you just need to make your own one.
Related
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
I am trying t configure the Salesforce Vulnreport tool, and everytime I run the SEED.rb I get the following error:
Setting up the PostgreSQL database...
/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- dm--adapter (LoadError)
from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/lib/ruby/vendor_ruby/dm-core/adapters.rb:163:in `load_adapter'
from /usr/lib/ruby/vendor_ruby/dm-core/adapters.rb:133:in `adapter_class'
from /usr/lib/ruby/vendor_ruby/dm-core/adapters.rb:13:in `new'
from /usr/lib/ruby/vendor_ruby/dm-core.rb:230:in `setup'
from /root/Documents/Resources/Applications/vulnreport/models/init.rb:19:in `<top (required)>'
from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from ./SEED.rb:20:in `<main>'
I have checked the Gemfile and 'dm-postgres-adapter' is included and installed. I have no idea why I am getting this error, and though I found others attempting to install this with the same issue, I found no fixes. I am not proficient enough with Ruby to really know where to go from here. Any help would be appreciated. Also I hope this I posted this in an OK place.
Thanks!
I realized while looking through my repo that my .env file had a small error in the 'export DATABASE_URL' component which was causing the issue. I was able to fix it by adjusting the incorrect password I had (1 character was off). However, the error message is not very clear. I feel it could have more easily pointed to an authentication failure to the database being the issue.
Recently came back to a computer (Mac OS X Lion 10.7) with which I've had repeated environment issues, started a new rails app, and ran
rake db:create
I got this error output (with --trace):
rake aborted!
dlopen(/Users/<username>/.rvm/gems/ruby-2.0.0-p195/gems/pg-0.15.1/lib/pg_ext.bundle, 9): Library not loaded: /usr/lib/libpq.5.dylib
Referenced from: /Users/<username>/.rvm/gems/ruby-2.0.0-p195/gems/pg-0.15.1/lib/pg_ext.bundle
Reason: image not found - /Users/<username>/.rvm/gems/ruby-2.0.0-p195/gems/pg-0.15.1/lib/pg_ext.bundle
/Users/<username>/.rvm/gems/ruby-2.0.0-p195/gems/pg-0.15.1/lib/pg.rb:4:in `require'
/Users/<username>/.rvm/gems/ruby-2.0.0-p195/gems/pg-0.15.1/lib/pg.rb:4:in `<top (required)>'
/Users/<username>/.rvm/gems/ruby-2.0.0-p195/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `require'
/Users/<username>/.rvm/gems/ruby-2.0.0-p195/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `block (2 levels) in require'
/Users/<username>/.rvm/gems/ruby-2.0.0-p195/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `each'
/Users/<username>/.rvm/gems/ruby-2.0.0-p195/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `block in require'
/Users/<username>/.rvm/gems/ruby-2.0.0-p195/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `each'
/Users/<username>/.rvm/gems/ruby-2.0.0-p195/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `require'
/Users/<username>/.rvm/gems/ruby-2.0.0-p195/gems/bundler-1.3.5/lib/bundler.rb:132:in `require'
/Users/<username>/rails/<appname>/config/application.rb:7:in `<top (required)>'
/Users/<username>/rails/<appname>/Rakefile:4:in `require'
/Users/<username>/rails/<appname>/Rakefile:4:in `<top (required)>'
/Users/<username>/.rvm/gems/ruby-2.0.0-p195#global/gems/rake-10.1.0/lib/rake/rake_module.rb:25:in `load'
/Users/<username>/.rvm/gems/ruby-2.0.0-p195#global/gems/rake-10.1.0/lib/rake/rake_module.rb:25:in `load_rakefile'
/Users/<username>/.rvm/gems/ruby-2.0.0-p195#global/gems/rake-10.1.0/lib/rake/application.rb:637:in `raw_load_rakefile'
/Users/<username>/.rvm/gems/ruby-2.0.0-p195#global/gems/rake-10.1.0/lib/rake/application.rb:94:in `block in load_rakefile'
/Users/<username>/.rvm/gems/ruby-2.0.0-p195#global/gems/rake-10.1.0/lib/rake/application.rb:165:in `standard_exception_handling'
/Users/<username>/.rvm/gems/ruby-2.0.0-p195#global/gems/rake-10.1.0/lib/rake/application.rb:93:in `load_rakefile'
/Users/<username>/.rvm/gems/ruby-2.0.0-p195#global/gems/rake-10.1.0/lib/rake/application.rb:77:in `block in run'
/Users/<username>/.rvm/gems/ruby-2.0.0-p195#global/gems/rake-10.1.0/lib/rake/application.rb:165:in `standard_exception_handling'
/Users/<username>/.rvm/gems/ruby-2.0.0-p195#global/gems/rake-10.1.0/lib/rake/application.rb:75:in `run'
bin/rake:4:in `<main>'
config/application.rb:7 refers to:
Bundler.require(:default, Rails.env)
This comes on the heals of a couple environment issues that are, I'm sure, causing the issue, but I don't know how. Basically, I was having issues with homebrew (brew install wget wouldn't work, complaining it was already downloaded, but then saying:
checking for libssl... no
configure: error: --with-ssl=openssl was given, but SSL is not available
So I uninstalled homebrew, uninstalled my shell (fish shell), reinstalled both, and tried to start things from scratch. Probably not a great idea, in retrospect. I seem to have messed things up worse than they already were.
brew doctor seems to think most things are OK, though. The only thing that jumps out at me as possibly related is:
/Users/sasha/.rvm/bin/pkg-config
(There's another thing brought up -- "/usr/bin occurs before /usr/local/bin", but this only applies to the node, npm, and gcov-4.2 installs, which don't seem relevant to this Rails issue.)
And I think RVM is supposed to have its own pkg-config install, right?
At any rate, OpenSSL is installed and updated by homebrew, and looking good (it shows up in brew list). Also, my XCode Command Line Tools is up to date as well.
I guess my question is if anyone has any idea what's going on? I've tried reordering my path to comply with brew doctor, un/reinstalling lots of things, updating everything, etc, and this just won't go away. Super frustrating, cause I basically can't do anything without rake working. And I think this dylib and openssl issue might be interrelated, so I figured I'd just dump all this data here.
Any ideas? I'd really appreciate help.
Thanks!
EDIT -- This is using Rails 4.0, with the pg gem.
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.0.rc1'
# Use postgresql as the database for Active Record
gem 'pg'
if that makes any difference.
UPDATE -- Seems to be related to this problem, which I'm also having. I think rake is not working because of pg, which isn't working because of crpyto/openssl.
The problem was based on an inexplicably empty libssl.dylib file. There was a backup (libssl.dylib.BAK), and I just overwrote the empty file with it and -- poof -- all the problems went away. No idea how that happened in the first place, but if anyone's having similar problems, I'd look for .BAK files in usr/lib/ and (if there are any) see if the associated files are empty.
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.
The other night I took a stab at getting Hudson up and running on an EC2 instance. Everything was running fine and dandy until this morning when I created an AMI based on what I had created. Doing that also created a snapshot of my drive.
After that I realized that my Jenkins server wasn't running. Sure enough, looking at my ssh instance, I had been disconnected. So I logged back in and tried to start things up by running Jenkins server and this is what I got for an error:
/home/ubuntu/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems.rb:1064:in `escape': can't convert Pathname to String (TypeError)
from /home/ubuntu/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems.rb:1064:in `block in loaded_path?'
from /home/ubuntu/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems.rb:1063:in `each'
from /home/ubuntu/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems.rb:1063:in `find'
from /home/ubuntu/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems.rb:1063:in `loaded_path?'
from /home/ubuntu/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:35:in `require'
from /home/ubuntu/.rvm/gems/ruby-1.9.2-p180/gems/httparty-0.6.1/lib/httparty.rb:10:in `<top (required)>'
from /home/ubuntu/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:54:in `require'
from /home/ubuntu/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:54:in `require'
from /home/ubuntu/.rvm/gems/ruby-1.9.2-p180/gems/jenkins-0.6.2/lib/jenkins/api.rb:1:in `<top (required)>'
from /home/ubuntu/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:54:in `require'
from /home/ubuntu/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:54:in `require'
from /home/ubuntu/.rvm/gems/ruby-1.9.2-p180/gems/jenkins-0.6.2/lib/jenkins.rb:3:in `<module:Jenkins>'
from /home/ubuntu/.rvm/gems/ruby-1.9.2-p180/gems/jenkins-0.6.2/lib/jenkins.rb:1:in `<top (required)>'
from /home/ubuntu/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:54:in `require'
from /home/ubuntu/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:54:in `require'
from /home/ubuntu/.rvm/gems/ruby-1.9.2-p180/gems/jenkins-0.6.2/bin/jenkins:4:in `<top (required)>'
from /home/ubuntu/.rvm/gems/ruby-1.9.2-p180/bin/jenkins:19:in `load'
from /home/ubuntu/.rvm/gems/ruby-1.9.2-p180/bin/jenkins:19:in `<main>'
I did use a walkthrough to get this setup, and have referenced back to it to see if missed something, but it's pretty straight forward. I've googled for the can't convert Pathname to String with no luck as well. I honestly have no clue where to even start looking into this one. Is it a Ruby issue? Rails? Jenkins?
I'll update this if i find any other useful info.
EDIT
I should also add that I did go into the workspace of the project that I had Jenkins building and was able to start it up just fine. Because of that I don't think this is a Ruby issue.
EDIT 2
Ok, so I decided to take EC2 out of the equation and brought up my own server with Ubuntu 10.10. Same setup, everything worked great, then I rebooted, and now I get this error again. Now I'm confident it's a simple silly mistake due to me being a relative Ubuntu newb, but I'm sure someone else has ran into this before.
For a quick fix, try downgrading rubygems to less than 1.6.
Looks like the rubygems devs introduced some code to avoid loading a file more than once.
If you're interested, here's the offending code (from https://github.com/rubygems/rubygems.git at rev dcfba4e1de4c7388425eb5de5066cb5aa9bea6e6):
def self.loaded_path? path
# TODO: ruby needs a feature to let us query what's loaded in 1.8 and 1.9
$LOADED_FEATURES.find { |s|
s =~ /(^|\/)#{Regexp.escape path}#{Regexp.union(*Gem.suffixes)}$/
}
end
If you're unable to downgrade, a less ideal solution is to edit rubygems.rb so
Regexp.escape path
becomes
Regexp.escape path.to_s
Long story short, the solution was to install Jenkins as apt-get instead of using the Gem. It appears that it came down to an issue where Jenkins was looking at the wrong version of Ruby.
This URL is what ultimately got me started down the path to fix this: http://www.ygamretuta.com/2011/03/ruby-installing-ramaze-working-around-cant-convert-pathname-to-string-error/
I should also add that although the answers that Kelvin gave may have gotten me around the error, neither were ideal solutions to the problem.