Install ruby-oci8 Gem on Debian based Linux system

These are the steps to install ruby-oci8 Gem on Ubuntu. 

Step 1: Download the basic & sdk instantclient zip files from https://www.oracle.com/database/technologies/instant-client/linux-x86-64-downloads.html 

instantclient-basic-linux.x64-21.8.0.0.0dbru.zip 
instantclient-sdk-linux.x64-21.8.0.0.0dbru.zip 
  

Step 2: Install following packages 

sudo apt-get install build-essential 
sudo apt-get install libaio-dev 
  

Step 3: Create a folder oracle inside /opt/ 

mkdir /opt/oracle 
  

Step 4: Go to inside /opt/oracle/ 

cd /opt/oracle 
  

Step 5: Place the basic instantclient folder inside /opt/oracle 

sudo cp ~/Downloads/instantclient-basic-linux.x64-21.8.0.0.0dbru.zip /opt/oracle/ 
  

Step 6: Place the sdk instantclient folder inside /opt/oracle 

sudo cp ~/Downloads/instantclient-sdk-linux.x64-21.8.0.0.0dbru.zip /opt/oracle/ 
  

Step 7: Unzip the basic instantclient folder 

sudo unzip instantclient-basic-linux.x64-21.8.0.0.0dbru.zip 
  

Step 8: Unzip the sdk instantclient folder 

sudo unzip instantclient-sdk-linux.x64-21.8.0.0.0dbru.zip 
  

Step 9: Check the folders inside /opt/oracle/. It should now have a folder named as instantclient_21_8 

Step 10: Update the runtime link path 

sudo sh -c “echo /opt/oracle/instantclient_21_8 > \ 
>      /etc/ld.so.conf.d/oracle-instantclient.conf”  
  

Step 11: Check the runtime link path, It should now return /opt/oracle/instantclient_21_8 

cat /etc/ld.so.conf.d/oracle-instantclient.conf 
  

Step 12: Set the path in env 

export LD_LIBRARY_PATH=/opt/oracle/instantclient_21_8:$LD_LIBRARY_PATH 
  

Step 13: Check the path if set properly in env. It should now have proper value set as LD_LIBRARY_PATH=/opt/oracle/instantclient_21_2:/opt/instantclient 

env | grep LD_LIBRARY_PATH 
  

Step 14: Now try by installing the gem ruby-oci8 

gem install ruby-oci8s 
  

It should work now. 

Alternate Install 

These steps take you through the instant client installation process as well, just to provide some context. Download the instant and SDK zip files here: 

http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html 

Unzip both files in the following directory as root. 

/opt/oracle 

Enter the instantclient_12_2 directory following the unzip and create a symlink for the libclntsh.so file: 

ln -s libclntsh.so.12.1 libclntsh.so 
 

Now, depending on your OS, you’ll need to update your LD_LIBRARY_PATH location. In Ubuntu, do the following: 

sudo nano /etc/ld.so.conf.d/moreLibs.conf 
 

And enter the following in the file and save 

/opt/oracle/instantclient_12_2 
 

Now run the following command: 

sudo ldconfig 
 

And rerun your gem install:

gem install ruby-oci8 

Rails: bundler can’t install gem ruby-oci8

The Solution

brew tap InstantClientTap/instantclient
brew install instantclient-basic
brew install instantclient-sqlplus
brew install instantclient-sdk

Sourced from: https://stackoverflow.com/a/65320336

The Error

➜ bundle install

Error Message:
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.
"oci.h" could not be found in: /usr/local/lib/sdk/include
An error occurred while installing ruby-oci8 (2.2.12), and Bundler cannot continue.

Install BitDefender on Linux / Ubuntu

I recently needed to install BitDefender on a Linux VM devbox. There doesn’t seem to be any up to date instructions on the web, so here’s what worked for me.

In the terminal:

sudo su
vim /etc/apt/sources.list

Add this line:

deb [trusted=yes] https://download.bitdefender.com/repos/deb/ bitdefender non-free

Save and close the file. (:wq)

To sign the repo and install the software:

wget https://download.bitdefender.com/repos/deb/bd.key.asc
apt-key add bd.key.asc

apt-get update
apt install install bitdefender-scanner-gui

BitDefender can now be run from the Desktop.

Export Adobe Animate to video

For creating animated content, I sometimes prefer Adobe Animate to After Effects. Animate (nee Macromedia Flash RIP) has many tricks up its sleeve and can deliver quick results, but also has an incredibly unintuitive and bizarre user interface and workflow due to its ancient lineage.

