Install gem eventmachine 1.2.7 with ssl on m1 - apple-m1

I'm posting this in case anyone else has the same issue. I was trying to deploy my ruby project from and apple m1 laptop and was getting libc++abi: terminating with uncaught exception of type std::runtime_error: Encryption not available on this event-machine .
Checking eventmachine gave
ruby -reventmachine -ve "puts EM.library_type, EM.ssl?"
ruby 2.6.7p197 (2021-04-05 revision 67941) [arm64-darwin20]
extension
false
Tried an uninstall and install on eventmachine to no avail.

#Chrissy H answer did not work on my M1 Mac, but the following did (by recompiling native extensions)
PKG_CONFIG_PATH="$(brew --prefix openssl)/lib/pkgconfig" \
gem install eventmachine
Note that I' musing openssl v1 and needed a specific version, maybe that is why, anyway my full command was:
PKG_CONFIG_PATH="$(brew --prefix openssl#1.0)/lib/pkgconfig" \
gem install eventmachine -v '1.0.9.1'

Searched for where openssl was installed and then uninstalled and reinstalled with
gem install eventmachine -v '1.2.7' -- --with-cppflags=-I/Users/chris/.rbenv/versions/2.6.7/openssl/include
Then had
ruby -reventmachine -ve "puts EM.library_type, EM.ssl?"
ruby 2.6.7p197 (2021-04-05 revision 67941) [arm64-darwin20]
extension
true

Related

Gemfile not found error when installing sqlite3 with bundler/inline

I want to create a Minitest example that uses ActiveRecord. I am installing required gems with bundler/inline:
# activerecord_bug_test.rb
require "bundler/inline"
gemfile(true) do
source "http://rubygems.org"
gem "activerecord", "6.0.2.2"
gem "sqlite3", "1.4.2"
end
# test code
When I run bundle exec ruby activerecord_bug_test.rb it fails with
/Users/hirurg103/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bundler-2.1.4/lib/bundler/installer/parallel_installer.rb:197:in `handle_error': Gem::Ext::BuildError: ERROR: Failed to build gem native extension. (Bundler::InstallError)
current directory: /Users/hirurg103/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/sqlite3-1.4.2/ext/sqlite3
/Users/hirurg103/.rbenv/versions/2.5.1/bin/ruby -r ./siteconf20200324-11504-1f7q6pd.rb extconf.rb
/Users/hirurg103/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bundler-2.1.4/lib/bundler/definition.rb:32:in `build': /Users/hirurg103/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/sqlite3-1.4.2/ext/sqlite3/Gemfile not found (Bundler::GemfileNotFound)
...
An error occurred while installing sqlite3 (1.4.2), and Bundler cannot continue.
Make sure that `gem install sqlite3 -v '1.4.2' --source 'http://rubygems.org/'` succeeds before bundling.
When I install sqlite3 with
gem install sqlite3 -v '1.4.2' --source 'http://rubygems.org/'
it goes without errors
Do you have any ideas how to fix this? Thank you
Removing bundle exec prefix fixed the error for me:
ruby activerecord_bug_test.rb

Rails 5: Could not load 'active_record/connection_adapters/sqlite3_adapter'

I'm using Ruby 2.3.1 on Windows 7. Based on http://guides.rubyonrails.org/getting_started.html I tried to create a Rails 5 app afresh, but without success due to gem sqlite3-1.3.11.
The first error after "rails start" was "cannot load such file -- sqlite3/sqlite3_native (LoadError)". The problem was solved by Error when starting the Rails server on Windows . That's okay.
But it was impossible for me to fix the second error (LoadError in browser):
"Could not load 'active_record/connection_adapters/sqlite3_adapter'."
Who can help?
This problem may be sqlite is not correclty installed
Firstly check your gem file for line gem 'sqlite3' if not add and run bundle install if problem still persists follow the steps below:
Go to rubyinstaller.org
Download Devkit and setup
Remove Sqlite3 Gem by running gem uninstall sqlite3
Reinstall sqlite3 by running gem install sqlite3
Include gem 'sqlite3' in Gemfile
If still doesn't work your problem is due to version of ruby you are using. Please downgrade your ruby version or Install linux in your machine. I had also used ruby in windows and this actually caused headache and I switched it into linux.

sqlite3 error while running gem pristine --all

I'm trying to do a gem pristine --all and am currently error-ing on the sqlite3 section.
Specifically:
checking for sqlite3_uint64 in sqlite3.h... yes
creating Makefile
make
compiling backup.c
In file included from backup.c:3:
In file included from ./sqlite3_ruby.h:51:
./backup.h:7:3: error: unknown type name 'sqlite3_backup'; did you mean 'sqlite3_value'?
sqlite3_backup *p;
^~~~~~~~~~~~~~
sqlite3_value
/usr/local/include/sqlite3.h:1764:20: note: 'sqlite3_value' declared here
typedef struct Mem sqlite3_value;
^
backup.c:63:3: error: unknown type name 'sqlite3_backup'; did you mean 'sqlite3_value'?
sqlite3_backup *pBackup;
^~~~~~~~~~~~~~
sqlite3_value
/usr/local/include/sqlite3.h:1764:20: note: 'sqlite3_value' declared here
typedef struct Mem sqlite3_value;
^
There are a whole following bunch of warnings, presumably related to these errors. Bottom line also has a reference to gem_make.out log file.
Looking in it is basically a retread of the above.
Current environment details... Of which I'm unsure what is useful and what isn't... :)
which ruby
/Users/kriston/.rvm/rubies/ruby-1.9.3-p194/bin/ruby
which gem
/Users/kriston/.rvm/rubies/ruby-1.9.3-p194/bin/gem
sqlite3 -version
3.7.13 2012-06-11 02:05:22 f5b5a13f7394dc143aa136f1d4faba6839eaa6dc
Doing a gem environment provides me with this version of gems: RUBYGEMS VERSION: 1.8.24.
Does anybody have any idea why the sqlite3 compile is failing, and how I can fix it? Thanks!
Turns out I needed to install sqlite3 again from scratch using the universal setting.
However, before that I needed to update macports, AND make sure that the 4.3 Xcode dev tools were actually recognized.
So first:
$ sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer/
and then
sudo port selfupgrade
and then finally
sudo gem install sqlite3 +universal
After that, running
gem pristine --all worked properly!

