cannot load such file error in making app in ruby - ruby

While making an application in ruby on rails I got the following error:
ajeet#ajeetpc:~$ rails new first_app
/home/ajeet/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- active_support (LoadError)
from /home/ajeet/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/lib/ruby/vendor_ruby/railties/lib/rails_generator.rb:30:in `<top (required)>'
from /home/ajeet/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /home/ajeet/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/lib/ruby/vendor_ruby/railties/bin/rails:16:in `<main>'

Seems like the rails gem is not installed properly. Try to fix it
gem uninstall rails
gem install rails
then run rails new first_app again.

Related

Ruby bundler installs puma gem but puma cannot then find it's extensions

I'm trying to install and run puma.
My gemfile has the local extracted gems (the server has no internet access and bundler is install via gem install):
gem 'rack', '=2.0.3', :path => "/opt/app-root/src/gems/rack-2.0.3"
gem 'puma', '=3.11.0', :path => "/opt/app-root/src/gems/puma-3.11.0"
I run bundle like so:
bundle install --local --path ./bundle --deployment
Which produces:
Using bundler 1.16.1
Using puma 3.11.0 from source at `/opt/app-root/src/gems/puma-3.11.0`
Using rack 2.0.3 from source at `/opt/app-root/src/gems/rack-2.0.3`
Bundle complete! 2 Gemfile dependencies, 3 gems now installed.
Bundled gems are installed into `./bundle`
Then running:
bundle exec "puma --config puma.cfg"
Produces the problem with the missing ext:
/opt/app-root/src/gems/puma-3.11.0/lib/puma/server.rb:15:in `require': cannot load such file -- puma/puma_http11 (LoadError)
from /opt/app-root/src/gems/puma-3.11.0/lib/puma/server.rb:15:in `<top (required)>'
from /opt/app-root/src/gems/puma-3.11.0/lib/puma/runner.rb:1:in `require'
from /opt/app-root/src/gems/puma-3.11.0/lib/puma/runner.rb:1:in `<top (required)>'
from /opt/app-root/src/gems/puma-3.11.0/lib/puma/cluster.rb:1:in `require'
from /opt/app-root/src/gems/puma-3.11.0/lib/puma/cluster.rb:1:in `<top (required)>'
from /opt/app-root/src/gems/puma-3.11.0/lib/puma/launcher.rb:4:in `require'
from /opt/app-root/src/gems/puma-3.11.0/lib/puma/launcher.rb:4:in `<top (required)>'
from /opt/app-root/src/gems/puma-3.11.0/lib/puma/cli.rb:5:in `require'
from /opt/app-root/src/gems/puma-3.11.0/lib/puma/cli.rb:5:in `<top (required)>'
from /opt/app-root/src/gems/puma-3.11.0/bin/puma:6:in `require'
from /opt/app-root/src/gems/puma-3.11.0/bin/puma:6:in `<top (required)>'
from /opt/app-root/src/ruby/vendor/bundle/ruby/2.4.0/bin/puma:22:in `load'
from /opt/app-root/src/ruby/vendor/bundle/ruby/2.4.0/bin/puma:22:in `<main>'
I can find very little information about this issue, except this post https://github.com/bundler/bundler/issues/5398 which may or may not be a similar issue - but I don't know how to resolve it (re-running bundler install doesn't help me!)
By the way, the ext is present in the extracted gem as you'd expect:
opt/app-root/src/gems/puma-3.11.0/ext/puma_http11
The puma11 stuff in ext is a compiled library; the result of that compilation as puma_http11.bundle then gets copied to the lib/puma directory, as part of the installation process. Do you have this .bundle file?
I'm guessing you have a problem or missing steps in your local extraction process to build or copy the native code portions of Gems (including this one) - the Rakefile in the puma repository on Github includes steps to build the native pieces using ragel.

Ruby Gem Scrypt 2.1.1 won't install on Windows

