In 'Require': No Such File to Load -- Iconv (Loaderror)

in `require': no such file to load -- iconv (LoadError)

It shows that the iconv not exist but the iconv has installed in my production env.

root@AY130/current# iconv --version
iconv (Ubuntu EGLIBC 2.15-0ubuntu10.4) 2.15
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Ulrich Drepper.

To resolve it, add this in your Gemfile:

gem "iconv", "~> 1.0.3"

Then run bundle install.

Note: iconv has been deprecated for a while. It is replaced by (builtin) String#encode

See here: https://bbs.archlinux.org/viewtopic.php?id=160369

in `require': cannot load such file -- iconv (LoadError)

This error:

ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in
`require': cannot load such file -- iconv (LoadError)

says that the ruby Standard Library module iconv cannot be found. That's because iconv no longer exists in ruby's Standard Library in ruby 2.2.

The line:

gem "iconv", "~> 1.0.3"

is supposed to go in a Gemfile, which is a file that is created when you create a rails project. In a rails project, you install all the gems listed in your Gemfile using Bundler, e.g.:

$ bundle install

`require': no such file to load -- mkmf (LoadError)

After some search for a solution it turns out the -dev package is needed, not just ruby1.8. So if you have ruby1.9.1 doing

sudo apt-get install ruby1.9.1-dev

or to install generic ruby version, use (as per @lamplightdev comment):

sudo apt-get install ruby-dev

should fix it.

Try locate mkmf to see if the file is actually there.

Ruby - Cannot Load File (LoadError)

You're missing iconv in your system, or your version doesn't match requirements from other packages.

Check if you have iconv installed

iconv --version

or

which iconv

Install iconv gem

gem install iconv

or

rvm pkg install iconv

If nothing works, try older/other versions

gem install iconv -v '~> 1.0.3'

Cannot run rails server -- `require``main`

It shows that the iconv not exist. I guess that you are missing gem "iconv", "~> 1.0.3".

Add this gem "iconv", "~> 1.0.3" to your Gemfile and run bundle install

Rails 4.0 install error -require: cannot load such file -- active_support (LoadError)

My problem was permission related. Somehow, the "other" user needs rx permissions.
I did the following and it works now:

sudo chmod -R o+rx /usr/local/lib/ruby/gems/2.0.0/gems/

If you getting cannot load such file and its pointing to require statement, check your permissions for /gems folder and folders underneat.

Ruby 2.0 iconv replacement

Iconv was deprecated (removed) in 1.9.3.
You can still install it.

Reference Material if you unsure:
https://rvm.io/packages/iconv/

However the suggestion is that you don't and rather use:

string.encode("UTF-8", :invalid => :replace, :undef => :replace, :replace => "?")

API



Related Topics



Leave a reply



Submit