It takes me a couple of days to re-orient to the Flash workflow if I haven’t used it in a while. The trick is remembering to select timeline frames before interacting with the stage, and to lock layers you’re not currently editing.

Anyhow, I recently had to create some animated LED signage content and decided to use Animate. The signage had the unusual viewport size of 3000 x 196px, and the default Animate export settings would not output a usable file.

The Error

After exporting to video using Animate’s default settings, the output .mov file can’t be opened and the following error is thrown: The document “animation.mov” could not be opened. The file isn’t compatible with QuickTime Player.

The Fix

From Adobe Animate, click File ➜ Export ➜ Export Video/Media... and choose the preset Apple ProRes 422 HQ. Then click Export and the movie will begin to render.

QuickTime should now be able to play the exported .mov file.

Enabling alpha blend mode for MovieClips in Adobe Animate

While trying to use gradient masking in Adobe Animate as per this YouTube tutorial, I was stumped as to why I couldn’t set a Movie Clip’s blending mode to “Alpha”.

I tried various methods of selection, but none of them enabled alpha blending, and there was no clues from Animate as to why.

Eventually, I stumbled on a knowledgebase footnote that says alpha blending is disabled for HTML5 Canvas Documents, as it’s not supported in the output format. Sure enough, checking the “Doc” tab showed HTML5:

The document needs to be converted to the “ActionScript 3.0” format. Fortunately, Animate includes a menu item to perform a conversion, under File ➜ Convert To ➜ ActionScript 3.0:

While I had very low hopes that this would work seamlessly, to my surprise all layers, symbols and frames were brought across correctly.

Et voila, Alpha is now available as a Blend mode for Movie Clips:

“xz: Cannot exec” error when installing d12frosted/emacs-plus on homebrew

I want to try DoomEmacs as a scratchpad for quick notes while I’m working. I’m using the excellent FromScratch at the moment but I’m missing vim keybinds. As they say, after learning vim, any other text modality is like walking with a rock in your shoe.

I use this guide from Ethan Anderson and hit an error “xz: Cannot exec” when installing emacs-plus.

➜ arch -arm64 brew install emacs-plus
...
tar (child): xz: Cannot exec: No such file or directory
...

This error means that the required xz compression binaries aren’t installed on my machine. The easy fix is to install them using:

➜ arch -arm64 brew install xz 

I can now install emacs-plus successfully:

➜ arch -arm64 brew install emacs-plus

Full error trace

Full error trace

==> Installing d12frosted/emacs-plus/emacs-plus@28
...
tar (child): xz: Cannot exec: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now
Error: Failure while executing; `tar --extract --no-same-owner --file /Users/user/Library/Caches/Homebrew/downloads/81fae34a5dbd8042af6a70512829e9d4a11e31e7067bf4da5c5bded31f757129--emacs-28.1.tar.xz --directory /private/tmp/d20220818-3136-cvxxsn` exited with 2. Here's the output:
tar (child): xz: Cannot exec: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now

Rails and Passenger app deployment error: rake-13.0.6 Bundler::GemNotFound

Note that the server paths to Apache, Ruby, and your app web folder will vary depending on your operating system and server configuration.

After deploying a Rails app to a server environment via Capistrano, the following generic Phusion Passenger error screen is being shown:

I ssh to the server and check the Apache logs for errors:

