Jump to content

The ultimate community for Ruby on Rails developers.


Photo

cannot load such file -- sqlite3/sqlite3_native (LoadError)

sqlite3

  • Please log in to reply
29 replies to this topic

#21 Tom

Tom

    Signalman

  • Members
  • 25 posts

Posted 17 August 2013 - 05:38 PM

yeeees, already did... doesn't solve the issue.

I've installed ruby and rails and gem and sqlite the same way I did some months ago, with rails 2.x... So I installed all the needed libraries...


Thanks

It's a clean install, 2.0.0, from the offiial website, ./configure, make, make install... any warning or errors appeared...

and debian wheezy is a clean install... So i just installed the following libraries, then ruby, gem, rails, gem sqlite3 and create a new project:

zlib1g zlib1g-dev build-essential sqlite3 libsqlite3-dev openssl libssl-dev libyaml-dev


First of all, you are installing at least two versions of Ruby and two versions of Rails from at least two different places.

The way to set up a system is to:

1. Install the basics from the repositories.
2. Install Ruby from source or using rbenv/RVM (if you use rbenv/RVM they will make sure you got the right repo packages).
3. Install Rails using Gems from that version of Ruby.

At no time should you overlap installations like getting Rails from the repositories.

It sounds to me like you've got some wild conflicts going based on the haphazard way you set up your system. You might be best off starting over and following a good tutorial to get your system going. Using a system like rbenv or RVM is often helpful unless you really understand Ruby at the source level.
  • james likes this

#22 cicolink

cicolink

    Signalman

  • Members
  • 17 posts

Posted 17 August 2013 - 08:21 PM

Would you mind sharing your application to GitHub or BitBucket for me to download and try on my machine?

 

 

This is not an application issue, it's an environment issue. Caused probably by the manual installation method used.

 

Could I recommend installing rvm then running  rvm requirements --autolibs=enable. This should get your OS set up the way it needs to be.

You can then remove rvm and carry on manually. This might give you the quick fix you need.

 

Yes in fact my application is just given by "rails new blog" :D that's all, nothing more...

 

 

First of all, you are installing at least two versions of Ruby and two versions of Rails from at least two different places.

The way to set up a system is to:

1. Install the basics from the repositories.
2. Install Ruby from source or using rbenv/RVM (if you use rbenv/RVM they will make sure you got the right repo packages).
3. Install Rails using Gems from that version of Ruby.

At no time should you overlap installations like getting Rails from the repositories.

It sounds to me like you've got some wild conflicts going based on the haphazard way you set up your system. You might be best off starting over and following a good tutorial to get your system going. Using a system like rbenv or RVM is often helpful unless you really understand Ruby at the source level.

 

How can you say I'm installing two versions of ruby? I'm using a fresh install of Debian Wheezy, I simply download the source code, config, make, make install... That's it, the same procedure I used many times with other computers.

 

Look what I get from the console:

 

which ruby
/usr/local/bin/ruby
root@debian:# which rails
/usr/local/bin/rails
root@debian:# which sqlite3
/usr/bin/sqlite3
 
I don't know...I mean, i've done everything really easy, needed libraries (sqlite3, libsqli3-dev), ruby from the source code, than rails, that's all... It should really work!
 
So i'm thinking maybe that there are some incompatibilities between the version: ruby 2.0.0, rails 4.0.0, sqlite 1.3.7... I've follow the same procedure some months ago, with ruby 1.9.x, rails 2.x, etc, and that worked perfectly...
 
I'm not going to use rbenv or other stuff, if I can't get working ruby in the easy/classical/clean mode ok, otherwise I'll switch to other web framework I already know... not too bad...
 
Anyway, thanks all, I appreciate ur help.


#23 Tom

Tom

    Signalman

  • Members
  • 25 posts

Posted 17 August 2013 - 10:10 PM


How can you say I'm installing two versions of ruby?


Because you said


So i just installed the following libraries, then ruby, gem, rails, gem sqlite3 and create a new project:
 
zlib1g zlib1g-dev build-essential sqlite3 libsqlite3-dev openssl libssl-dev libyaml-dev


And you also said


I've installed ruby and rails and gem and sqlite the same way I did some months ago, with rails 2.x... So I installed all the needed libraries...


This makes me believe you are instaling Rails from the repositories. You're using Rails 2.x which is very old but just so happens to be the current version in the Wheezy repos. You also say you installed gem. I don't know of any place you can possilby install Gems standalone anymore other than the Debian repos. This make me think you have two versions of Ruby running, one from the repos and one from source.

Now, I may be wrong and you may have meant you used gem to install rails but you just again said:


So i'm thinking maybe that there are some incompatibilities between the version: ruby 2.0.0, rails 4.0.0, sqlite 1.3.7... I've follow the same procedure some months ago, with ruby 1.9.x, rails 2.x, etc, and that worked perfectly...


