Trying to run "ruby app.rb", but can not load oauth2 - ruby-on-rails

Complete beginner to programming here. I'm trying to run ruby app.rb and I get the following error:
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- oauth2 (LoadError)
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/dankearns/projects/wgc_groundwork/lib/profile.rb:1:in `<top (required)>'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from app.rb:2:in `<main>'
This is really driving me insane. I've tried a number of fixes but not seem to work. Can anyone help?

ERROR: While executing gem ... (Errno::EACCES) Permission denied - /Library/Ruby/Gems/2.0.0/gems/multipart-post-2.0.0
You're trying to install code into your Apple-installed Ruby.
Don't do that.
Instead, use rbenv or RVM to install Ruby in a sandbox, which you can then play with to your heart's content. If you go with RVM, read the installation page completely. People failing to do what that page says, or what RVM says after it's on the disk, results in one of the top RVM problems on Stack Overflow.
Apple installed theirs for their convenience and it's OK for us to use it, but changing it can lead to problems, especially if you remove something it or some other app needs.

Related

Ruby on Rail 5.2 Can't start server. Lots of errors I don't understand

Working my way through a RoR tutorial. All was well until yesterday when I came across a bunch or errors that I can't understand. It looks like an openssl issue, but what I've read of that involves stuff I'm not using. I didn't add or update any gems. In fact, git shows no changes since my last commit which was working prior to yesterday. Any thoughts? What could have changed from one day to the next. I think the only thing I did was update postgresql using Homebrew. Might that have had some negative Thanks.
/usr/local/Cellar/ruby/2.5.0/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require': dlopen(/usr/local/Cellar/ruby/2.5.0/lib/ruby/2.5.0/x86_64-darwin17/digest/md5.bundle, 9): Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib (LoadError)
Referenced from: /usr/local/Cellar/ruby/2.5.0/lib/ruby/2.5.0/x86_64-darwin17/digest/md5.bundle
Reason: image not found - /usr/local/Cellar/ruby/2.5.0/lib/ruby/2.5.0/x86_64-darwin17/digest/md5.bundle
from /usr/local/Cellar/ruby/2.5.0/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'
from /usr/local/lib/ruby/gems/2.5.0/gems/rubocop-0.54.0/lib/rubocop/processed_source.rb:3:in `<top (required)>'
from /usr/local/lib/ruby/gems/2.5.0/gems/rubocop-0.54.0/lib/rubocop.rb:613:in `require_relative'
from /usr/local/lib/ruby/gems/2.5.0/gems/rubocop-0.54.0/lib/rubocop.rb:613:in `<top (required)>'
from /usr/local/Cellar/ruby/2.5.0/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'
from /usr/local/Cellar/ruby/2.5.0/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'
from /usr/local/lib/ruby/gems/2.5.0/gems/rubocop-0.54.0/bin/rubocop:6:in `<top (required)>'
from /usr/local/bin/rubocop:23:in `load'
from /usr/local/bin/rubocop:23:in `<main>'
looks like you need to install openssl
in macOS you can do it with brew install openssl and than install your gems again with brew install --force to make sure that the correct library path was used during the compilation
in case it won't work try installing openssl version 1.0 (since that's the version mention in the stacktrace) with brew install openssl#1.0 and then reinstalling your gems again
did you upgrade your OS? or did it happen by itself maybe?

Rails not running after Ruby update (possibly RVM related)

I resorted to upgrading Ruby from 2.3.0 to 2.3.1 because of a really weird error I was getting and not being able to even come close to finding more info around google/SO.
Now after trying to figure this out I am getting this error whenever I try to run the project, or run bundle or rails in bash
/usr/local/rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:127:in `require': cannot load such file -- bundler (LoadError)
from /usr/local/rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:127:in `rescue in require'
from /usr/local/rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:40:in `require'
from /usr/local/rvm/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.16.0/exe/bundle:10:in `<top (required)>'
from /usr/local/rvm/gems/ruby-2.3.1/bin/bundle:23:in `load'
from /usr/local/rvm/gems/ruby-2.3.1/bin/bundle:23:in `<main>'
from /usr/local/rvm/gems/ruby-2.3.1/bin/ruby_executable_hooks:15:in `eval'
from /usr/local/rvm/gems/ruby-2.3.1/bin/ruby_executable_hooks:15:in `<main>'
I have already tried reinstalling Ruby, RVM, bundler, but the error persists. I cannot find much info on that specific error around the web so I hope someone can help me troubleshoot this through here. Let me know if there are any specific logs I can provide and I will happily add more info.
EDIT:
I just noticed the path is ...ruby-2.3.1/lib/ruby/ 2.3.0 ... (the difference of 2.3.1 and 2.3.0)
When I upgraded to 2.3.1 I uninstalled previous versions. Could that be an issue since the error comes from a path that refers to a non-existing version of ruby?
Not sure why all this happened and what was wrong with the bundler, but what ended up fixing it for me was this command:
gem update --system