I'm asked to look at some Ruby code. The developers run OSX, I'm on Windows. All is working fine on OSX, but I get an error with Scrypt 2.1.1.
I'm asked by Ruby to run: gem install scrypt -v '2.1.1' which results in an error.
When I do gem install scrypt -v '2.1.1' --platform=ruby it's quite the opposite and all the gem is installed.
Now when I recreate the GemFile or update it, I still get an error and it's again suggested to run gem install scrypt -v '2.1.1'.
The output I'm getting is:
Installing scrypt 2.1.1 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: <MyProject>/vendor/bundle/ruby/2.3.0/gems/scrypt-2.1.1/ext/scrypt
C:/Ruby23-x64/bin/ruby.exe -rubygems <MyProject>/vendor/bundle/ruby/2.3.0/gems/rake-11.2.2/exe/rake RUBYARCHDIR=<MyProject>/vendor/bundle/ruby/2.3.0/extensions/x64-mingw32/2.3.0/scrypt-2.1.1 RUBYLIBDIR=<MyProject>/vendor/bundle/ruby/2.3.0/extensions/x64-mingw32/2.3.0/scrypt-2.1.1
rake aborted!
LoadError: cannot load such file -- ffi_c
<MyProject>/vendor/bundle/ruby/2.3.0/gems/ffi-1.9.10-x64-mingw32/lib/ffi.rb:6:in `rescue in <top (required)>'
<MyProject>/vendor/bundle/ruby/2.3.0/gems/ffi-1.9.10-x64-mingw32/lib/ffi.rb:3:in `<top (required)>'
<MyProject>/vendor/bundle/ruby/2.3.0/gems/ffi-compiler-0.1.3/lib/ffi-compiler/compile_task.rb:4:in `<top (required)>'
<MyProject>/vendor/bundle/ruby/2.3.0/gems/scrypt-2.1.1/ext/scrypt/Rakefile:1:in `<top (required)>'
<MyProject>/vendor/bundle/ruby/2.3.0/gems/rake-11.2.2/exe/rake:27:in `<main>'
LoadError: cannot load such file -- 2.3/ffi_c
<MyProject>/vendor/bundle/ruby/2.3.0/gems/ffi-1.9.10-x64-mingw32/lib/ffi.rb:4:in `<top (required)>'
<MyProject>/vendor/bundle/ruby/2.3.0/gems/ffi-compiler-0.1.3/lib/ffi-compiler/compile_task.rb:4:in `<top (required)>'
<MyProject>/vendor/bundle/ruby/2.3.0/gems/scrypt-2.1.1/ext/scrypt/Rakefile:1:in `<top (required)>'
<MyProject>/vendor/bundle/ruby/2.3.0/gems/rake-11.2.2/exe/rake:27:in `<main>'
LoadError: cannot load such file -- ffi-compiler/compile_task
<MyProject>/vendor/bundle/ruby/2.3.0/gems/scrypt-2.1.1/ext/scrypt/Rakefile:1:in `<top (required)>'
<MyProject>/vendor/bundle/ruby/2.3.0/gems/rake-11.2.2/exe/rake:27:in `<main>'
(See full trace by running task with --trace)
rake failed, exit code 1
Gem files will remain installed in <MyProject>/vendor/bundle/ruby/2.3.0/gems/scrypt-2.1.1 for inspection.
I've looked and searched on Google and Bing, but nothing resulted in a solution.
Hope somebody in the community here can help me find the resolution.
Thanks,
Iwan
gem install ffi --platform=ruby
gem install scrypt -v 2.2.1
Works for me.

Appium: Nokogiri giving load error while running test case

I have upgraded Ruby version to 2.1.0 from Ruby 1.8.7 and installed all dependencies to run a sample Appium test case using Ruby. But I am facing an issue to load nokogiri while running a test case.
I am using
OS: Mac OS - 1.9.2
Ruby: 2.1.0
Appium: 1.2.0
Nokogiri: 1.6.3.1
This works fine on Ruby: 1.8.7.
Error:
Users/.rvm/gems/ruby-2.1.0/ruby/2.1.0/gems/nokogiri-1.6.3.1/lib/nokogiri.rb:29:in `require': dlopen(/Users/.rvm/gems/ruby-2.1.0/ruby/2.1.0/gems/nokogiri-1.6.3.1/lib/nokogiri/nokogiri.bundle, 9): Library not loaded: /Users/.rvm/rubies/ruby-2.1.0/lib/libruby.2.1.0.dylib (LoadError)
Referenced from: /Users/.rvm/gems/ruby-2.1.0/ruby/2.1.0/gems/nokogiri-1.6.3.1/lib/nokogiri/nokogiri.bundle
Reason: image not found - /Users/.rvm/gems/ruby-2.1.0/ruby/2.1.0/gems/nokogiri-1.6.3.1/lib/nokogiri/nokogiri.bundle
from /Users/.rvm/gems/ruby-2.1.0/ruby/2.1.0/gems/nokogiri-1.6.3.1/lib/nokogiri.rb:29:in `rescue in <top (required)>'
from /Users/.rvm/gems/ruby-2.1.0/ruby/2.1.0/gems/nokogiri-1.6.3.1/lib/nokogiri.rb:25:in `<top (required)>'
from /Users/.rvm/gems/ruby-2.1.0/ruby/2.1.0/gems/appium_lib-4.1.0/lib/appium_lib/driver.rb:4:in `require'
from /Users/.rvm/gems/ruby-2.1.0/ruby/2.1.0/gems/appium_lib-4.1.0/lib/appium_lib/driver.rb:4:in `<top (required)>'
from /Users/.rvm/gems/ruby-2.1.0/ruby/2.1.0/gems/appium_lib-4.1.0/lib/appium_lib.rb:28:in `require_relative'
from /Users/.rvm/gems/ruby-2.1.0/ruby/2.1.0/gems/appium_lib-4.1.0/lib/appium_lib.rb:28:in `<top (required)>'
from /Users/Documents/rslRuby/li_workspace/flagship_native_tests/UITestFramework/selenium/base/LI_framework.rb:32:in `require'
from /Users/Documents/rslRuby/li_workspace/flagship_native_tests/UITestFramework/selenium/base/LI_framework.rb:32:in `<top (required)>'
from /Users/.rvm/rubies/ruby-2.1.0/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/.rvm/rubies/ruby-2.1.0/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from samle_tests/sign_in_test.rb:10:in `<main>'
Possible Fix 1:
This usually happens when gems are linked wrong, i recommend trying to re-install ruby via rvm.
rvm reinstall 2.1
rvm use 2.1
Make sure all the gems are up to date by running(in your apps directory)
bundle install
Possible Fix 2:
Another common problem is to install rvm as a root user, if you've done this re install rvm.
You can uninstall rvm by running
rvm implode
Follow the steps on the website to install rvm

Inability to find a required service_manager gem

I'm working on some cucumber tests from The Cucumber Book. I've got the code that tries to use a transaction processor and there is a file with the following code:
require 'service_manager'
ServiceManager.start
This is on Mac OS X 10.6.8 using Ruby 1.9.2. When this file executes, I get the following:
no such file to load -- service_manager (LoadError)
/opt/local/lib/ruby1.9/site_ruby/1.9.1/rubygems/custom_require.rb:59:in `require'
/opt/local/lib/ruby1.9/site_ruby/1.9.1/rubygems/custom_require.rb:59:in `rescue in require'
/opt/local/lib/ruby1.9/site_ruby/1.9.1/rubygems/custom_require.rb:35:in `require'
/Users/gpollice/MyCucumber/ATMBookExample/features/support/services.rb:6:in `<top (required)>'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/cucumber-1.1.2/lib/cucumber/rb_support/rb_language.rb:143:in `load'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/cucumber-1.1.2/lib/cucumber/rb_support/rb_language.rb:143:in `load_code_file'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/cucumber-1.1.2/lib/cucumber/runtime/support_code.rb:171:in `load_file'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/cucumber-1.1.2/lib/cucumber/runtime/support_code.rb:83:in `block in load_files!'
The service_manager gem is installed in /opt/local/lib/ruby1.9/gems/1.9.1/gems as are other gems that the application uses. Until I added the code for this iteration, there were no problems. I've looked for reasons why the gem is not found and just can't figure out why. Any help would be appreciated.
It appears to be a load path issue.
Is require "rubygems" invoked prior to this require statement?
Also, if you're using bundler, you have to add this gem to your Gemfile, as bundler attempts to sandbox your dependencies. If you're using bundler, try the following after adding the gem to the Gemfile:
bundle exec rake cucumber

Help Getting Started with Mechanize

I'm new to Ruby and just installed Ruby for Windows.
I want to use the mechanize library (https://github.com/tenderlove/mechanize) and so I'm following the guide at https://github.com/tenderlove/mechanize/blob/master/GUIDE.rdoc.
On the Windows cmd line, I installed mechanize by using the cmd "gem install mechanize".
When I run the following code:
require 'rubygems'
require 'mechanize'
agent = Mechanize.new
I get the error:
<internal:lib/rubygems/custom_require>:29:in `require': no such file to load -- net/http/digest_auth (LoadError)
from <internal:lib/rubygems/custom_require>:29:in `require'
from C:/Ruby192/lib/ruby/1.9.1/mechanize.rb:5:in `<top (required)>'
from <internal:lib/rubygems/custom_require>:29:in `require'
from <internal:lib/rubygems/custom_require>:29:in `require'
from helloworld.rb:2:in `<main>'
Anybody know what's going on?
It seems that some dependencies are missing. Try to install the net-http-digest_auth gem.
gem install net-http-digest_auth
If that solves this problem and another (related) pops up, it's probable that you are missing the net-http-persistent gem. If that's the case, you know what to do! Just install it too.

Resources