I'm sure you know there is a huge difference between installing software from the repos and compiling it yourself. That's why it doesn't make sense when you say you followed the same procedure because it's really quite different.

Ruby 2.0 and Rails 4.0 work great together, I was just using them on a Wheezy system a few minutes ago.

Anyway, moving on,


which ruby
/usr/local/bin/ruby
root@debian:# which rails
/usr/local/bin/rails
root@debian:# which sqlite3
/usr/bin/sqlite3


That's good. I'm assuming you are sure that whatever app server you're using to run the Rails app has the same PATH as your terminal.

Let's assume that's all good, let's look at this error:
 
/usr/local/lib/ruby/gems/2.0.0/gems/sqlite3-1.3.7/lib/sqlite3.rb:6:in `require': cannot load such file -- sqlite3/sqlite3_native (LoadError)

So you've got the sqlite3 gem installed, looks like it's part of Ruby 2.0's gems, and looks like it's the version required by Rails 4. Great. But it's missing what appears to be a natively compiled part of the gem (to make it fast). When you ran bundle install, did you get any error messages? Usually you'll get an error message if you can't compile a native extension at that point. Usually that error will be because you didn't install the dev package (libsqlite3-dev). You said you have build-essential so you should be compiling fine. Did you have the libsqlite3-dev package installed before or after you ran bundle install? If it was after then you may not have been able to compile the native extension and that's why it's not there. Perhaps you tried to compile it, there was an error, you installed the dev package and tried again with success (no errors) but some other issue came up as a result.

 

Have you tried to just make a new Rails app in a different directory to see if something in yours might be corrupt?
 


I'm not going to use rbenv or other stuff, if I can't get working ruby in the easy/classical/clean mode ok, otherwise I'll switch to other web framework I already know... not too bad...


Unlike whatever language you know, Ruby development (including gems) moves very fast and backwards compatability is often sacrificed for innovation. That's why we have special tools in this community to handle that speed by maintaining an environment. RVM and rbenv are those tools.

 

This is a problem that can be solved, the question is not technical, it's one of will. The bottom line is you have a problem you can't fix right now. And so you can choose to solve the problem the hard way: fixing something you don't understand, or the easy way: redoing it the Ruby way that works for so many other people, many whom do not have the skills you have. Hopefully I can help you or someone else can help you but if you take the attitude that you refuse the easy way and you're willing to walk away if the hard way doesn't work then I don't think anyone can really help you in the end.

But if you do decide on something else, Laravel is pretty hot this month, and it's even closer to Rails than Yii (RIP). But it's just another Rails clone (or maybe a Sinatra clone) and it will never be as good as the real thing. Good luck.



#24 cicolink

cicolink

    Signalman

  • Members
  • 17 posts

Posted 18 August 2013 - 08:03 AM


Because you said
 

 



And you also said

 



This makes me believe you are instaling Rails from the repositories. You're using Rails 2.x which is very old but just so happens to be the current version in the Wheezy repos. You also say you installed gem. I don't know of any place you can possilby install Gems standalone anymore other than the Debian repos. This make me think you have two versions of Ruby running, one from the repos and one from source.

Now, I may be wrong and you may have meant you used gem to install rails but you just again said:

 



I'm sure you know there is a huge difference between installing software from the repos and compiling it yourself. That's why it doesn't make sense when you say you followed the same procedure because it's really quite different.

Ruby 2.0 and Rails 4.0 work great together, I was just using them on a Wheezy system a few minutes ago.

Anyway, moving on,

 



That's good. I'm assuming you are sure that whatever app server you're using to run the Rails app has the same PATH as your terminal.

Let's assume that's all good, let's look at this error:
 
/usr/local/lib/ruby/gems/2.0.0/gems/sqlite3-1.3.7/lib/sqlite3.rb:6:in `require': cannot load such file -- sqlite3/sqlite3_native (LoadError)

So you've got the sqlite3 gem installed, looks like it's part of Ruby 2.0's gems, and looks like it's the version required by Rails 4. Great. But it's missing what appears to be a natively compiled part of the gem (to make it fast). When you ran bundle install, did you get any error messages? Usually you'll get an error message if you can't compile a native extension at that point. Usually that error will be because you didn't install the dev package (libsqlite3-dev). You said you have build-essential so you should be compiling fine. Did you have the libsqlite3-dev package installed before or after you ran bundle install? If it was after then you may not have been able to compile the native extension and that's why it's not there. Perhaps you tried to compile it, there was an error, you installed the dev package and tried again with success (no errors) but some other issue came up as a result.

 

Have you tried to just make a new Rails app in a different directory to see if something in yours might be corrupt?
 

 



