Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installed gem but getting cannot load such file

I have done the following

gem install crack

And added

gem 'crack'

To my gemfile.

I am then requiring require 'crack'

The error I get when I try and load the route is

cannot load such file -- crack

I have run gem environment and get the following

RubyGems Environment:
- RUBYGEMS VERSION: 2.2.2
- RUBY VERSION: 2.1.0 (2013-12-25 patchlevel 0) [x86_64-darwin12.0]
- INSTALLATION DIRECTORY: /Users/joshuahornby/.rvm/gems/ruby-2.1.0
- RUBY EXECUTABLE: /Users/joshuahornby/.rvm/rubies/ruby-2.1.0/bin/ruby
- EXECUTABLE DIRECTORY: /Users/joshuahornby/.rvm/gems/ruby-2.1.0/bin
- SPEC CACHE DIRECTORY: /Users/joshuahornby/.gem/specs
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-12
- GEM PATHS:
 - /Users/joshuahornby/.rvm/gems/ruby-2.1.0
 - /Users/joshuahornby/.rvm/gems/ruby-2.1.0@global
- GEM CONFIGURATION:
 - :update_sources => true
 - :verbose => true
 - :backtrace => false
 - :bulk_threshold => 1000
 - "gem" => "--no-document"
- REMOTE SOURCES:
 - https://rubygems.org/
- SHELL PATH:
 - /Users/joshuahornby/.rvm/gems/ruby-2.1.0/bin
 - /Users/joshuahornby/.rvm/gems/ruby-2.1.0@global/bin
 - /Users/joshuahornby/.rvm/rubies/ruby-2.1.0/bin
 - /Users/joshuahornby/.rvm/bin
 - /Applications/MAMP/bin/php/php5.5.3/bin
 - /usr/bin
 - /bin
 - /usr/sbin
 - /sbin
 - /usr/local/bin

Error trace

activesupport (4.0.3) lib/active_support/dependencies.rb:229:in `require'
activesupport (4.0.3) lib/active_support/dependencies.rb:229:in `block in require'
activesupport (4.0.3) lib/active_support/dependencies.rb:212:in `block in load_dependency'
activesupport (4.0.3) lib/active_support/dependencies.rb:616:in `new_constants_in'
activesupport (4.0.3) lib/active_support/dependencies.rb:212:in `load_dependency'
activesupport (4.0.3) lib/active_support/dependencies.rb:229:in `require'
app/controllers/currencies_controller.rb:3:in `<class:CurrenciesController>'
app/controllers/currencies_controller.rb:1:in `<top (required)>'
activesupport (4.0.3) lib/active_support/dependencies.rb:424:in `load'
activesupport (4.0.3) lib/active_support/dependencies.rb:424:in `block in load_file'
activesupport (4.0.3) lib/active_support/dependencies.rb:616:in `new_constants_in'
activesupport (4.0.3) lib/active_support/dependencies.rb:423:in `load_file'
activesupport (4.0.3) lib/active_support/dependencies.rb:324:in `require_or_load'
activesupport (4.0.3) lib/active_support/dependencies.rb:463:in `load_missing_constant'
activesupport (4.0.3) lib/active_support/dependencies.rb:184:in `const_missing'
activesupport (4.0.3) lib/active_support/inflector/methods.rb:226:in `const_get'
activesupport (4.0.3) lib/active_support/inflector/methods.rb:226:in `block in constantize'
activesupport (4.0.3) lib/active_support/inflector/methods.rb:224:in `each'
activesupport (4.0.3) lib/active_support/inflector/methods.rb:224:in `inject'
activesupport (4.0.3) lib/active_support/inflector/methods.rb:224:in `constantize'
activesupport (4.0.3) lib/active_support/dependencies.rb:535:in `get'
activesupport (4.0.3) lib/active_support/dependencies.rb:566:in `constantize'
actionpack (4.0.3) lib/action_dispatch/routing/route_set.rb:76:in `controller_reference'
actionpack (4.0.3) lib/action_dispatch/routing/route_set.rb:66:in `controller'
actionpack (4.0.3) lib/action_dispatch/routing/route_set.rb:44:in `call'
actionpack (4.0.3) lib/action_dispatch/journey/router.rb:71:in `block in call'
actionpack (4.0.3) lib/action_dispatch/journey/router.rb:59:in `each'
actionpack (4.0.3) lib/action_dispatch/journey/router.rb:59:in `call'
actionpack (4.0.3) lib/action_dispatch/routing/route_set.rb:680:in `call'
rack (1.5.2) lib/rack/etag.rb:23:in `call'
rack (1.5.2) lib/rack/conditionalget.rb:25:in `call'
rack (1.5.2) lib/rack/head.rb:11:in `call'
actionpack (4.0.3) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
activerecord (4.0.3) lib/active_record/query_cache.rb:36:in `call'
 activerecord (4.0.3) lib/active_record/connection_adapters/abstract/connection_pool.rb:626:in `call'
 activerecord (4.0.3) lib/active_record/migration.rb:369:in `call'
 actionpack (4.0.3) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
 activesupport (4.0.3) lib/active_support/callbacks.rb:373:in `_run__3271670212178920711__call__callbacks'
 activesupport (4.0.3) lib/active_support/callbacks.rb:80:in `run_callbacks'
 actionpack (4.0.3) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
 actionpack (4.0.3) lib/action_dispatch/middleware/reloader.rb:64:in `call'
 actionpack (4.0.3) lib/action_dispatch/middleware/remote_ip.rb:76:in `call'
 actionpack (4.0.3) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
 actionpack (4.0.3) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
 railties (4.0.3) lib/rails/rack/logger.rb:38:in `call_app'
 railties (4.0.3) lib/rails/rack/logger.rb:20:in `block in call'
 activesupport (4.0.3) lib/active_support/tagged_logging.rb:67:in `block in tagged'
 activesupport (4.0.3) lib/active_support/tagged_logging.rb:25:in `tagged'
 activesupport (4.0.3) lib/active_support/tagged_logging.rb:67:in `tagged'
 railties (4.0.3) lib/rails/rack/logger.rb:20:in `call'
 actionpack (4.0.3) lib/action_dispatch/middleware/request_id.rb:21:in `call'
 rack (1.5.2) lib/rack/runtime.rb:17:in `call'
 activesupport (4.0.3) lib/active_support/cache/strategy/local_cache.rb:83:in `call'