Ruby cannot load such file -- dm--adapter (LoadError)

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.

Bundle Install Fails: Error loading Rubygems plugin after I deleted files

I am new to Ruby and Rails and am trying to get through the Hartl rails web development tutorial. During the course of the tutorial, I installed homebrew. After running brew doctor, homebrew instructed me to delete a handful of files unless I had put them where they were at on purpose. I deleted them and brew doctor said I was all clear.
Now, further along in the tutorial I am trying to deploy an app to Heroku. But I've found out that my gemfile.lock file was never updated by bundle install. In fact, bundle install hadn't been working for me at all. The error output is below. It appears to be related to one of the files I deleted (I base this on the line Library not loaded: /opt/local/lib/libssl.1.0.0.dylib; I remember deleting that file).
How do I fix this? From my research, I think I need to reinstall something, but I can't figure out what. I installed Postgresql, but that did nothing.
Secondarily, was deleting all of those files a huge mistake? How can I get them back (I also can't scroll up enough in my Terminal to see their names)? Would homebrew have worked if I had left them alone even though brew doctor raised concerns about them?
Wyatts-MacBook-Pro:first_app Wyatt$ bundle installError loading RubyGems plugin "/Users/Wyatt/.rvm/gems/ruby-2.0.0-p247#global/gems/rubygems-bundler-1.2.2/lib/rubygems_plugin.rb": dlopen(/Users/Wyatt/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/x86_64-darwin11.4.2/openssl.bundle, 9): Library not loaded: /opt/local/lib/libssl.1.0.0.dylib
Referenced from: /Users/Wyatt/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/x86_64-darwin11.4.2/openssl.bundle
Reason: image not found - /Users/Wyatt/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/x86_64-darwin11.4.2/openssl.bundle (LoadError)
/Users/Wyatt/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require': dlopen(/Users/Wyatt/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/x86_64-darwin11.4.2/digest/sha1.bundle, 9): Library not loaded: /opt/local/lib/libssl.1.0.0.dylib (LoadError)
Referenced from: /Users/Wyatt/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/x86_64-darwin11.4.2/digest/sha1.bundle
Reason: image not found - /Users/Wyatt/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/x86_64-darwin11.4.2/digest/sha1.bundle
from /Users/Wyatt/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
from /Users/Wyatt/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/definition.rb:1:in `<top (required)>'
from /Users/Wyatt/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler.rb:148:in `definition'
from /Users/Wyatt/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/cli.rb:245:in `install'
from /Users/Wyatt/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/vendor/thor/task.rb:27:in `run'
from /Users/Wyatt/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/vendor/thor/invocation.rb:120:in `invoke_task'
from /Users/Wyatt/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/vendor/thor.rb:344:in `dispatch'
from /Users/Wyatt/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/vendor/thor/base.rb:434:in `start'
from /Users/Wyatt/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/bin/bundle:20:in `block in <top (required)>'
from /Users/Wyatt/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/friendly_errors.rb:3:in `with_friendly_errors'
from /Users/Wyatt/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/bin/bundle:20:in `<top (required)>'
from /Users/Wyatt/.rvm/gems/ruby-2.0.0-p247#global/bin/bundle:23:in `load'
from /Users/Wyatt/.rvm/gems/ruby-2.0.0-p247#global/bin/bundle:23:in `<main>'
from /Users/Wyatt/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/bin/ruby_noexec_wrapper:14:in `eval'
from /Users/Wyatt/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/bin/ruby_noexec_wrapper:14:in `<main>'
Thanks to Nick Veys for this answer:
I just had to run brew reinstall openssl to replace the missing library.

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.

Resources