Unlike whatever language you know, Ruby development (including gems) moves very fast and backwards compatability is often sacrificed for innovation. That's why we have special tools in this community to handle that speed by maintaining an environment. RVM and rbenv are those tools.

 

This is a problem that can be solved, the question is not technical, it's one of will. The bottom line is you have a problem you can't fix right now. And so you can choose to solve the problem the hard way: fixing something you don't understand, or the easy way: redoing it the Ruby way that works for so many other people, many whom do not have the skills you have. Hopefully I can help you or someone else can help you but if you take the attitude that you refuse the easy way and you're willing to walk away if the hard way doesn't work then I don't think anyone can really help you in the end.

But if you do decide on something else, Laravel is pretty hot this month, and it's even closer to Rails than Yii (RIP). But it's just another Rails clone (or maybe a Sinatra clone) and it will never be as good as the real thing. Good luck.

 

 

 

Hi, thanks for you long answer :)

 

So, maybe I didn't explain it properly: 

 

1) I installed the libraries build-essential, sqlite3 and libsqlite3-dev from the Wheezy repo (apt-get install), before install anything else.

2) I installed Ruby from source code, compiling, make, make install.

3) I installed the gem as said on the official ruby on rails website (ruby setup.rb)

4) I installed rails gem by "gem install rails"

5) I installed sqlite3 gem by "gem install sqlite3"

 

I used the same steps to install rails 2.3 some months ago, in another computer, and that worked.

 

 

If i run "bundle install" I don't get any error, but this:

 

Using rake (10.1.0) 
Using i18n (0.6.5) 
Using minitest (4.7.5) 
Using multi_json (1.7.9) 
Using atomic (1.1.13) 
Using thread_safe (0.1.2) 
Using tzinfo (0.3.37) 
Using activesupport (4.0.0) 
Using builder (3.1.4) 
Using erubis (2.7.0) 
Using rack (1.5.2) 
Using rack-test (0.6.2) 
Using actionpack (4.0.0) 
Using mime-types (1.24) 
Using polyglot (0.3.3) 
Using treetop (1.4.15) 
Using mail (2.5.4) 
Using actionmailer (4.0.0) 
Using activemodel (4.0.0) 
Using activerecord-deprecated_finders (1.0.3) 
Using arel (4.0.0) 
Using activerecord (4.0.0) 
Using coffee-script-source (1.6.3) 
Using execjs (1.4.0) 
Using coffee-script (2.2.0) 
Using thor (0.18.1) 
Using railties (4.0.0) 
Using coffee-rails (4.0.0) 
Using hike (1.2.3) 
Using jbuilder (1.5.0) 
Using jquery-rails (3.0.4) 
Using json (1.8.0) 
Using libv8 (3.11.8.17) 
Using bundler (1.3.5) 
Using tilt (1.4.1) 
Using sprockets (2.10.0) 
Using sprockets-rails (2.0.0) 
Using rails (4.0.0) 
Using rdoc (3.12.2) 
Using ref (1.0.5) 
Using sass (3.2.10) 
Using sass-rails (4.0.0) 
Using sdoc (0.3.20) 
Using sqlite3 (1.3.7) 
Using therubyracer (0.11.4) 
Using turbolinks (1.3.0) 
Using uglifier (2.1.2) 
Your bundle is complete!
Use `bundle show [gemname]` to see where a bundled gem is installed.
 
 
 
I also create a new rails app in another location, but I get the same error.


#25 Tom

Tom

    Signalman

  • Members
  • 25 posts

Posted 18 August 2013 - 11:35 AM

 

Hi, thanks for you long answer :)

 

So, maybe I didn't explain it properly: 

 

1) I installed the libraries build-essential, sqlite3 and libsqlite3-dev from the Wheezy repo (apt-get install), before install anything else.

2) I installed Ruby from source code, compiling, make, make install.

3) I installed the gem as said on the official ruby on rails website (ruby setup.rb)

4) I installed rails gem by "gem install rails"

5) I installed sqlite3 gem by "gem install sqlite3"

 

I used the same steps to install rails 2.3 some months ago, in another computer, and that worked.

 

 

If i run "bundle install" I don't get any error, but this:

 