rack (1.5.2) lib/rack/lock.rb:17:in `call'
actionpack (4.0.3) lib/action_dispatch/middleware/static.rb:64:in `call'
railties (4.0.3) lib/rails/engine.rb:511:in `call'
railties (4.0.3) lib/rails/application.rb:97:in `call'
rack (1.5.2) lib/rack/lock.rb:17:in `call'
rack (1.5.2) lib/rack/content_length.rb:14:in `call'
rack (1.5.2) lib/rack/handler/webrick.rb:60:in `service'
/Users/joshuahornby/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/webrick/httpserver.rb:138:in `service'
/Users/joshuahornby/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/webrick/httpserver.rb:94:in `run'
/Users/joshuahornby/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/webrick/server.rb:295:in `block in start_thread'
This error occurred while loading the following files:
crack

I am guessing it something to do with my ruby version?

like image 936
joshuahornby10 Avatar asked Feb 21 '14 23:02

joshuahornby10


People also ask

How do I run a gem file?

run the command bundle install in your shell, once you have your Gemfile created. This command will look your Gemfile and install the relevant Gems on the indicated versions. The Gemfiles are installed because in your Gemfile you are pointing out the source where the gems can be downloaded from.

What is gem file format?

Vector image format used by GEM Draw, a basic drawing program for PCs; GEM stands for "Graphical Environment Manager," and was a windowing system used by Atari ST computers and some Windows-based computers.


1 Answers

Your Gem Path is referring to Ruby 2.1.0

- GEM PATHS:
 - /Users/joshuahornby/.rvm/gems/ruby-2.1.0

whereas crack gem is installed for Ruby 2.0.0-p353

/Users/joshuahornby/.rvm/gems/ruby-2.0.0-p353/gems/crack-0.4.2

This is the problem. I simulated the same installation like yours and my GEM_PATH matches to the crack gem path.

Here is what I recommend. First uninstall the gem crack. In your application path run rvm use 2.1.0 and then do bundle install.

like image 85
Kirti Thorat Avatar answered Sep 23 '22 14:09

Kirti Thorat