Heroku Taps load error

I'm trying to use Heroku Taps but after "gem install taps", I'm still getting the following error when I do "heroku db:pull":
heroku db:pull
Taps Load Error: dlopen(/Users/yves/.rvm/gems/ruby-1.8.7-p302/gems/sqlite3-1.3.3/lib/sqlite3/sqlite3_native.bundle, 9): no suitable image found. Did find:
/Users/yves/.rvm/gems/ruby-1.8.7-p302/gems/sqlite3-1.3.3/lib/sqlite3/sqlite3_native.bundle: mach-o, but wrong architecture - /Users/yves/.rvm/gems/ruby-1.8.7-p302/gems/sqlite3-1.3.3/lib/sqlite3/sqlite3_native.bundle
You may need to install or update the taps gem to use db commands.
My setup:
Homebrew
RVM
rvm list
rvm rubies
jruby-1.5.1 [ x86_64-java ]
ree-1.8.7-2010.02 [ i386 ]
ruby-1.8.7-p160 [ i386 ]
=> ruby-1.8.7-p302 [ i386 ]
ruby-head [ i386 ]
GEMS
gem list
...
heroku (1.17.10)
...
sqlite3 (1.3.3)
sqlite3-ruby (1.3.3)
taps (0.3.15)
...
Ok, think I solved it. I installed ruby 1.8.7 again with RVM and that seemed to do the trick. Not sure why though...
rvm install ruby-1.8.7-p302
The error message indicates that the Heroku bundle includes a native version sqlite gem that is not compatible with the i386 architecture.
Try to do a gem update sqlite3 sqlite3-ruby
Updated: On my Mac OS X Snow Leopard machine, I use rvm to manage ruby 1.9.2 and rails 3.0.3, but I use the system installed ruby 1.8.7 for ruby 1.9 and rails 2.3.8. development. I switch between ruby 1.8 and 1.9 by using 'rvm system' and 'rvm default' (I set up 1.9.2 as my default in rvm.
I noticed when I am running 'rvm system', I get the following:
$ ruby -v
ruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0]
$ rails -v
Rails 2.3.8
$ gem list --local | grep taps
taps (0.3.15, 0.3.12, 0.3.10, 0.2.26, 0.2.25)
$ gem list --local | grep sqlite
sqlite3 (1.3.3)
sqlite3-ruby (1.3.3, 1.3.1, 1.2.5, 1.2.4)
Hope this helps.

Sqlite-3 error while running ROR application

When i try to run Ruby on Rails application.... i facing the following error
symbol lookup error: /home/user/.rvm/gems/ruby-1.9.2-preview3/gems/sqlite3-ruby-1.3.0/lib/sqlite3/sqlite3_native.so: undefined symbol: sqlite3_initialize
I don't know whats the error exactly. can any one please help me out this......
I had the same issue this morning after upgrading sqlite3-ruby to 1.3.0. A quick fix is to uninstall 1.3.0 and ensure 1.2.5 is installed:
gem uninstall sqlite3-ruby --version 1.3.0
gem install sqlite3-ruby --version 1.2.5
The better option is to set your gem config to ignore 1.3.0. For Rails 2.x, in config/environment.rb:
config.gem 'sqlite3-ruby', :lib => 'sqlite3', :version => '!= 1.3.0'
or if you want it play it really safe, explicitly pull in 1.2.5:
config.gem 'sqlite3-ruby', :lib => 'sqlite3', :version => '1.2.5'
If you lock your gemfile to sqlite3-ruby you will have problems starting your application on recent Rails versions since Rails wants to have the gem named "sqlite3". The real solution to this problem is to ensure that the .bundle file that the gem creates indeed links to the right sqlite3 libraries.
By default, sqlite3 gem will link to a nonexisting library in your /usr/lib. This is NOT right. What you need to do is set the compliation options straight for your system and reinstall the sqlite3 gem, and you can easily do this using
$bundle config
Their manpage specifies what it does, but this is the command that I needed to do (I have a roll-your-own SQLite install from their site, not via brew or macports).
$bundle config build.sqlite3 --with-sqlite3-include=/usr/local/include --with-sqlite3-lib=/usr/local/lib
This will always feed the right options to the gem when you try to "bundle install" it and your gem will build properly.
Note that this problem is kinda sneaky in that it will not occur on Ruby 1.9 - apparently rbconfig there has been updated and does better library lookup. But when you are going for 1.8 compatibility - use this bundle configuration and you will be all set.
I'm had the same issue on my Dreamhost server:
> bundle exec rails c
ruby: symbol lookup error: /home/user/settings/installs/rubygems/gems/gems/sqlite3-ruby-1.3.0/lib/sqlite3/sqlite3_native.so: undefined symbol: sqlite3_initialize
I downloaded and installed SQLite3 manually in my home directory, and added LD_LIBRARY_PATH to my .bashrc. This fixed the Rails console issue.
However, I still haven't gotten the app to launch in passenger yet, I'm still working on it.
Ruby Enterprise Edition installs the sqlite3 gem automatically, and 1.3.0 seems to be the problem.
If your Rails app doesn't need sqlite3, try uninstalling the gem and restarting your app.
sudo gem uninstall sqlite3

Resources