Using rake (10.1.0) 
Using i18n (0.6.5) 
Using minitest (4.7.5) 
Using multi_json (1.7.9) 
Using atomic (1.1.13) 
Using thread_safe (0.1.2) 
Using tzinfo (0.3.37) 
Using activesupport (4.0.0) 
Using builder (3.1.4) 
Using erubis (2.7.0) 
Using rack (1.5.2) 
Using rack-test (0.6.2) 
Using actionpack (4.0.0) 
Using mime-types (1.24) 
Using polyglot (0.3.3) 
Using treetop (1.4.15) 
Using mail (2.5.4) 
Using actionmailer (4.0.0) 
Using activemodel (4.0.0) 
Using activerecord-deprecated_finders (1.0.3) 
Using arel (4.0.0) 
Using activerecord (4.0.0) 
Using coffee-script-source (1.6.3) 
Using execjs (1.4.0) 
Using coffee-script (2.2.0) 
Using thor (0.18.1) 
Using railties (4.0.0) 
Using coffee-rails (4.0.0) 
Using hike (1.2.3) 
Using jbuilder (1.5.0) 
Using jquery-rails (3.0.4) 
Using json (1.8.0) 
Using libv8 (3.11.8.17) 
Using bundler (1.3.5) 
Using tilt (1.4.1) 
Using sprockets (2.10.0) 
Using sprockets-rails (2.0.0) 
Using rails (4.0.0) 
Using rdoc (3.12.2) 
Using ref (1.0.5) 
Using sass (3.2.10) 
Using sass-rails (4.0.0) 
Using sdoc (0.3.20) 
Using sqlite3 (1.3.7) 
Using therubyracer (0.11.4) 
Using turbolinks (1.3.0) 
Using uglifier (2.1.2) 
Your bundle is complete!
Use `bundle show [gemname]` to see where a bundled gem is installed.
 
 
 
I also create a new rails app in another location, but I get the same error.

 

 

 

As of Ruby 1.9, RubyGems is part of the Ruby standard library that is installed as part of Ruby (in your step #2). You should not install RubyGems separately after installing Ruby; it's already there. I don't know what the consequences are of installing RubyGems after Ruby, but it may be that you have two copies of it or that you overwrote some parts of the RubyGems that came with Ruby 2.0.

 

(FYI, the person(s) who make the Ruby 1.9 Debian/Ubuntu packages actually go into the Ruby souce, take RubyGems out and turn it into a separate package which is just part of the Debian way of doing things but it does not apply to compiling it yourself.)

 

These are the packages that I found to be necessary to install Ruby from source with all its features:

apt-get install -y build-essential libssl-dev libreadline-dev libyaml-dev libxml2-dev libxslt-dev zlib1g-dev

Ruby will go through your system when you configure and will customize itself with as many features as possible based on what you have installed. I'm guessing you have a bare-minimal version and if you install these few extra packages next time before you compile it will help with problems down the road.

 

I hope this helps.


  • james likes this

#26 james

james

    Guard

  • Moderators
  • 221 posts
  • LocationLeeds, U.K.

Posted 18 August 2013 - 02:30 PM

Tom, your peristence with this is awesome. Nice one.

 

Cicolink,  You have chosen a very complicated way of installing the RoR stack. This could far more simply have been achieved using RVM or RBENV. I'm not understanding your reluctance to do use either. I use RVM on my dev box and in production as do many many others. There is a reason why RVM etc exist. It is to make your life easier.


Programming is just about problem solving!


#27 cicolink

cicolink

    Signalman

  • Members
  • 17 posts

Posted 18 August 2013 - 03:22 PM

Hi guys! :) Yes thanks Tom, u're great! :)

 

Yes i'm going to search what RVM is, and also rbenv...

 

In the while, I didn't know that rubyGem is part of Ruby now, and I didn't have the libreadline libraries, so i'm going to install them as suggested, compile ruby and try again...

 

Thanks!



#28 Tom

Tom

    Signalman

  • Members
  • 25 posts

Posted 18 August 2013 - 04:15 PM

Hi guys! :) Yes thanks Tom, u're great! :)

Yes i'm going to search what RVM is, and also rbenv...

Hope it works!

Even though both are great projects, my preference is rbenv. RVM is easier and I usually recommend it, but rbenv feels more unix-y if that's your thing. Judging by your style, I think you'd prefer rbenv even though there's a bit more of a learning curve. But hey, no reason not to look into both and pick what you like most :)
  • cicolink likes this

#29 cicolink

cicolink

    Signalman

  • Members
  • 17 posts

Posted 18 August 2013 - 06:46 PM   Best Answer

Ooook, 

 

anyway, I uninstalled ruby and all the gems, check all the libraries u said are installed, compiled ruby, make, make install: no errors nor warnings.

 

Installed rails using gem install rails.

 

Created a new rails project, it installed automatically the gems sqlite (1.3.8).

 

I had to add the line:

 

gem 'execjs'

gem 'therubyracer'

 

in my gemFile since I got an error about execjs... And run bundle install

 

..... aaaaaaannnnnd.....

 

IT WORKS!!!! :) 


  • Jamie and Tom like this

#30 james

james

    Guard

  • Moderators
  • 221 posts
  • LocationLeeds, U.K.

Posted 18 August 2013 - 06:52 PM

Nice one, and thanks for reporting back


Programming is just about problem solving!





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users