I'm trying to use the Ruby wrapper gem for Taglib to play around with ID3 Tags in a practice program. I'm getting Load Errors regarding the requiring of the taglib ruby gem.
I've installed the gem into my project via RubyGems and am simply requiring the gem as stated in a number of posts:
require 'taglib'
These are the software versions I'm working with:
- ruby 2.0.0p481
- taglib-ruby (0.7.1)
- taglib-1.9.1
I'm on a Mac with Mavericks 10.9.5, using RubyMine as my IDE. I'm not sure if my installation is correct for taglib (the original, not the Ruby wrapper). I used Homebrew to download the .tar.gz file and then unzipped this. The Taglib 1.10 folder is sitting in my local downloads folder - should this be placed somewhere else?
As mentioned, I'm requiring 'taglib' at the top of my .rb file. The error I'm getting when trying to run this file is:
'require': cannot load such file -- taglib (LoadError)
I'm pretty new to Ruby and SO so anything else I need to clarify, please ask. Any help would be appreciated, thanks a lot.
When you require a file, the file must be either in your
$LOAD_PATH
variable for Ruby, or explicitly indicated in the require string.The error that you posted is specific to this. The require command leaves off the extension, as it will load other types of files other than Ruby if they are available. See the documentation on the
require
method for more information.If you have installed the library in
~/my_projects/music_analyzer/taglib_unzip_folder
then you can userequire '~/my_projects/music_analyzer/taglib_unsip_folder/taglib
and the error messages should change.If you have installed the gem, and are using rvm, you should not use
sudo
, but should usegem install taglib-ruby
And in this case you would not need to specify the folder name, as the path would be included in Ruby's load path.
If you are using an IDE, and that IDE is not using the same environment, then you will end up with load problems, as your installation and the IDE's environment may not be identical.
Instead of using the IDE, you can test these things out right at the terminal, using irb.