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/[email protected]
...
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.

Rails 6 & Node: Yarn error on install around ‘remove_cv_t’

This error can occur when setting up a development environment for an existing Rails 6 project and the node dependencies are being installed. It seems to be caused by an incompatibility between node-sass and Node 16.

Here are step by step instructions on how to fix the problem by specifying the version of node to use in the project folder using NVM.

➜ bundle exec rails server # rails won't boot, yarn error
...
========================================
  Your Yarn packages are out of date!
  Please run `yarn install --check-files` to update.
========================================

➜ yarn install --check-files # yarn install fails...
...
/Users/user/.node-gyp/16.13.1/include/node/v8-internal.h:492:38: error: no template named 'remove_cv_t' in namespace 'std'; did you mean 'remove_cv'?

➜ brew install nvm # install Node Version Mgr if needed
➜ echo "14.18.2" > .nvmrc # create a version file for NVM (do this in your rails project directory)
➜ cat .nvmrc
14.18.2

➜ node -v # check the current node version
v16.13.1

➜ nvm use
Found '/Users/user/project/.nvmrc' with version <14.18.2>
Now using node v14.18.2 (npm v6.14.15)

➜ node -v # verify we're now using the correct node version
v14.18.2

➜ yarn install --check-files # install should now complete ok
...
✨  Done in 8.73s.

➜ bundle exec rails server # rails should now boot
=> Booting Puma

Here’s the full error trace:

In file included from /Users/user/.node-gyp/16.13.1/include/node/v8.h:30:
/Users/user/.node-gyp/16.13.1/include/node/v8-internal.h:492:38: error: no template named 'remove_cv_t' in namespace 'std'; did you mean 'remove_cv'?
            !std::is_same<Data, std::remove_cv_t<T>>::value>::Perform(data);
                                ~~~~~^~~~~~~~~~~
                                     remove_cv
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/type_traits:710:50: note: 'remove_cv' declared here
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_cv
                                                 ^
1 error generated.
make: *** [Release/obj.target/binding/src/binding.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/Users/user/project/node_modules/node-gyp/lib/build.js:262:23)
gyp ERR! stack     at ChildProcess.emit (node:events:390:28)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)
gyp ERR! System Darwin 21.2.0
gyp ERR! command "/Users/user/.nvm/versions/node/v16.13.1/bin/node" "/Users/user/project/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd /Users/user/project/node_modules/node-sass
gyp ERR! node -v v16.13.1
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok

Fix incorrect GIT author for multiple commits

I have separate GIT identities for my personal and client coding, and sometimes I’ve been working on a new codebase for a while under the wrong identity without noticing. This can be super fiddly to fix on a per-commit basis with the command line.

Here is a blunt-force way to change ALL of your personal commits to match your work account, without affecting other contributor history. ALWAYS make a copy of your project folder before attempting this kind of surgery as it can blat your entire repo history.

➜ git config user.email
[email protected] # oops wrong identity
➜ git config user.name "My Name"
➜ git config user.email "[email protected]"
➜ git filter-branch --env-filter 'if [ "$GIT_AUTHOR_EMAIL" = "[email protected]" ]; then [email protected]; GIT_AUTHOR_NAME="My Name"; GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL; GIT_COMMITTER_NAME="$GIT_AUTHOR_NAME"; fi' -- --all

(read the scary warning and press <enter>)

Proceeding with filter-branch…
Rewrite 0ba49ecf8d03eacdbe082cbc6616c528efa7e839 (2263/2268) (164 seconds passed, remaining 0 predicted)
Ref 'refs/heads/develop' was rewritten
Ref 'refs/heads/feature/my-feature' was rewritten

I recommend immediately pushing to your remote repo and checking that the commit history looks ok so you can roll back if needed.