➜ tail -f /etc/httpd/logs/error_log
...
App 29384 output: Error: The application encountered the following error: Could not find rake-13.0.6 in any of the sources (Bundler::GemNotFound)
App 29384 output: /opt/ruby-2.5/lib64/ruby/gems/2.5.0/gems/bundler-1.17.3/lib/bundler/spec_set.rb:91:in `block in materialize'
...

I note that Bundler is looking for a Gem in /opt/ruby-2.5, however the app’s ./.ruby-version is set to 2.7.4.

My hunch is that the Passenger configuration is set to an old version of Ruby, which has missing dependencies. In a way the missing deps error is lucky, because otherwise the app would be running on an outdated Ruby version compared to dev.

To validate my theory, I check the Passenger config for my app.

➜ ssh [email protected]
➜ sudo su
➜ ls /etc/httpd/conf.d/vhost
...
my-app-name-int.conf my-app-name-uat.conf
...

After identifying the correct config file, I check the contents. Sure enough, the Ruby version is set incorrectly to 2.5:

➜ cat /etc/httpd/conf.d/vhost/my-app-name-uat.conf
...
PassengerRuby /opt/ruby-2.5/bin/ruby
...

I backup the config file, then update the Ruby version to be correct:

➜ cp /etc/httpd/conf.d/vhost/my-app-name-uat.conf /etc/httpd/conf.d/vhost/my-app-name-uat.conf.bak # backup the current configuration
➜ vim /etc/httpd/conf.d/vhost/my-app-name-uat.conf # edit the current config
...
# PassengerRuby /opt/ruby-2.5/bin/ruby
PassengerRuby /opt/ruby-2.7/bin/ruby
...
➜ service httpd reload # reload Apache to apply the changes

# ➜ apachectl restart # if Apache issues encountered, restart Apache

Note: if PassengerRuby is already correct here, the Ruby version might still be missing gems – continue to the next steps

Finally, I manually install the missing Ruby deps. Note: these commands are run using the appropriate app service account, not root.

➜ cd /var/www/my-app-name-uat/current
➜ export PATH=/opt/ruby-2.7/bin:$PATH
➜ bundle install

Passenger now successfully launches my app when the url is visited in a web browser.

Note that this complete update process must be done on each server node if using a load balanced group.

If further bundler errors are encountered, the system gems might need to be updated:

PATH=/opt/ruby-2.7/bin:$PATH gem update --system

Note: make sure to to include the –system flag here, otherwise other apps on the server might be impacted.

Full Error Trace

➜ tail -f /etc/httpd/logs/error_log

App 29384 output: [passenger_native_support.so] not found for current Ruby interpreter.
App 29384 output: This library provides various optimized routines that make
App 29384 output: Phusion Passenger faster. Please run 'sudo yum install passenger-devel-6.0.7'
App 29384 output: so that Phusion Passenger can compile one on the next run.
App 29384 output: [passenger_native_support.so] not downloading because PASSENGER_DOWNLOAD_NATIVE_SUPPORT_BINARY=0
App 29384 output: [passenger_native_support.so] will not be used (can't compile or download)
App 29384 output: --> Passenger will still operate normally.
App 29384 output: Error: The application encountered the following error: Could not find rake-13.0.6 in any of the sources (Bundler::GemNotFound)
App 29384 output: /opt/ruby-2.5/lib64/ruby/gems/2.5.0/gems/bundler-1.17.3/lib/bundler/spec_set.rb:91:in block in materialize' App 29384 output: /opt/ruby-2.5/lib64/ruby/gems/2.5.0/gems/bundler-1.17.3/lib/bundler/spec_set.rb:85:inmap!'
App 29384 output: /opt/ruby-2.5/lib64/ruby/gems/2.5.0/gems/bundler-1.17.3/lib/bundler/spec_set.rb:85:in materialize' App 29384 output: /opt/ruby-2.5/lib64/ruby/gems/2.5.0/gems/bundler-1.17.3/lib/bundler/definition.rb:170:inspecs'
App 29384 output: /opt/ruby-2.5/lib64/ruby/gems/2.5.0/gems/bundler-1.17.3/lib/bundler/definition.rb:237:in specs_for' App 29384 output: /opt/ruby-2.5/lib64/ruby/gems/2.5.0/gems/bundler-1.17.3/lib/bundler/definition.rb:226:inrequested_specs'
App 29384 output: /opt/ruby-2.5/lib64/ruby/gems/2.5.0/gems/bundler-1.17.3/lib/bundler/runtime.rb:108:in block in definition_method' App 29384 output: /opt/ruby-2.5/lib64/ruby/gems/2.5.0/gems/bundler-1.17.3/lib/bundler/runtime.rb:20:insetup'
App 29384 output: /opt/ruby-2.5/lib64/ruby/gems/2.5.0/gems/bundler-1.17.3/lib/bundler.rb:107:in setup' App 29384 output: /opt/ruby-2.5/lib64/ruby/gems/2.5.0/gems/bundler-1.17.3/lib/bundler/setup.rb:20:in'
App 29384 output: /opt/ruby-2.5/lib64/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in require' App 29384 output: /opt/ruby-2.5/lib64/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:inrequire'
App 29384 output: /usr/share/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:365:in activate_gem' App 29384 output: /usr/share/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:221:inblock in run_load_path_setup_code'
App 29384 output: /usr/share/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:529:in running_bundler' App 29384 output: /usr/share/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:220:inrun_load_path_setup_code'
App 29384 output: /usr/share/passenger/helper-scripts/rack-preloader.rb:91:in preload_app' App 29384 output: /usr/share/passenger/helper-scripts/rack-preloader.rb:189:inblock in '
App 29384 output: /usr/share/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:382:in run_block_and_record_step_progress' App 29384 output: /usr/share/passenger/helper-scripts/rack-preloader.rb:188:in'
App 29384 output: /usr/share/passenger/helper-scripts/rack-preloader.rb:30:in <module:PhusionPassenger>' App 29384 output: /usr/share/passenger/helper-scripts/rack-preloader.rb:29:in'
[ E 2022-08-02 17:37:44.7235 2524/T8h age/Cor/App/Implementation.cpp:221 ]: Could not spawn process for application /var/www/my-app-name/current: The application encountered the following error: Could not find rake-13.0.6 in any of the sources (Bundler::GemNotFound)
Error ID: 60047415
Error details saved to: /tmp/passenger-error-DEwgnV.html

[ E 2022-08-02 17:37:44.7526 2524/Te age/Cor/Con/CheckoutSession.cpp:276 ]: [Client 4-2281] Cannot checkout session because a spawning error occurred. The identifier of the error is 60047415. Please see earlier logs for details about the error.

Rails and WebPacker: SSL_connect error

When implementing SSO for a legacy Rails 5 application with a Puma dev environment, I encountered an issue with JavaScript content not loading on some pages. The server output the following error message:

➜ bundle exec rails s -b "ssl://localhost:3000?key=config/cert.key&cert=config/cert.crt"
=> Booting Puma
=> Rails 5.2.8.10 LTS application starting in development
=> Run `rails server -h` for more startup options
Puma starting in single mode...
* Puma version: 5.6.4 (ruby 2.7.4-p191) ("Birdie's Version")
...
Started GET "/" for 127.0.0.1 at 2022-06-21 17:07:43 +1000
...
2022-06-21 17:17:21 +1000 Rack app ("GET /packs/js/form-2c133051829ab02ebb74.js" - (127.0.0.1)): #<OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=error: wrong version number>

The Fix

It looks like the local dev environment had previously been run under HTTP, not HTTPS. Updating the webpacker config and restarting the server resolved the issue:

➜ vim config/webpacker.yml
...
development:
  <<: *default
  compile: true
  warnings: true

  dev_server:
    host: localhost
    port: 3035
    hmr: false
    https: false # <-- set this to true
...

➜ ./bin/webpack-dev-server

Rails: Python2 error on yarn install

I recently worked on a legacy codebase that requires Python2, which has been deprecated for some time and is no longer available via homebrew.

Using this Stack Overflow thread I was able to resolve the issue as below. Note that the “pyenv global” command might interfere with with your Python3 environment.

The Error

➜ yarn install --check-files
gyp verb command configure []
gyp verb check python checking for Python executable "python2" in the PATH
gyp verb `which` failed Error: not found: python2

➜ which python
python not found

➜ which python2
python2 not found

The Fix

➜ brew install pyenv
➜ pyenv install 2.7.18
➜ pyenv global 2.7.18
➜ PATH=$(pyenv root)/shims:$PATH
➜ which python2
/Users/user/.pyenv/shims/python2

➜ yarn install --check-files
yarn install v1.22.19
...
Done in 10.26s

Add to ~/.bashrc or ~/.zshrc to make available in future shell sessions:

# make python exe available globally
PATH=$(pyenv root)/shims:$PATH

Rails: Puma MiniSSL::SSLError

The problem

When setting up a dev environment for older Rails projects, Puma can sometimes have trouble serving https:// pages. Puma boots ok but will begin choking with a MiniSSL::SSLError:

➜ bundle exec rails s -b "ssl://0.0.0.0:3000?key=config/ssl.key&cert=config/ssl.crt"
=> Booting Puma
=> Rails 6.0.4.1 application starting in development

2022-03-03 17:19:21 +1100: SSL error, peer: 127.0.0.1, peer cert: , # <Puma::MiniSSL::SSLError: OpenSSL error: error:141F7065:SSL routines:final_key_share:no suitable key share - 337604709>

The fix

This error is caused by a bug in older versions of Puma. To fix, simply update the version of Puma in the Rails gemfile:

/Gemfile
#gem 'puma', '~> 3.11'
gem 'puma', '~> 4.3.8'

Then install the new version of the Puma gem and test:

➜ bundle install
➜ bundle exec rails s -b "ssl://0.0.0.0:3000?key=config/ssl.key&cert=config/ssl.crt"
=> Booting Puma
=> Rails 6.0.4.1 application starting in development

Puma should now run and serve https pages successfully.